variables:
PROJECT_NAME: fuluops_svr
stages:
- build_push
.app_build_push: &app_build_push
stage: build_push
image: registry.cn-hangzhou.aliyuncs.com/ich-sre/ops_deploy:2.3
script:
- ls -al && make compile
- docker login -u ${DOCKER_REPOSTORY_USERNAME} -p ${DOCKER_REPOSTORY_PASSPORD} ${DOCKER_REPOSTORY_ADDRESSURL}
- docker build -t ${APP_IMAGE_URL} .
- docker tag ${APP_IMAGE_URL} ${APP_IMAGE_URL}
- docker push ${APP_IMAGE_URL}
- docker rmi -f ${APP_IMAGE_URL}
build svr dev:
<<: *app_build_push
only:
- develop
except:
- tags
variables:
DOCKER_REPOSTORY_USERNAME: $PROD_REGISTRY_USERNAME
DOCKER_REPOSTORY_PASSPORD: $PROD_REGISTRY_PASSWORD
DOCKER_REPOSTORY_ADDRESSURL: $PROD_REGISTRY
APP_IMAGE_URL: $PROD_REGISTRY_REPO/${PROJECT_NAME}:v-$CI_PIPELINE_ID
environment:
name: develop
allow_failure: false
build svr prod:
<<: *app_build_push
only:
- /^rel-[\S]+$/
except:
- branches
variables:
DOCKER_REPOSTORY_USERNAME: $PROD_REGISTRY_USERNAME
DOCKER_REPOSTORY_PASSPORD: $PROD_REGISTRY_PASSWORD
DOCKER_REPOSTORY_ADDRESSURL: $PROD_REGISTRY
APP_IMAGE_URL: $PROD_REGISTRY_REPO/${PROJECT_NAME}:v-$CI_PIPELINE_ID
environment:
name: prod
allow_failure: false
标签:集成,runner,APP,gitlab,URL,build,push,docker,IMAGE
From: https://www.cnblogs.com/guanchaoguo/p/17577954.html