-
Notifications
You must be signed in to change notification settings - Fork 446
302 lines (253 loc) · 11.8 KB
/
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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
name: CI
on:
push:
pull_request:
workflow_dispatch:
jobs:
build:
name: Build docker image
strategy:
matrix:
nominatim:
- version: "4.3"
- version: "4.4"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.nominatim.version }}
tags: nominatim:latest
outputs: type=docker,dest=/tmp/nominatim.tar
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: nominatim-${{ matrix.nominatim.version }}
path: /tmp/nominatim.tar
test:
name: Test docker image
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
nominatim:
- version: "4.3"
- version: "4.4"
test_scenario:
- name: Import with PBF_URL and update
commands: |-
# get the data from four days ago to make sure there really are updates to apply
four_days_ago=`date --date="4 days ago" +%y%m%d`
docker run -i --rm \
-e PBF_URL=http://download.geofabrik.de/europe/monaco-${four_days_ago}.osm.pbf \
-e REPLICATION_URL=http://download.geofabrik.de/europe/monaco-updates/ \
-p 8001:8080 \
--name nominatim \
nominatim &
./assert-non-empty-json "http://localhost:8001/search.php?q=avenue%20pasteur"
docker exec -i nominatim sudo -u nominatim nominatim replication --project-dir /nominatim --once
./assert-non-empty-json "http://localhost:8001/search.php?q=avenue%20pasteur"
- name: Import with volume mount
commands: |-
docker run -i --rm \
-e PBF_URL=http://download.geofabrik.de/europe/monaco-latest.osm.pbf \
-e REPLICATION_URL=http://download.geofabrik.de/europe/monaco-updates/ \
-v nominatim-data:/var/lib/postgresql/14/main \
-p 8002:8080 \
nominatim &
./assert-non-empty-json "http://localhost:8002/search.php?q=avenue%20pasteur"
- name: Import with bind-mount, container restart & update
commands: |-
# get the data from four days ago to make sure there really are updates to apply
four_days_ago=`date --date="4 days ago" +%y%m%d`
docker run -i --rm \
-e PBF_URL=http://download.geofabrik.de/europe/monaco-${four_days_ago}.osm.pbf \
-e REPLICATION_URL=http://download.geofabrik.de/europe/monaco-updates/ \
-v /tmp/nominatim-data:/var/lib/postgresql/14/main \
-p 8003:8080 \
--name nominatim \
nominatim &
./assert-non-empty-json "http://localhost:8003/search.php?q=avenue%20pasteur"
# Stop container
docker stop nominatim
# import to bind mount is done previously
docker run -i --rm \
-e PBF_URL=http://download.geofabrik.de/europe/monaco-${four_days_ago}.osm.pbf \
-e REPLICATION_URL=http://download.geofabrik.de/europe/monaco-updates/ \
-v /tmp/nominatim-data:/var/lib/postgresql/14/main \
-p 8004:8080 \
--name nominatim \
nominatim &
./assert-non-empty-json "http://localhost:8004/search.php?q=avenue%20pasteur"
docker exec -i nominatim sudo -u nominatim nominatim replication --project-dir /nominatim --once
./assert-non-empty-json "http://localhost:8004/search.php?q=avenue%20pasteur"
- name: UPDATE_MODE=once with volume
commands: |-
# get the data from four days ago to make sure there really are updates to apply
four_days_ago=`date --date="4 days ago" +%y%m%d`
docker run -i --rm \
-e PBF_URL=http://download.geofabrik.de/europe/monaco-${four_days_ago}.osm.pbf \
-e REPLICATION_URL=http://download.geofabrik.de/europe/monaco-updates/ \
-e UPDATE_MODE=once \
-v nominatim-update-volume:/var/lib/postgresql/14/main \
-p 8004:8080 \
--name nominatim \
nominatim &
./assert-non-empty-json "http://localhost:8004/search.php?q=avenue%20pasteur"
echo -n "check replication log for Update completed. Count:"
docker exec nominatim /bin/bash -c 'tail -f /var/log/replication.log | grep -m 1 -c "Update completed."'
- name: UPDATE_MODE=continuous with bind-mount
commands: |-
# get the data from few days ago to make sure there really are updates to apply
days_ago=`date --date="4 days ago" +%y%m%d`
docker run -i --rm \
-e PBF_URL=http://download.geofabrik.de/europe/monaco-${days_ago}.osm.pbf \
-e REPLICATION_URL=http://download.geofabrik.de/europe/monaco-updates/ \
-e UPDATE_MODE=continuous \
-v /tmp/nominatim-update-bindmount:/var/lib/postgresql/14/main \
-p 8004:8080 \
--name nominatim \
nominatim &
./assert-non-empty-json "http://localhost:8004/search.php?q=avenue%20pasteur"
echo -n "check replication log for Update completed. Count:"
docker exec nominatim /bin/bash -c 'tail -f /var/log/replication.log | grep -m 1 -c "Update completed."'
- name: Import full style
commands: |-
docker run -i --rm \
-e PBF_URL=http://download.geofabrik.de/europe/monaco-latest.osm.pbf \
-e REPLICATION_URL=http://download.geofabrik.de/europe/monaco-updates/ \
-e IMPORT_STYLE=full \
-p 8005:8080 \
nominatim &
./assert-non-empty-json "http://localhost:8005/search.php?q=hotel%20de%20paris"
- name: Import admin style
commands: |-
docker run -i --rm \
-e PBF_URL=http://download.geofabrik.de/europe/monaco-latest.osm.pbf \
-e REPLICATION_URL=http://download.geofabrik.de/europe/monaco-updates/ \
-e IMPORT_STYLE=admin \
-p 8006:8080 \
nominatim &
./assert-empty-json "http://localhost:8006/search.php?q=hotel%20de%20paris"
- name: Import with PBF_PATH
commands: |-
wget --cut-dirs=1 -nH -xP /tmp/data http://download.geofabrik.de/europe/monaco-latest.osm.pbf
docker run -i --rm \
-e PBF_PATH=/nominatim/data/monaco-latest.osm.pbf \
-e REPLICATION_URL=http://download.geofabrik.de/europe/monaco-updates/ \
-v nominatim7-data:/var/lib/postgresql/14/main \
-v /tmp/data:/nominatim/data \
-p 8007:8080 \
--name nominatim \
nominatim &
./assert-non-empty-json "http://localhost:8007/search.php?q=avenue%20pasteur"
- name: REPLICATION_URL is blank
commands: |-
docker run -i --rm \
-e PBF_URL=http://download.geofabrik.de/europe/monaco-latest.osm.pbf \
-p 8008:8080 \
nominatim &
./assert-non-empty-json "http://localhost:8008/search.php?q=avenue%20pasteur"
- name: FREEZE
commands: |-
docker run -i --rm \
-e PBF_URL=http://download.geofabrik.de/europe/monaco-latest.osm.pbf \
-e FREEZE="true" \
-p 8009:8080 \
nominatim &
./assert-non-empty-json "http://localhost:8009/search.php?q=avenue%20pasteur"
- name: GB postcode import
commands: |-
docker run -i --rm \
-e PBF_URL=https://download.geofabrik.de/europe/great-britain/england/rutland-latest.osm.pbf \
-e IMPORT_GB_POSTCODES="true" \
-p 8010:8080 \
nominatim &
./assert-non-empty-json "http://localhost:8010/search.php?postalcode=LE15+8TX"
./assert-non-empty-json "http://localhost:8010/search.php?postalcode=PE9+3SY"
./assert-non-empty-json "http://localhost:8010/search.php?postalcode=PE9+4ES"
- name: REVERSE_ONLY
commands: |-
docker run -i --rm \
-e PBF_URL=http://download.geofabrik.de/europe/monaco-latest.osm.pbf \
-e REVERSE_ONLY="true" \
-p 8011:8080 \
nominatim &
./assert-reverse-only "http://localhost:8011/search.php?q=avenue%20pasteur"
./assert-non-empty-json "http://localhost:8011/reverse.php?lat=43.734&lon=7.42&format=jsonv2"
- name: Check for clean shutdown
commands: |-
docker run --detach --rm \
-e PBF_URL=http://download.geofabrik.de/europe/monaco-latest.osm.pbf \
-p 8009:8080 \
--name nominatim \
nominatim
./assert-non-empty-json "http://localhost:8009/search.php?q=avenue%20pasteur"
# Shutdown the container
docker stop -t 60 nominatim
# Verify that the exit code is zero
CONTAINER_EXIT_CODE=$(docker inspect nominatim --format='{{.State.ExitCode}}')
test "$CONTAINER_EXIT_CODE" -eq 0
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: nominatim-${{ matrix.nominatim.version }}
path: /tmp
- name: Load image
run: |
docker load --input /tmp/nominatim.tar
docker image ls -a
- name: Checkout
uses: actions/checkout@v4
# Excute the test scenario
- name: ${{ matrix.test_scenario.name }}
working-directory: .github/workflows
run: ${{ matrix.test_scenario.commands }}
publish:
name: Publish docker image
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
nominatim:
- version: "4.3"
- version: "4.4"
steps:
- name: Checkout
uses: actions/checkout@v4
# Compute the Docker tags and labels to apply to the built image
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# List of Docker images to use as base name for tags
images: |
mediagis/nominatim
# Disable generation of latest tag
flavor: |
latest=false
# Add simple tag with nominatim version + tag with custom date format
tags: |
type=raw,value=${{ matrix.nominatim.version }}
type=raw,value=${{ matrix.nominatim.version }}-{{date 'YYYY-MM-DDTHH-mm'}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: ${{ github.ref == 'refs/heads/master' && github.repository_owner == 'mediagis' }}
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.nominatim.version }}
platforms: linux/amd64,linux/arm64
push: ${{ github.ref == 'refs/heads/master' && github.repository_owner == 'mediagis' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}