使用GitLab CI/CD简单部署纯页面 制作Docker镜像,推送拉取 .gitlab-ci.yml 详细

2022-01-24 19:49:37 浏览数 (2)

代码语言: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

变量名都是自定义的有效字段

0 人点赞