forked from jitesoft/webpage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
33 lines (31 loc) · 1010 Bytes
/
.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
stages:
- build
- deploy
Build:
stage: build
image: docker:latest
before_script:
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} registry.gitlab.com
script:
- docker build -t ${CI_REGISTRY_IMAGE}:latest --no-cache .
- docker push ${CI_REGISTRY_IMAGE}:latest
after_script:
- docker logout registry.gitlab.com
only:
- master
Deploy:
variables:
HOME_DIR: /home/johannes/docker/services/jitesoft.web
stage: deploy
image: alpine
before_script:
- apk add --no-cache openssh-client
- eval $(ssh-agent -s)
- echo "${DEPLOY_KEY}" | ssh-add -
- mkdir -p ~/.ssh
- echo "${JITESOFT_SERVER_KEY}" > ~/.ssh/known_hosts
script:
- scp ./docker-compose.yml ${DEPLOY_USER}@jitesoft.com:${HOME_DIR}
- ssh ${DEPLOY_USER}@jitesoft.com 'docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} registry.gitlab.com && cd ${HOME_DIR} && docker pull ${CI_REGISTRY_IMAGE}:latest && docker stack deploy -c docker-compose.yml jitesoft'
only:
- master