-
Notifications
You must be signed in to change notification settings - Fork 7
184 lines (160 loc) · 5.13 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Docker
on:
push:
branches:
- main
- develop
- current
pull_request:
branches:
- develop
release:
types: [published]
jobs:
tests:
name: Build containers and process tests
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: True
- name: copy cur environment
run: cp .env.dev.example .env
- name: Copy config samples
run: |
./scripts/init_applications_config.sh .env
- name: Build all images
run: |
./build/build_geonature_all.sh .env
- name: Lauch docker compose
run: |
docker compose up -d
- name: Save Logs in temp file
run: |
docker compose logs -f > /tmp/docker_compose.log &
- name: test containers running
uses: nick-fields/retry@v2
with:
timeout_seconds: 120
max_attempts: 10
retry_wait_seconds: 30
command: |
docker compose ps
nb_services_running=$(docker compose ps --services --filter 'status=running' | wc -l)
nb_services_healthy=$(docker compose ps | grep '(healthy)'| wc -l)
echo nb_services_running $nb_services_running
echo nb_services_healthy $nb_services_healthy
[ "$nb_services_running" = "10" ] || exit 1
[ "$nb_services_healthy" = "6" ] || exit 1
- name: test app response
run: |
./scripts/test_docker_url.sh .env
- name: test reload
run: |
./scripts/test_docker_reload.sh .env
- name: Log if fail
if: ${{ failure() }}
run: |
docker compose logs
cat /tmp/docker_compose.log
docker compose ps
publish:
name: Build and publish dockerimages
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
needs: tests
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: True
- name: Git Sumbodule Update
run: |
cur=$(pwd)
for app in "GeoNature" "GeoNature-atlas" "UsersHub" "TaxHub"; do
cd ./sources/${app}
git submodule init
git submodule update
cd $cur
done
- name: Set Environnement variables
run: |
scripts/init_env.sh >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and export geonature backend wheels image
id: build-wheels
uses: docker/build-push-action@v4
with:
context: ./sources/GeoNature
file: ./sources/GeoNature/backend/Dockerfile
target: wheels
push: true
tags: "${{ env.GN_BACKEND_TAGS }}-wheels"
labels: ${{ env.GN_LABELS }}
- name: Build and export geonature backend image (+ 4 modules)
id: build-prod
uses: docker/build-push-action@v4
with:
context: .
file: ./build/Dockerfile-geonature-backend
target: prod-extra
push: true
tags: "${{ env.GN_BACKEND_TAGS }}"
labels: ${{ env.GN_LABELS }}
build-args: GEONATURE_BACKEND_IMAGE=${{env.GN_BACKEND_IMAGE}}
- name: Build and export frontend source
uses: docker/build-push-action@v4
with:
context: ./sources/GeoNature
file: ./sources/GeoNature/frontend/Dockerfile
target: source
tags: "${{env.GN_FRONTEND_TAGS}}-source"
push: true
- name: Build and export frontend nginx
uses: docker/build-push-action@v4
with:
context: ./sources/GeoNature
file: ./sources/GeoNature/frontend/Dockerfile
target: prod-base
tags: "${{env.GN_FRONTEND_TAGS}}-nginx"
push: true
- name: Build and export frontend + 4 modules
uses: docker/build-push-action@v4
with:
context: .
file: ./build/Dockerfile-geonature-frontend
tags: "${{env.GN_FRONTEND_TAGS}}"
build-args: GEONATURE_FRONTEND_IMAGE=${{env.GN_FRONTEND_IMAGE}}
push: true
- name: Build and export Usershub
uses: docker/build-push-action@v4
with:
context: ./sources/UsersHub
file: ./sources/UsersHub/Dockerfile
tags: "${{env.UH_TAGS}}"
push: true
- name: Build and export TaxHub
uses: docker/build-push-action@v4
with:
context: ./sources/TaxHub
file: ./sources/TaxHub/Dockerfile
tags: "${{env.TH_TAGS}}"
push: true
- name: Build and export GeoNature-atlas
uses: docker/build-push-action@v4
with:
context: ./sources/GeoNature-atlas
file: ./sources/GeoNature-atlas/Dockerfile
tags: "${{env.ATLAS_TAGS}}"
push: true