Skip to content

Commit 2e672b7

Browse files
committed
Merge branch 'docker-publish-all'
2 parents 35d3ae6 + 8532a6e commit 2e672b7

5 files changed

Lines changed: 110 additions & 41 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Publish all multi-arch Docker image versions
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
fetch_versions:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
matrix: ${{ steps.versions.outputs.matrix }}
11+
steps:
12+
- name: Check out the repository to the runner
13+
uses: actions/checkout@v6
14+
- id: versions
15+
run: echo matrix=$(python update.py ) >> "$GITHUB_OUTPUT"
16+
17+
call_build:
18+
needs:
19+
- fetch_versions
20+
strategy:
21+
max-parallel: 1
22+
matrix: ${{ fromJson(needs.fetch_versions.outputs.matrix) }}
23+
uses: ./.github/workflows/docker-publish.yml
24+
with:
25+
overpass_version: ${{ matrix.version}}
26+
secrets:
27+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish multi-arch Docker image
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
overpass_version:
9+
description: 'Version number to build (e.g. 0.7.62)'
10+
required: true
11+
type: string
12+
workflow_call:
13+
inputs:
14+
overpass_version:
15+
description: 'Version number to build (e.g. 0.7.62)'
16+
required: true
17+
type: string
18+
secrets:
19+
DOCKERHUB_TOKEN:
20+
required: true
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
build:
27+
uses: docker/github-builder/.github/workflows/build.yml@7d2a02426d4b989616ba5aaee4e879afd4134b0d # v1.6.0
28+
permissions:
29+
contents: read
30+
id-token: write
31+
with:
32+
output: image
33+
push: true
34+
platforms: linux/amd64,linux/arm64
35+
build-args: OVERPASS_VERSION=${{ github.event.release.tag_name || inputs.overpass_version }}
36+
cache: true
37+
cache-mode: max
38+
meta-images: ${{ vars.DOCKERHUB_USERNAME }}/overpass-api
39+
meta-tags: type=semver,pattern={{version}}
40+
secrets:
41+
registry-auths: |
42+
- registry: docker.io
43+
username: ${{ vars.DOCKERHUB_USERNAME }}
44+
password: ${{ secrets.DOCKERHUB_TOKEN }}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ RUN apt-get update \
2626
zlib1g \
2727
zlib1g-dev
2828

29-
ADD http://dev.overpass-api.de/releases/osm-3s_v{version}.tar.gz /app/src.tar.gz
29+
ARG OVERPASS_VERSION
30+
ADD http://dev.overpass-api.de/releases/osm-3s_v${OVERPASS_VERSION}.tar.gz /app/src.tar.gz
3031

3132
RUN mkdir -p /app/src \
3233
&& cd /app/src \
@@ -91,9 +92,9 @@ COPY docker-entrypoint.sh docker-healthcheck.sh /app/
9192
RUN chmod a+rx /app/docker-entrypoint.sh /app/bin/update_overpass.sh /app/bin/rules_loop.sh /app/bin/dispatcher_start.sh \
9293
/app/bin/oauth_cookie_client.py /app/bin/start_fcgiwarp.sh
9394

94-
ENV OVERPASS_RULES_LOAD=${{OVERPASS_RULES_LOAD:-1}}
95-
ENV OVERPASS_USE_AREAS=${{OVERPASS_USE_AREAS:-true}}
96-
ENV OVERPASS_ALLOW_DUPLICATE_QUERIES=${{OVERPASS_ALLOW_DUPLICATE_QUERIES:-no}}
95+
ENV OVERPASS_RULES_LOAD=${OVERPASS_RULES_LOAD:-1}
96+
ENV OVERPASS_USE_AREAS=${OVERPASS_USE_AREAS:-true}
97+
ENV OVERPASS_ALLOW_DUPLICATE_QUERIES=${OVERPASS_ALLOW_DUPLICATE_QUERIES:-no}
9798

9899
EXPOSE 80
99100

build.sh

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,31 @@
22

33
set -e
44

