.codechina-ci.yml 923 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
image: docker:stable

variables:
  MAVEN_OPTS: "-Dmaven.repo.local=/root/.m2/repository"
  IMAGE_NAME: "chatbox-vue-8888"

stages:
  - build
  - deploy

cache:
  key: ${CI_PROJECT_ID}-${CI_COMMIT_REF_SLUG}
  paths:
    - ./target

docker-build:
  image: maven:3.6.3-openjdk-8
  stage: build
  script:
    - mvn clean package
  tags:
    - deepexi-belle-dev
  only:
    - main

docker-deploy:
  stage: deploy
  cache:
    key: ${CI_PROJECT_ID}-${CI_COMMIT_REF_SLUG}
    paths:
      - ./target
    policy: pull
  script:
    - docker build -t ${IMAGE_NAME} .
    - if [ $(docker ps -aq --filter name=^${IMAGE_NAME}$) ]; then docker rm -f ${IMAGE_NAME};fi
    - docker run -d --name ${IMAGE_NAME} -p 8888:8888 --restart=always ${IMAGE_NAME}
    - if [ $(docker images | grep "none" | awk '{print $3}') ]; then docker rmi $(docker images | grep "none" | awk '{print $3}');fi
  tags:
    - deepexi-belle-dev
  only:
    - main