Skip to content

Commit

Permalink
Adapt Docker setup to latest changes
Browse files Browse the repository at this point in the history
And use newer versions of base images.
  • Loading branch information
tpetillon committed Nov 17, 2024
1 parent 6164c07 commit a6e8c17
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 26 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
*
!scripts/tune-postgis.sh
!openstreetmap-carto.style
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
FROM ubuntu:focal
FROM ubuntu:noble

# https://serverfault.com/questions/949991/how-to-install-tzdata-on-a-ubuntu-docker-image
ARG DEBIAN_FRONTEND=noninteractive

# Style dependencies
RUN apt-get update && apt-get install --no-install-recommends -y \
ca-certificates curl gnupg postgresql-client python3 python3-distutils \
fonts-hanazono fonts-noto-cjk fonts-noto-hinted fonts-noto-unhinted \
mapnik-utils nodejs npm ttf-unifont unzip git && rm -rf /var/lib/apt/lists/*
ca-certificates curl gnupg postgresql-client python3 \
fonts-hanazono fonts-noto-cjk fonts-noto-hinted fonts-noto-unhinted fonts-unifont \
mapnik-utils nodejs npm unzip git && rm -rf /var/lib/apt/lists/*

# Kosmtik with plugins, forcing prefix to /usr because Ubuntu sets
# npm prefix to /usr/local, which breaks the install
# We install kosmtik not from release channel, but directly from a specific commit on github.
RUN npm set prefix /usr && npm install -g --unsafe-perm "git+https://git@github.com/kosmtik/kosmtik.git"
# 5dbde8db6b5e22073951066b0646a91c10bb81a5 is master's tip as of 2024-11-17.
RUN npm set prefix /usr && npm install -g --unsafe-perm "git+https://git@github.com/kosmtik/kosmtik.git#5dbde8db6b5e22073951066b0646a91c10bb81a5"

WORKDIR /usr/lib/node_modules/kosmtik/
RUN kosmtik plugins --install kosmtik-overpass-layer \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.db
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM postgis/postgis:10-2.5-alpine
FROM postgis/postgis:15-3.5-alpine

COPY ./scripts/tune-postgis.sh /docker-entrypoint-initdb.d/tune-postgis.sh
14 changes: 1 addition & 13 deletions Dockerfile.import
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
FROM ubuntu:bionic

RUN apt-get update && apt-get install --no-install-recommends -y \
ca-certificates curl gnupg && rm -rf /var/lib/apt/lists/*

RUN echo 'deb http://ppa.launchpad.net/osmadmins/ppa/ubuntu bionic main\n\
deb-src http://ppa.launchpad.net/osmadmins/ppa/ubuntu bionic main' > \
/etc/apt/sources.list.d/osmadmins-ppa.list

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 \
--recv A438A16C88C6BE41CB1616B8D57F48750AC4F2CB
FROM ubuntu:noble

RUN apt-get update && apt-get install --no-install-recommends -y \
osm2pgsql gdal-bin python3-psycopg2 python3-yaml unzip \
python3-requests postgresql-client && rm -rf /var/lib/apt/lists/*

ADD openstreetmap-carto-flex.lua /

RUN mkdir -p /openstreetmap-carto
WORKDIR /openstreetmap-carto

Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'
services:
kosmtik:
image: kosmtik:v1
image: openstreetmap-carto-kosmtik:v1
platform: linux/amd64
build:
context: .
Expand All @@ -16,7 +16,7 @@ services:
- PGHOST=db
- PGUSER=postgres
db:
image: db:v1
image: openstreetmap-carto-db:v1
build:
context: .
dockerfile: Dockerfile.db
Expand All @@ -25,7 +25,7 @@ services:
- PG_WORK_MEM
- PG_MAINTENANCE_WORK_MEM
import:
image: import:v1
image: openstreetmap-carto-import:v1
build:
context: .
dockerfile: Dockerfile.import
Expand Down
11 changes: 8 additions & 3 deletions scripts/docker-startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ test $i -gt $MAXCOUNT && echo "Timeout while waiting for PostgreSQL to be runnin
case "$1" in
import)
# Creating default database
psql -c "SELECT 1 FROM pg_database WHERE datname = 'gis';" | grep -q 1 || createdb gis && \
psql -d gis -c 'CREATE EXTENSION IF NOT EXISTS postgis;' && \
psql -d gis -c 'CREATE EXTENSION IF NOT EXISTS hstore;' && \
psql -c "SELECT 1 FROM pg_database WHERE datname = 'gis';" | grep -q 1 || createdb gis
psql -d gis -c 'CREATE EXTENSION IF NOT EXISTS postgis;'
psql -d gis -c 'CREATE EXTENSION IF NOT EXISTS hstore;'
psql -d gis -c 'ALTER SYSTEM SET jit=off;' -c 'SELECT pg_reload_conf();'

# Creating default import settings file editable by user and passing values for osm2pgsql
if [ ! -e ".env" ]; then
Expand Down Expand Up @@ -50,6 +51,10 @@ EOF
--style openstreetmap-carto-flex.lua \
$OSM2PGSQL_DATAFILE

# Setting up indexes and functions
psql -d gis -f indexes.sql
psql -d gis -f functions.sql

# Downloading and importing needed shapefiles
scripts/get-external-data.py $EXTERNAL_DATA_SCRIPT_FLAGS

Expand Down

0 comments on commit a6e8c17

Please sign in to comment.