-
Notifications
You must be signed in to change notification settings - Fork 13
125 lines (108 loc) · 3.46 KB
/
docker.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Build and push Docker images
on:
workflow_call:
secrets:
GHCR_USERNAME:
required: true
GHCR_TOKEN:
required: true
inputs:
push:
required: false
type: boolean
default: true
apps:
required: false
type: string
default: "[\"api\",\"simulators-api\",\"dispatch-service\",\"mail-service\",\"combine-api\",\"simdata-api\"]"
env:
NX_SKIP_NX_CACHE: ${{ vars.NX_SKIP_NX_CACHE_VALUE }}
jobs:
build:
services:
nats:
image: nats
ports:
- 4222:4222
redis:
image: redis
ports:
- 6379:6379
mongo:
image: mongo
ports:
- 27017:27017
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
app: ${{fromJSON(inputs.apps)}}
steps:
- name: Checkout [dev]
uses: actions/checkout@v3
if: ${{ github.event_name != 'pull_request' }}
with:
fetch-depth: 0
- name: Checkout [pr]
uses: actions/checkout@v3
if: ${{ github.event_name == 'pull_request' }}
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3.3.0
with:
node-version: '18'
- name: Install dependencies
run: sudo apt-get update && sudo apt-get -y install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
- name: Install Poetry
run: pipx install poetry==1.4.0
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
architecture: "x64"
- name: Install npm dependencies
uses: bahmutov/npm-install@v1
with:
useRollingCache: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: 'ghcr.io'
username: "${{ secrets.GHCR_USERNAME }}"
password: "${{ secrets.GHCR_TOKEN }}"
- name: Build Docker Image
env:
INPUT_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INPUT_PUSH: ${{ inputs.push }}
run: npx nx docker ${{matrix.app}}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{format('ghcr.io/biosimulations/{0}', matrix.app)}}
tags: type=sha
- name: Start Docker Image
env:
app: ${{matrix.app}}
image: ${{steps.meta.outputs.tags}}
NATS_HOST: 127.0.0.1:4222
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
MANAGEMENT_DOMAIN: crbmdev.auth0.com
MANAGEMENT_ID: TEST_MANAGEMENT_ID
MANAGEMENT_SECRET: TEST_MANAGEMENT_SECRET
HPC_SSH_INIT: false
run: docker run -d --name ${{matrix.app}} --network=host -e NATS_HOST -e REDIS_HOST -e REDIS_PORT -e MANAGEMENT_DOMAIN -e MANAGEMENT_ID -e MANAGEMENT_SECRET -e HPC_SSH_INIT ${{env.image}}
- name: Wait for Docker Image to start
run: sleep 10
- name: Confirm Docker Image is Running
run: if [ $(docker inspect -f '{{.State.Running}}' ${{matrix.app}}) = "true" ]; then exit 0; else docker logs ${{matrix.app}} && exit 1; fi
- name: Stop Docker Image
if: always()
run: docker stop ${{matrix.app}}