-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
49 lines (44 loc) · 1.66 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
variables:
CI_DEBUG_SERVICES: "true"
before_script:
- apk update
- apk --no-cache add py3-pip python3 curl
- pip3 install pyyaml --break-system-packages
- curl -O https://raw.githubusercontent.com/FredHutch/swarm-build-helper/main/build_helper.py
# below is from https://stackoverflow.com/a/65810302/470769
- mkdir -p $HOME/.docker
- echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
- set -x
stages:
- build
- test
- deploy
build:
stage: build
script:
- mkdir -p .secrets
- echo $GOOGLE_TOKEN | base64 -d > .secrets/$GOOGLE_TOKEN_NAME
- docker build -t sc-registry.fredhutch.org/gdscnsoil:test .
- docker push sc-registry.fredhutch.org/gdscnsoil:test
# nginx redirect is simple, not gonna test it
- docker build -t sc-registry.fredhutch.org/gdscnsoil-redirect:latest -f Dockerfile.nginx .
- docker push sc-registry.fredhutch.org/gdscnsoil-redirect:latest
test:
stage: test
services:
- name: sc-registry.fredhutch.org/gdscnsoil:test
alias: gdscnsoil
script:
- sleep 15 && curl -sI http://gdscnsoil:3838 |head -1|grep -q "200 OK"
deploy:
stage: deploy
only:
refs:
- main
script:
- docker tag sc-registry.fredhutch.org/gdscnsoil:test sc-registry.fredhutch.org/gdscnsoil:latest
- docker push sc-registry.fredhutch.org/gdscnsoil:latest
- sleep 15
- echo $SC_SWARM_CICD_SSH_KEY | base64 -d > ./sc_swarm_cicd_ssh_key
- chmod 0400 ./sc_swarm_cicd_ssh_key
- python3 build_helper.py docker-compose.yml | ssh -i ./sc_swarm_cicd_ssh_key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null [email protected] docker stack deploy --with-registry-auth -c - gdscnsoil