variables:
  #docker仓库地址
  REGISTRY_HOST:  registry.dev.trydotec.com
  #准度科技信息化项目
  PROJECT_NAME: mediate
  #注册中心
  SUB_PROJECT_NAME: mediate-manage-web
  CEWCS_IMAGE: $REGISTRY_HOST/$PROJECT_NAME/$SUB_PROJECT_NAME:1.0.0-dev
  CEWCS_IMAGE_STG: $REGISTRY_HOST/$PROJECT_NAME/$SUB_PROJECT_NAME:1.0.0-stg
  CEWCS_IMAGE_PRD: $REGISTRY_HOST/$PROJECT_NAME/$SUB_PROJECT_NAME:1.0.0-prd
  
stages:
  - build
  - push
  - clean

before_script:
  - docker login --username=trydo --password=zd123456 $REGISTRY_HOST

构建:
  stage: build
  only:
    - main
  script:
    - export JAVA_HOME=/usr/local/java/jdk-11.0.2
    - mvn -B clean package -DskipTests
    - docker build -t $CEWCS_IMAGE -f dockerfile/Dockerfile .

推送:
  stage: push
  only:
    - main
  script:
    - docker push $CEWCS_IMAGE

部署:
  stage: clean
  only:
    - main
  script:
#    - echo '不用清理，用作缓存'
     - docker rmi -f $CEWCS_IMAGE


构建测试环境:
  stage: build
  only:
    - stg
  script:
    - export JAVA_HOME=/usr/local/java/jdk-11.0.2
    - mvn -B clean package -DskipTests
    - docker build -t $CEWCS_IMAGE_STG -f dockerfile/Dockerfile_stg .

推送测试环境:
  stage: push
  only:
    - stg
  script:
    - docker push $CEWCS_IMAGE_STG

部署测试环境:
  stage: clean
  only:
    - stg
  script:
    #    - echo '不用清理，用作缓存'
    - docker rmi -f $CEWCS_IMAGE_STG


构建发布环境:
  stage: build
  only:
    - prd
  script:
    - export JAVA_HOME=/usr/local/java/jdk-11.0.2
    - mvn -B clean package -DskipTests
    - docker build -t $CEWCS_IMAGE_PRD -f dockerfile/Dockerfile_prd .


推送发布环境:
  stage: push
  only:
    - prd
  script:
    - docker push $CEWCS_IMAGE_PRD


部署发布环境:
  stage: clean
  only:
    - prd
  script:
    #    - echo '不用清理，用作缓存'
    - docker rmi -f $CEWCS_IMAGE_PRD
