更新部署

This commit is contained in:
RainSun 2021-08-02 19:15:50 +08:00
parent 267b4ee000
commit a1dbdd0b97
2 changed files with 11 additions and 51 deletions

View File

@ -1,16 +1,10 @@
variables:
DOCKER_REGION: "registry.cn-qingdao.aliyuncs.com"
DOCKER_NAMESPACE: "lacus"
DOCKER_USERNAME: "rainsun20170129"
DOCKER_PASSWORD: "100200300Wdy*"
APP_NAME: "wxapi"
IMAGE_NAME: "$DOCKER_REGION/$DOCKER_NAMESPACE/$APP_NAME:$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA"
IMAGE_NAME: "$APP_NAME:$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA"
DOCKER_FILE_PATH: "./Dockerfile"
stages:
- build
- pveclear
- pvedeploy
- clear
- deploy
@ -23,54 +17,20 @@ build:
- dockerbase
script:
- ls -a
- docker login --username=${DOCKER_USERNAME} --password=${DOCKER_PASSWORD} ${DOCKER_REGION}
- docker build -t ${IMAGE_NAME} -f ${DOCKER_FILE_PATH} .
- docker push ${IMAGE_NAME}
- docker rmi ${IMAGE_NAME}
pveclear:
stage: pveclear
tags:
- dockerbase
script:
- docker stop ${APP_NAME}
- docker rm ${APP_NAME}
allow_failure: true
pvedeploy:
stage: pvedeploy
tags:
- dockerbase
script:
- docker login --username=${DOCKER_USERNAME} --password=${DOCKER_PASSWORD} ${DOCKER_REGION}
- docker pull ${IMAGE_NAME}
- docker run -t -d --name ${APP_NAME} -p 8080:80 ${IMAGE_NAME}
cache:
policy: pull
ali2clear:
clear:
stage: clear
tags:
- ali2
only:
- master
- dockerbase
script:
- docker stop ${APP_NAME}
- docker rm ${APP_NAME}
allow_failure: true
when: manual
ali2deploy:
deploy:
stage: deploy
tags:
- ali2
only:
- master
- dockerbase
script:
- docker login --username=${DOCKER_USERNAME} --password=${DOCKER_PASSWORD} ${DOCKER_REGION}
- docker pull ${IMAGE_NAME}
- docker run -t -d --name ${APP_NAME} -p 127.0.0.1:5012:80 ${IMAGE_NAME}
cache:
policy: pull
when: manual
- docker run -t -d --name ${APP_NAME} -p 5013:80 ${IMAGE_NAME}

View File

@ -7,17 +7,17 @@ setting = 'production'
# 获取数据集
def col(arg):
conn = MongoClient('mongodb://wxapi:uJ5hB9mJ0gR2@39.96.28.83:27017/wxapi')
conn = MongoClient('mongodb://wxapi:64FPvMfce822XZ@10.99.0.4:27001/weChatRobot')
if setting == 'development':
arg += '_test'
if arg == 'keyword':
return conn.wxapi.keyword
return conn.weChatRobot.keyword
elif arg == 'access_token':
return conn.wxapi.access_token
return conn.weChatRobot.access_token
elif arg == 'keyword_test':
return conn.wxapi.keyword_test
return conn.weChatRobot.keyword_test
elif arg == 'access_token_test':
return conn.wxapi.access_token_test
return conn.weChatRobot.access_token_test
else:
return False