代码语言:javascript复制
buildimg:
image: $DOCKER_IMG
stage: build
tags:
- myubuntu1
script:
- docker build -t $APP_IMAGE_NAME .
- docker login -u $HARBOR_USERNAME -p $HARBOR_PWD $HARBOR_URL
- docker push $APP_IMAGE_NAME
- docker image rm $APP_IMAGE_NAME
deploy:
image: $DOCKER_IMG
stage: deploy
tags:
- myubuntu1
script:
- - if [ $(docker ps -aq --filter name=$APP_CONTAINER_NAME) ]; then docker rm -f $APP_CONTAINER_NAME;fi
- docker login -u $HARBOR_USERNAME -p $HARBOR_PWD $HARBOR_URL
- docker run -d -p 8081:80 --name $APP_CONTAINER_NAME $APP_IMAGE_NAME
变量名都是自定义的有效字段