Dockerfile example
ssipos90 opened this issue · 2 comments
Hi,
I wanted to drop a Dockerfile, maybe someone will find it useful.
This container needs OSM_CHANGES_URL to work and a planet dump either in dumps volume as /dumps/latest.pbf
or specified as an env var.
build/osmimposm/Dockerfile:
FROM debian:buster-slim
ARG IMPOSM_VERSION=v0.11.1/imposm-0.11.1-linux-x86-64.tar.gz
RUN set -eu; \
useradd -M -u 999 -r imposm; \
mkdir -p /data /opt/imposm; \
chown -R imposm:imposm /data /opt/imposm; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gettext; \
curl -sL https://github.com/omniscale/imposm3/releases/download/$IMPOSM_VERSION \
| tar -xz -C /usr/local/bin --strip-components=1; \
chmod +x /usr/local/bin/imposm; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*;
COPY import-pbf entrypoint /usr/local/bin/
COPY *.json* /opt/imposm/
VOLUME /data
VOLUME /expiry
VOLUME /dumps
WORKDIR /data
USER imposm
ENTRYPOINT ["/usr/local/bin/entrypoint"]
CMD ["run"]
build/osmimposm/entrypoint (chmod +x)
#!/bin/sh
set -eu
envsubst < /opt/imposm/config.json.template > /opt/imposm/config.json
export DEFAULT_ARGS="-config /opt/imposm/config.json -connection $DATABASE_URL"
case "$1" in
import) import-pbf;;
run)
find /expiry -type f -mtime +3 -delete
find /expiry -mindepth 1 -type d -mtime +7 -empty -delete
exec imposm run $DEFAULT_ARGS
;;
*) exec "$@";;
esac
build/osmimposm/config.json.template
{
"replication_url": "$OSM_CHANGES_URL",
"diffdir": "/data/diff",
"cachedir": "/data/cache",
"mapping": "/opt/imposm/mapping.json",
"expiretiles_dir": "/expiry",
"expiretiles_zoom": 14
}
build/osmimposm/import-pbf (chmod +x)
#!/bin/sh
set -eu
rm -rf /data/diff/* /data/cache/*
PBF_PATH=${PBF_PATH:-/dumps/latest.pbf}
imposm import $DEFAULT_ARGS \
-read "${PBF_PATH}" \
-diff \
-overwritecache \
-write
echo "deploying in production"
imposm import $DEFAULT_ARGS -deployproduction
docker-compose.yml
services:
postgres:
image: postgis/postgis
...
osmimposm:
build: build/osmimposm
environment:
- OSM_CHANGES_URL=https://planet.openstreetmap.org/replication/minute
- DATABASE_URL=postgis://user:password@postgres/yourdbname
volumes:
- osmimposm:/data
- osmtilesexpiry:/expiry
- osmpbfdumps:/dumps:ro
volumes:
osmimposm:
osmpbfdumps:
osmtilesexpiry:
You need to have a mapping.json
in the build context.
Edits:
Add missing volume, typos
Add missing config.json.template
Add docker-compose.yml
Would be nice if there is an official docker image that can be used on different processor architectures (x86, x64 and arm64). What is your opinion about this?
Would be nice if there is an official docker image that can be used on different processor architectures (x86, x64 and arm64). What is your opinion about this?
You'd probably need a build stage.