-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
53 lines (46 loc) · 1.53 KB
/
.gitlab-ci.yml
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
42
43
44
45
46
47
48
49
50
51
52
53
stages:
- build
- release
- deploy
services:
- docker:dind
variables:
DOCKER_TLS_CERTDIR: ""
DOCKER_DRIVER: overlay2
DOCKER_IMAGE_TAG: "$VERSION.$CI_PIPELINE_IID$envVersTag"
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
building:
stage: build
environment: $CI_COMMIT_REF_NAME
image:
name: docker:18-git
only:
refs:
- development
script:
- echo " === $CI_PROJECT_NAME - Build Dockerfile === "
- echo $APP_ENV
- cp $APP_ENV .env ; ls -la; cat .env
- docker build -t "$CI_REGISTRY/$CI_PROJECT_PATH:$DOCKER_IMAGE_TAG" .
- docker images
- docker tag $CI_REGISTRY/$CI_PROJECT_PATH:$DOCKER_IMAGE_TAG $CI_REGISTRY/$CI_PROJECT_PATH:latest
- docker images
- echo " === $CI_PROJECT_NAME - Push images === "
- docker push $CI_REGISTRY/$CI_PROJECT_PATH:$DOCKER_IMAGE_TAG
- docker push $CI_REGISTRY/$CI_PROJECT_PATH:latest
deploying:
stage: deploy
environment: $CI_COMMIT_REF_NAME
image:
name: docker:18-git
only:
refs:
- development
before_script:
- echo " DOCKER_IMAGE_TAG - $DOCKER_IMAGE_TAG "
script:
- echo " === $CI_PROJECT_NAME - Prepare deploying === "
- wget https://github.com/rancher/cli/releases/download/v0.6.13/rancher-linux-amd64-v0.6.13.tar.gz && tar -zxvf rancher-linux-amd64-v0.6.13.tar.gz
- sed -i 's|IMAGE_TAG|"$CI_REGISTRY/$CI_PROJECT_PATH:$DOCKER_IMAGE_TAG"|g' $DOCKER_COMPOSE_FILE
- ./rancher-v0.6.13/rancher -f $DOCKER_COMPOSE_FILE up -s $RANCHER_STACK_NAME --upgrade -d