* #01 init code

This commit is contained in:
yanghanbin
2024-02-22 17:02:36 +08:00
commit b41f0c3b05
4 changed files with 280 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
#接收外部参数,由jenkinsfile执行部署脚本时传递
projectName=$1
imageName=$2
version=$3
profileActive=$4
echo "镜像名: $imageName"
echo "项目名: $projectName"
echo "版本号: $version"
echo "多环境: $profileActive"
# 容器id
containerId=$(docker ps -a | grep -w "${projectName}" | awk '{print $1}')
if [ "$containerId" != "" ] ;
then
#停掉容器
docker stop "$containerId"
#删除容器
docker rm "$containerId"
echo "成功删除容器"
fi
# 镜像id
imageId=$(docker images | grep -w "${projectName}" | awk '{print $3}')
#if [ "$imageId" != "" ] ;
#then
#删除镜像
#docker rmi --force $(docker images | grep -w "${projectName}" | awk '{print $3}')
#echo "成功删除镜像"
#fi
docker login 192.168.3.210:9999
# 镜像下载
docker pull "$imageName"
# cd /data/dev/app
# 启动容器
VERSION="${version}" PROFILE_ACTIVE=${profileActive} docker-compose up -d "${projectName}"
echo "容器启动成功"
# 镜像id
imageId=$(docker images | grep -w "${projectName}" | awk '{print $3}')
#if [ "$imageId" != "" ] ;
#then
#删除镜像
#docker rmi --force $(docker images | grep -w "${projectName}" | awk '{print $3}')
#echo "成功删除镜像"
#fi
+98
View File
@@ -0,0 +1,98 @@
version: "3.8"
services:
ai-auth:
image: 192.168.3.210:9999/ai/ai-auth:${VERSION}
container_name: ai-auth
ports:
- "9206:9206"
mem_limit: 512m
environment:
PROFILE_ACTIVE: ${PROFILE_ACTIVE}
volumes:
- /data/logs/ai-auth/:/data/logs/ai-auth
restart:
always
ai-customer:
image: 192.168.2.210:9999/ai/ai-customer:${VERSION}
container_name: ai-customer
ports:
- "9204:9204"
environment:
PROFILE_ACTIVE: ${PROFILE_ACTIVE}
volumes:
- /data/logs/ai-customer/:/data/logs/ai-customer
restart:
always
ai-file:
image: 192.168.2.210:9999/ai/ai-file:${VERSION}
container_name: ai-file
ports:
- "9208:9208"
environment:
PROFILE_ACTIVE: ${PROFILE_ACTIVE}
volumes:
- /data/logs/ai-file/:/data/logs/ai-file
restart:
always
ai-gateway:
image: 192.168.2.210:9999/ai/ai-gateway:${VERSION}
container_name: ai-gateway
ports:
- "8088:8088"
environment:
PROFILE_ACTIVE: ${PROFILE_ACTIVE}
volumes:
- /data/logs/ai-gateway/:/data/logs/ai-gateway
restart:
always
ai-job:
image: 192.168.2.210:9999/ai/ai-job:${VERSION}
container_name: ai-job
ports:
- "9203:9203"
environment:
PROFILE_ACTIVE: ${PROFILE_ACTIVE}
volumes:
- /data/logs/ai-job/:/data/logs/ai-job
restart:
always
ai-news:
image: 192.168.2.210:9999/ai/ai-news:${VERSION}
container_name: ai-news
ports:
- "9205:9205"
environment:
PROFILE_ACTIVE: ${PROFILE_ACTIVE}
volumes:
- /data/logs/ai-news/:/data/logs/ai-news
restart:
always
ai-route:
image: 192.168.2.210:9999/ai/ai-route:${VERSION}
container_name: ai-route
ports:
- "9207:9207"
environment:
PROFILE_ACTIVE: ${PROFILE_ACTIVE}
volumes:
- /data/logs/ai-route/:/data/logs/ai-route
restart:
always
ai-system:
image: 192.168.2.210:9999/ai/ai-system:${VERSION}
container_name: ai-system
ports:
- "9201:9201"
environment:
PROFILE_ACTIVE: ${PROFILE_ACTIVE}
volumes:
- /data/logs/ai-system/:/data/logs/ai-system
restart:
always
networks:
default:
external:
name: docker_default