This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
83 lines (78 loc) · 2.64 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
stages:
- build
- publish
- deploy-staging
- deploy
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
build_and_test:
stage: build
image: registry.gitlab.com/aelve/codesearch/ci-test-env
services:
- docker:dind
script:
- sbt compile
- sbt core/assembly
- sbt web-server/assembly
- sbt scalafmt exit
- git diff --exit-code
cache:
key: codesearch
paths:
- ~/.sbt
- ~/.iv2/cache
- ~/.m2
artifacts:
paths:
- .dockerignore
- docker
- scripts
- Makefile
- codesearch-core.jar
- codesearch-server.jar
build_and_publish_docker_images:
stage: publish
image: registry.gitlab.com/aelve/codesearch/ci-test-env
services:
- docker:dind
before_script:
- docker login quay.io -u "$DOCKER_USER" -p "$DOCKER_PASS"
script:
- make build-docker-core "branch=${CI_COMMIT_REF_NAME}"
- make build-docker-web-server "branch=${CI_COMMIT_REF_NAME}"
- make push-docker-core "branch=${CI_COMMIT_REF_NAME}"
- make push-docker-web-server "branch=${CI_COMMIT_REF_NAME}"
only:
- develop
- master
deploy_to_staging:
stage: deploy-staging
image: kroniak/ssh-client
script:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- echo "$SSH_PRIVATE_KEY_STAGING" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh deployer@$STAGING_HOST "mkdir -p ~/docker && echo $DEPLOYER_PASS | sudo -S mkdir -p /mnt/vol/{portainer/data,postgresql,data,index,logs}"
- scp ./docker/docker-stack-compose.yml deployer@$STAGING_HOST:~/docker
- ssh deployer@$STAGING_HOST "docker login quay.io -u $DOCKER_USER -p $DOCKER_PASS"
- ssh deployer@$STAGING_HOST "SECRET_KEY=$STAGING_SECRET_KEY SERVER_PORT=$SERVER_PORT docker stack deploy --with-registry-auth -c ~/docker/docker-stack-compose.yml codesearch"
only:
- develop
deploy_to_production:
stage: deploy
image: kroniak/ssh-client
script:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh deployer@$HOST "mkdir -p ~/docker && echo $DEPLOYER_PASS | sudo -S mkdir -p /mnt/vol/{portainer/data,postgresql,data,index,logs}"
- scp ./docker/docker-stack-compose.yml deployer@$HOST:~/docker
- ssh deployer@$HOST "docker login quay.io -u $DOCKER_USER -p $DOCKER_PASS"
- ssh deployer@$HOST "SECRET_KEY=$SECRET_KEY SERVER_PORT=$SERVER_PORT docker stack deploy --with-registry-auth -c ~/docker/docker-stack-compose.yml codesearch"
only:
- master