.gitlab-ci.yml 2.79 KB
Newer Older
1 2 3 4
image: docker:1.10

stages:
- build
5
- register
6
- deploy
7 8 9
# - test

variables:
10
  PROJECT_NAME: $CI_PROJECT_NAME
11
  CONTAINER_IMAGE: iilab/$CI_PROJECT_NAME
12 13 14 15
  DEV_STACK_NAME: microservices-master
  STAGING_STACK_NAME: staging
  # CONTAINER_IMAGE: docker.iilab.org:5000/openintegrity/$PROJECT_NAME
  # CONTAINER_TEST_TAG: $PROJECT_VERSION-test-$CI_BUILD_REF_NAME
16 17

before_script:
18 19
  # - docker login --username cirunner --password $CI_PORTUS_PASSWORD --email admin@iilab.org docker.iilab.org:5000
  - docker login --username iilab --password $HUB_PASSWORD --email tech@iilab.org
20

21
build-register-dev:
22 23
  stage: build
  script:
24 25
    - docker build -t $CONTAINER_IMAGE:dev .
    - docker push $CONTAINER_IMAGE:dev
26 27
  tags:
    - docker-build
28 29
  # only:
  #   - master
30 31
  except:
    - tags
32

33 34 35 36 37 38 39 40 41
build-register-release:
  stage: build
  script:
    - docker build -t $CONTAINER_IMAGE:$CI_BUILD_TAG .
    - docker push $CONTAINER_IMAGE:$CI_BUILD_TAG
  tags:
    - docker-build
  only:
    - tags
42

43 44 45 46 47 48 49
deploy-master-dev:
  before_script:
    - /bin/true
  variables:
    CONTAINER_TAG: dev
    DEPLOY_STAGE: dev
    STACK_NAME: $DEV_STACK_NAME
Jun Matsushita committed
50 51
    RANCHER_ACCESS_JOB: $RANCHER_ACCESS_DEV
    RANCHER_SECRET_JOB: $RANCHER_SECRET_DEV
52 53
    RANCHER_COMPOSE_VERSION: 0.10.0
  stage: deploy
54
  script:
55
    - docker rm -f rancher-compose-$PROJECT_NAME || true
Jun Matsushita committed
56
    - docker create -e CONTAINER_TAG=$CONTAINER_TAG -e DEPLOY_STAGE=$DEPLOY_STAGE --name rancher-compose-$PROJECT_NAME iilab/rancher-compose:$RANCHER_COMPOSE_VERSION rancher-compose --project-name "$STACK_NAME" --url https://rancher.iilab.org --access-key "$RANCHER_ACCESS_JOB" --secret-key "$RANCHER_SECRET_JOB" up -d --upgrade --force-upgrade --confirm-upgrade || true
57 58
    - docker cp $CI_PROJECT_DIR/docker-compose.yml rancher-compose-$PROJECT_NAME:/app/docker-compose.yml
    - docker start --attach rancher-compose-$PROJECT_NAME
59 60
  # only:
  #   - master
61 62
  except:
    - tags
63 64 65
  tags:
    - docker-build

66 67 68 69 70 71 72
deploy-release-staging:
  before_script:
    - /bin/true
  variables:
    CONTAINER_TAG: $CI_BUILD_TAG
    DEPLOY_STAGE: staging
    STACK_NAME: $STAGING_STACK_NAME
Jun Matsushita committed
73 74
    RANCHER_ACCESS_JOB: $RANCHER_ACCESS
    RANCHER_SECRET_JOB: $RANCHER_SECRET
75 76 77 78
    RANCHER_COMPOSE_VERSION: 0.10.0
  stage: deploy
  script:
    - docker rm -f rancher-compose-$PROJECT_NAME || true
Jun Matsushita committed
79
    - docker create -e CONTAINER_TAG=$CONTAINER_TAG -e DEPLOY_STAGE=$DEPLOY_STAGE --name rancher-compose-$PROJECT_NAME iilab/rancher-compose:$RANCHER_COMPOSE_VERSION rancher-compose --project-name "$STACK_NAME" --url https://rancher.iilab.org --access-key "$RANCHER_ACCESS_JOB" --secret-key "$RANCHER_SECRET_JOB" up -d --upgrade --force-upgrade || true
80 81 82 83 84 85
    - docker cp $CI_PROJECT_DIR/docker-compose.yml rancher-compose-$PROJECT_NAME:/app/docker-compose.yml
    - docker start --attach rancher-compose-$PROJECT_NAME
  only:
    - tags
  tags:
    - docker-build