This repository has been archived by the owner on Nov 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
68 lines (64 loc) · 3.09 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
stages:
- build-docker-image-recette
- deploy-application-recette
- build-docker-image-production
- deploy-application-production
build_docker_image-recette:
stage: build-docker-image-recette
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
# build openfisca docker image and push it in containers registry
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR/docker-image --dockerfile $CI_PROJECT_DIR/docker-image/Dockerfile --destination $CI_REGISTRY_IMAGE:release-candidate
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
changes:
- docker-image/**/*
deploy_application-recette:
stage: deploy-application-recette
before_script:
- apt-get update -qq
- apt-get install -y -qq openssh-client rsync iputils-ping
# add target server in known_hosts
- mkdir ~/.ssh
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
# add SSH_PRIVATE_KEY in agent store
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
script:
- rsync -avz --no-perms --no-owner --no-group -e 'ssh' $CI_PROJECT_DIR/dist/deploy.sh $CI_PROJECT_DIR/dist/openfisca-recette-stack.yml $HOST_SERVER_USER@$HOST_SERVER_IP:/home/docker/openfisca
# exec deploy.sh to deploy docker stack openfisca or update openfisca image service
- ssh $HOST_SERVER_USER@$HOST_SERVER_IP "cd /home/docker/openfisca && ./deploy.sh $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD recette"
when: manual
build_docker_image-production:
stage: build-docker-image-production
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
# build openfisca docker image and push it in containers registry
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR/docker-image --dockerfile $CI_PROJECT_DIR/docker-image/Dockerfile --destination $CI_REGISTRY_IMAGE:release
when: manual
deploy_application-production:
stage: deploy-application-production
before_script:
- apt-get update -qq
- apt-get install -y -qq openssh-client rsync iputils-ping
# add target server in known_hosts
- mkdir ~/.ssh
- echo "$SSH_KNOWN_HOSTS_PROD" >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
# add SSH_PRIVATE_KEY in agent store
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY_PROD")
- mkdir -p ~/.ssh
script:
- rsync -avz --no-perms --no-owner --no-group -e 'ssh' $CI_PROJECT_DIR/dist/deploy.sh $CI_PROJECT_DIR/dist/openfisca-production-stack.yml $HOST_SERVER_USER@$HOST_SERVER_IP_PROD:/home/docker/openfisca
# exec deploy.sh to deploy docker stack openfisca or update openfisca image service
- ssh $HOST_SERVER_USER@$HOST_SERVER_IP_PROD "cd /home/docker/openfisca && ./deploy.sh $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD production"
when: manual