-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
48 lines (42 loc) · 1.25 KB
/
.gitlab-ci.yml
File metadata and controls
48 lines (42 loc) · 1.25 KB
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
image:
name: docker/compose:1.24.1
entrypoint: [""]
services:
- docker:dind
stages:
- build
- deploy
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
before_script:
- export IMAGE=$CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME
- apk add --no-cache openssh-client bash
- docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
- chmod +x ./setup_env.sh
- bash ./setup_env.sh
build:
stage: build
script:
- export API_IMAGE=$IMAGE:api
- export CLIENT_IMAGE=$IMAGE:client
- docker pull $IMAGE:api || true
- docker pull $IMAGE:client || true
- docker-compose -f docker-compose.ci.yml build --no-cache
- docker push $IMAGE:api
- docker push $IMAGE:client
deploy:
stage: deploy
script:
- export API_IMAGE=$IMAGE:api
- export CLIENT_IMAGE=$IMAGE:client
- mkdir -p ~/.ssh
- echo "$PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- cat ~/.ssh/id_rsa
- chmod 700 ~/.ssh/id_rsa
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa
- ssh-keyscan -H 'gitlab.com' >> ~/.ssh/known_hosts
- chmod +x ./deploy.sh
- scp -o StrictHostKeyChecking=no -r ./.env ./nginx/prod.conf ./nginx/nginx.conf ./docker-compose.prod.yml root@$DO_IP_ADDRESS:/app
- bash ./deploy.sh