-
Notifications
You must be signed in to change notification settings - Fork 1
119 lines (102 loc) · 3.31 KB
/
production-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
name: Docker build
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
services:
redis:
image: redis
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 6379:6379
postgres:
# Use a Postgres image that has wal2json installed
image: debezium/postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup node and cache
uses: ./.github/actions/node-and-cache
- name: Install pg_dump
uses: ./.github/actions/install-pg-dump
- name: Setup database
run: |
cp .env.ci .env
yarn install
CONFIRM_DROP=1 yarn setup
env:
CI: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build server
uses: docker/build-push-action@v2
with:
file: ./docker/dockerfiles/Dockerfile.prod
load: true
push: false
build-args: ROOT_URL=https://ilmo.prodeko.org
tags: |
ilmo-server
${{ secrets.REGISTRY_LOGIN_SERVER }}/ilmo/ilmo-server
secrets: |
GITHUB_SHA=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: server
- name: Build worker
uses: docker/build-push-action@v2
with:
file: ./docker/dockerfiles/Dockerfile.prod
load: true
push: false
build-args: ROOT_URL=https://ilmo.prodeko.org
tags: |
ilmo-worker
${{ secrets.REGISTRY_LOGIN_SERVER }}/ilmo/ilmo-worker
cache-from: type=gha
cache-to: type=gha,mode=max
target: worker
- name: Start server
run: |
docker run --rm -d --init -p 5678:5678 \
--env-file .env \
-e CI=true \
-e NODE_ENV=production \
-e DATABASE_HOST=172.17.0.1 \
-e REDIS_URL=redis://172.17.0.1:6379 \
--name ilmo-server ilmo-server
- name: Start worker
run: |
docker run --rm -d --init \
--env-file .env \
-e CI=true \
-e NODE_ENV=production \
-e DATABASE_HOST=172.17.0.1 \
-e REDIS_URL=redis://172.17.0.1:6379 \
--name ilmo-worker ilmo-worker
- name: Test docker
run: node .github/workflows/test-docker.js
- name: Tear down docker
run: docker kill ilmo-server ilmo-worker
- name: Docker login to ACR
uses: azure/docker-login@v1
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Push images to ACR
run: |
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/ilmo/ilmo-server
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/ilmo/ilmo-worker
- name: Deploy project
uses: ./.github/workflows/deploy