docker-vue3/run
2023-10-25 12:14:48 +00:00

35 lines
1.0 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 读取docker.conf文件
source docker.conf
# 设置系统环境变量
export NODE_CONTAINER_NAME=$container_name
export NODE_IMAGE_VERSION=$image_version
# 判断NODE_CONTAINER_NAME的docker容器是否存在如果存在删除它
# if docker ps -a --format '{{.Names}}' | grep -q "^$NODE_CONTAINER_NAME$"; then
# docker rm -f $NODE_CONTAINER_NAME
# fi
if [ $# -eq 0 ]; then
echo "usage: run [start|restart|stop|help]"
exit 1
fi
if [ "$1" = "start" ]; then
docker compose run --rm $NODE_CONTAINER_NAME npm --registry https://registry.npm.taobao.org install
docker compose up -d
elif [ "$1" = "restart" ]; then
docker rm -f $NODE_CONTAINER_NAME
# docker compose run --rm $NODE_CONTAINER_NAME npm --registry https://registry.npm.taobao.org install
docker compose up -d
elif [ "$1" = "stop" ]; then
docker rm -f $NODE_CONTAINER_NAME
elif [ "$1" = "help" ]; then
echo "usage: run [start|restart|stop|help]"
else
echo "无效的参数"
echo "usage: run [start|restart|stop|help]"
exit 1
fi