Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish multi-arch Docker image

on:
Comment thread
gy-mate marked this conversation as resolved.
release:
types: [published]
workflow_dispatch:
inputs:
overpass_version:
description: 'Version number to build (e.g. 0.7.62)'
required: true
type: string

permissions:
contents: read

jobs:
build:
uses: docker/github-builder/.github/workflows/build.yml@v1
permissions:
contents: read
id-token: write
with:
Comment thread
wiktorn marked this conversation as resolved.
output: image
push: true
platforms: linux/amd64,linux/arm64
build-args: OVERPASS_VERSION=${{ github.event.release.tag_name || inputs.overpass_version }}
cache: true
cache-mode: max
meta-images: ${{ vars.DOCKERHUB_USERNAME }}/overpass-api
meta-tags: type=semver,pattern={{version}}
secrets:
registry-auths: |
- registry: docker.io
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
9 changes: 5 additions & 4 deletions Dockerfile.template → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ RUN apt-get update \
zlib1g \
zlib1g-dev

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

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

ENV OVERPASS_RULES_LOAD=${{OVERPASS_RULES_LOAD:-1}}
ENV OVERPASS_USE_AREAS=${{OVERPASS_USE_AREAS:-true}}
ENV OVERPASS_ALLOW_DUPLICATE_QUERIES=${{OVERPASS_ALLOW_DUPLICATE_QUERIES:-no}}
ENV OVERPASS_RULES_LOAD=${OVERPASS_RULES_LOAD:-1}
ENV OVERPASS_USE_AREAS=${OVERPASS_USE_AREAS:-true}
ENV OVERPASS_ALLOW_DUPLICATE_QUERIES=${OVERPASS_ALLOW_DUPLICATE_QUERIES:-no}

EXPOSE 80

Expand Down
29 changes: 16 additions & 13 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,31 @@

set -e

IMAGE=wiktorn/overpass-api
VERSIONS=$(python update.py)

case "$1" in
"build")
python update.py

# docker build
find . -maxdepth 1 -type d -name '0.*' -exec sh -c 'docker build -t wiktorn/overpass-api:$(basename "$1") -f "$1"/Dockerfile .' sh {} \;
for version in $VERSIONS; do
docker build --build-arg "OVERPASS_VERSION=${version}" -t "${IMAGE}:${version}" .
done

# docker tag
while IFS= read -r -d '' file; do
docker tag "wiktorn/overpass-api:$(basename "$file")" wiktorn/overpass-api:latest
done < <(find . -maxdepth 1 -type d -regex '\./[0-9]\.[0-9]\.[0-9]*' -print0 | sort -nz | tail -z -n 1)
latest=$(echo "$VERSIONS" | sort -V | tail -n 1)
docker tag "${IMAGE}:${latest}" "${IMAGE}:latest"
;;

"push")
# docker push
find . -maxdepth 1 -type d -name '0.*' -exec sh -c 'docker push "wiktorn/overpass-api:$(basename "$1")"' sh {} \;
docker push wiktorn/overpass-api:latest
for version in $VERSIONS; do
docker push "${IMAGE}:${version}"
done
docker push "${IMAGE}:latest"
;;

"$1")
echo "Invalid argument $1"
echo "Valid arguments:"
echo "$0 build - to build docker images"
echo "$0 push - to push built images to docker hub"
echo "$0 build - to build Docker images"
echo "$0 push - to push built images to Docker Hub"
exit 1
;;
esac
38 changes: 14 additions & 24 deletions update.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import html.parser
import os
import pathlib
import shutil
import urllib.request

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


class VersionFinder(html.parser.HTMLParser):
Expand All @@ -23,31 +25,19 @@ def handle_starttag(self, tag, attrs):
self.versions.append(version)


def main():
def versions_to_build():
parser = VersionFinder()
response = urllib.request.urlopen(url)
data = response.read().decode(response.headers.get_content_charset())
parser.feed(data)
with open("Dockerfile.template") as f:
template = f.read()
for ver in parser.versions:
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',
'0.7.54.11', # invalid CRC in archive
'0.7.51', # no autoconf
))) or \
ver == '0.7':
# ignore old releases
continue
if os.path.exists(ver):
shutil.rmtree(ver)
os.mkdir(ver)
with open(pathlib.Path(ver) / "Dockerfile", "w+") as f:
f.write(template.format(version=ver))
#for i in ("etc", "bin"):
# shutil.copytree(i, pathlib.Path(ver) / i)
#shutil.copyfile("docker-entrypoint.sh", pathlib.Path(ver) / "docker-entrypoint.sh")
#shutil.copyfile("requirements.txt", pathlib.Path(ver) / "requirements.txt")

return [
version for version in parser.versions
if version != '0.7'
and not any(version.startswith(skip_prefix) for skip_prefix in skip_prefixes)
]


if __name__ == '__main__':
main()
for version_to_build in versions_to_build():
print(version_to_build)