-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.gitlab-ci.yml
executable file
·38 lines (35 loc) · 1.21 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
before_script:
##
## Install ssh-agent if not already installed, it is required by Docker.
## (change apt-get to yum if you use an RPM-based image)
##
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
##
## Run ssh-agent (inside the build environment)
##
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- echo "$SSH_DEPLOYER_PRIVATE_KEY" > ~/.ssh/id_rsa
- chmod 700 ~/.ssh/id_rsa
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
image:
gitlab/dind
build:
stage: build
only:
- develop
variables:
GIT_SUBMODULE_STRATEGY: recursive
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker push "$CI_REGISTRY_IMAGE"
services:
- docker:dind
deploy:
stage: deploy
only:
- develop
script:
- ssh -o StrictHostKeyChecking=no [email protected] docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- ssh -o StrictHostKeyChecking=no [email protected] "cd /opt/servers/ && docker-compose -f docker-compose-w12-product.yml pull && docker-compose -f docker-compose-w12-product.yml up -d"