5+
IMAGE=wiktorn/overpass-api
6+
VERSIONS=$(python update.py)
7+
58
case "$1" in
69
"build")
7-
python update.py
8-
9-
# docker build
10-
find . -maxdepth 1 -type d -name '0.*' -exec sh -c 'docker build -t wiktorn/overpass-api:$(basename "$1") -f "$1"/Dockerfile .' sh {} \;
10+
for version in $VERSIONS; do
11+
docker build --build-arg "OVERPASS_VERSION=${version}" -t "${IMAGE}:${version}" .
12+
done
1113

12-
# docker tag
13-
while IFS= read -r -d '' file; do
14-
docker tag "wiktorn/overpass-api:$(basename "$file")" wiktorn/overpass-api:latest
15-
done < <(find . -maxdepth 1 -type d -regex '\./[0-9]\.[0-9]\.[0-9]*' -print0 | sort -nz | tail -z -n 1)
14+
latest=$(echo "$VERSIONS" | sort -V | tail -n 1)
15+
docker tag "${IMAGE}:${latest}" "${IMAGE}:latest"
1616
;;
17+
1718
"push")
18-
# docker push
19-
find . -maxdepth 1 -type d -name '0.*' -exec sh -c 'docker push "wiktorn/overpass-api:$(basename "$1")"' sh {} \;
20-
docker push wiktorn/overpass-api:latest
19+
for version in $VERSIONS; do
20+
docker push "${IMAGE}:${version}"
21+
done
22+
docker push "${IMAGE}:latest"
2123
;;
24+
2225
"$1")
2326
echo "Invalid argument $1"
2427
echo "Valid arguments:"
25-
echo "$0 build - to build docker images"
26-
echo "$0 push - to push built images to docker hub"
28+
echo "$0 build - to build Docker images"
29+
echo "$0 push - to push built images to Docker Hub"
2730
exit 1
2831
;;
2932
esac

update.py

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import html.parser
2-
import os
3-
import pathlib
4-
import shutil
52
import urllib.request
3+
import json
64

75
url = "http://dev.overpass-api.de/releases/"
6+
skip_prefixes = (
7+
'0.6', 'eta', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.50', '0.7.52',
8+
'0.7.54.11', # invalid CRC in archive
9+
'0.7.51', # no autoconf
10+
)
811

912

1013
class VersionFinder(html.parser.HTMLParser):
@@ -23,31 +26,22 @@ def handle_starttag(self, tag, attrs):
2326
self.versions.append(version)
2427

2528

26-
def main():
29+
def versions_to_build():
2730
parser = VersionFinder()
2831
response = urllib.request.urlopen(url)
2932
data = response.read().decode(response.headers.get_content_charset())
3033
parser.feed(data)
31-
with open("Dockerfile.template") as f:
32-
template = f.read()
33-
for ver in parser.versions:
34-
if any((ver.startswith(x) for x in ('0.6', 'eta', '0.7.1', '0.7.2', '0.7.3', '0.7.4', '0.7.50', '0.7.52',
35-
'0.7.54.11', # invalid CRC in archive
36-
'0.7.51', # no autoconf
37-
))) or \
38-
ver == '0.7':
39-
# ignore old releases
40-
continue
41-
if os.path.exists(ver):
42-
shutil.rmtree(ver)
43-
os.mkdir(ver)
44-
with open(pathlib.Path(ver) / "Dockerfile", "w+") as f:
45-
f.write(template.format(version=ver))
46-
#for i in ("etc", "bin"):
47-
# shutil.copytree(i, pathlib.Path(ver) / i)
48-
#shutil.copyfile("docker-entrypoint.sh", pathlib.Path(ver) / "docker-entrypoint.sh")
49-
#shutil.copyfile("requirements.txt", pathlib.Path(ver) / "requirements.txt")
34+
35+
return [
36+
version for version in parser.versions
37+
if version != '0.7'
38+
and not any(version.startswith(skip_prefix) for skip_prefix in skip_prefixes)
39+
]
5040

5141

5242
if __name__ == '__main__':
53-
main()
43+
versions = versions_to_build()
44+
github_matrix = {
45+
"include": [{"version": v} for v in versions]
46+
}
47+
print(json.dumps(github_matrix, indent=None))

0 commit comments

Comments
 (0)