forked from FredHutch/shiny-cromwell
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
91 lines (76 loc) · 3.08 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
84
85
86
87
88
89
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
stages:
- build
- test
- deploy
build:
stage: build
script: |
python3 build_helper.py docker-compose.yml --fluentd-logging > /dev/null
echo $DB_CONFIG | base64 -d > .my.cnf
docker build \
-t sc-registry.fredhutch.org/shiny-cromwell:test \
--build-arg CI_COMMIT_BRANCH=${CI_COMMIT_BRANCH} \
--build-arg CI_COMMIT_SHA=${CI_COMMIT_SHA} \
--build-arg CI_COMMIT_SHORT_SHA=${CI_COMMIT_SHORT_SHA} \
--build-arg CI_COMMIT_TIMESTAMP=${CI_COMMIT_TIMESTAMP} \
.
rm .my.cnf
docker push sc-registry.fredhutch.org/shiny-cromwell:test
docker build -t sc-registry.fredhutch.org/shiny-cromwell-redirect:latest -f redirect/Dockerfile redirect/
sleep 5
test:
stage: test
services:
- name: sc-registry.fredhutch.org/shiny-cromwell:test
alias: shiny-cromwell
script: |
sleep 30
# docker ps
# CONTAINER_ID=$(docker ps | grep sc-registry.fredhutch.org__shiny-cromwell- | cut -d' ' -f1)
# env
# curl -si http://shiny-cromwell:3838/
# docker logs $CONTAINER_ID
curl -sI http://shiny-cromwell:3838 | head -1 | grep -q "200 OK"
docker run -w /srv/shiny-server --rm sc-registry.fredhutch.org/shiny-cromwell:test R -q -e 'testthat::test_dir("tests")'
deploy_preview:
stage: deploy
only:
refs:
- dev
script:
- docker tag sc-registry.fredhutch.org/shiny-cromwell:test sc-registry.fredhutch.org/shiny-cromwell-preview:latest
- docker push sc-registry.fredhutch.org/shiny-cromwell-preview: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 --fluentd-logging docker-compose-preview.yml | ssh -i ./sc_swarm_cicd_ssh_key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@sc-swarm-mgr.fhcrc.org docker stack deploy --prune --with-registry-auth -c - shiny-cromwell-preview
- rm -f ./sc_swarm_cicd_ssh_key
deploy:
stage: deploy
only:
refs:
- main
script:
- docker tag sc-registry.fredhutch.org/shiny-cromwell:test sc-registry.fredhutch.org/shiny-cromwell:latest
- docker push sc-registry.fredhutch.org/shiny-cromwell:latest
- docker push sc-registry.fredhutch.org/shiny-cromwell-redirect: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 --fluentd-logging docker-compose.yml | ssh -i ./sc_swarm_cicd_ssh_key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@sc-swarm-mgr.fhcrc.org docker stack deploy --prune --with-registry-auth -c - shiny-cromwell
- rm -f ./sc_swarm_cicd_ssh_key