-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
44 lines (39 loc) · 1.29 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
variables:
SCHEMA_IMAGE: inowas/schema
SCHEMA_PATH: /srv/docker/schema.inowas.com
stages:
- publish
- deploy
image: docker:20.10.16
services:
- docker:20.10.16-dind
publish:
stage: publish
before_script:
- docker info
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_TOKEN $CI_REGISTRY
script:
- docker build --tag $SCHEMA_IMAGE:$CI_COMMIT_SHA --tag $SCHEMA_IMAGE:latest --file src/docker/Dockerfile .
- docker push $SCHEMA_IMAGE:$CI_COMMIT_SHA
- docker push $SCHEMA_IMAGE:latest
only:
- main
deploy:
image: ubuntu:22.04
stage: deploy
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh-add <(echo "$SSH_PRIVATE_KEY")
script:
- ssh -p22 $SSH_CREDENTIALS "cd $SCHEMA_PATH && docker compose down"
- scp -P22 ./infrastructure/schema/docker-compose.yml $SSH_CREDENTIALS:/$SCHEMA_PATH/docker-compose.yml
- ssh -p22 $SSH_CREDENTIALS "cd $SCHEMA_PATH && docker compose pull"
- ssh -p22 $SSH_CREDENTIALS "cd $SCHEMA_PATH && docker compose up -d --force-recreate"
environment:
name: development
url: https://schema.inowas.com
only:
- main