Commit 0479101a authored by 黄贤军's avatar 黄贤军
parents e7f624ce 78b2eb2c
Pipeline #20817 passed with stage
in 1 minute and 3 seconds
...@@ -3,15 +3,15 @@ image: docker:latest ...@@ -3,15 +3,15 @@ image: docker:latest
stages: stages:
- build - build
- push - push
- deploy
variables: variables:
APP_NAME: dxserver_web APP_NAME: install_web
APP_IMAGE: "${HUANSI_REGISTRY_URL}/huansi/${APP_NAME}" APP_IMAGE: "${HUANSI_REGISTRY_URL}/huansi/${APP_NAME}"
before_script: before_script:
- docker login -u $HUANSI_USER -p $HUANSI_PASSWORD $HUANSI_REGISTRY_URL - docker login -u $HUANSI_USER -p $HUANSI_PASSWORD $HUANSI_REGISTRY_URL
build: build:
stage: build stage: build
retry: 2 retry: 2
...@@ -19,6 +19,8 @@ build: ...@@ -19,6 +19,8 @@ build:
- dev - dev
script: script:
- docker build -t ${APP_IMAGE}:${CI_COMMIT_REF_NAME} . - docker build -t ${APP_IMAGE}:${CI_COMMIT_REF_NAME} .
except:
- master
push: push:
stage: push stage: push
...@@ -26,25 +28,8 @@ push: ...@@ -26,25 +28,8 @@ push:
tags: tags:
- dev - dev
script: script:
- docker push ${APP_IMAGE}:${CI_COMMIT_REF_NAME} - docker build -t ${APP_IMAGE}:${APP_VERSION} .
- docker push ${APP_IMAGE}:${APP_VERSION}
- echo "success" - echo "success"
except:
- dev
deploy-master:
stage: deploy
retry: 2
tags:
- dev
variables:
APP_CNAME: "${APP_NAME}-${CI_COMMIT_REF_NAME}" # 默认不需要操作
APP_PORT: 8110 # 开放端口号,这个需要申请端口号开放 以下都是环境变量
API: "http://172.17.0.1:8109/" # 环境变量 API地址
PORT: 8000 #环境变量 PORT
script:
- docker ps -a | grep -i ${APP_CNAME} > /dev/null 2>&1 && docker stop ${APP_CNAME} && docker rm ${APP_CNAME}
- docker images|grep none|grep ${APP_IMAGE} > /dev/null 2>&1 && docker images|grep none|grep ${APP_IMAGE}|awk '{print $3}'|xargs docker rmi
# 参考环境变量的传递,-e "API1=${API2}",将API2变量传给至程序的API1接收
- docker run --name ${APP_CNAME} -d -p ${APP_PORT}:8000 -e "API=${API}" -e "PORT=${PORT}" $APP_IMAGE:${CI_COMMIT_REF_NAME}
only: only:
- master - web
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment