|
| 1 | +## Below an inlined version of the PostGIS Dockerfile. PostGIS does not |
| 2 | +## relase ARM64 versions of the image at the moment (they did in the past). |
| 3 | +## And thus, we have to build the ARM version our selves. |
| 4 | + |
| 5 | +FROM docker.io/postgres:18-trixie AS postgis |
| 6 | + |
| 7 | +ENV POSTGIS_MAJOR=3 |
| 8 | +ENV POSTGIS_VERSION=3.6.4+dfsg-2.pgdg13+1 |
| 9 | + |
| 10 | +RUN apt-get update \ |
| 11 | + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ |
| 12 | + && apt-get install -y --no-install-recommends \ |
| 13 | + # ca-certificates: for accessing remote raster files; |
| 14 | + # fix: https://github.com/postgis/docker-postgis/issues/307 |
| 15 | + ca-certificates \ |
| 16 | + \ |
| 17 | + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ |
| 18 | + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ |
| 19 | + && rm -rf /var/lib/apt/lists/* \ |
| 20 | + && mkdir -p /docker-entrypoint-initdb.d |
| 21 | + |
| 22 | + |
| 23 | +# Inlined version of the pgrouting Dockerfile. Needed to add support for the ARM64 version. |
| 24 | +FROM postgis AS pgrouting |
| 25 | + |
| 26 | +ENV PGROUTING_VERSION=3.8.0 |
| 27 | +ENV PGROUTING_SHA256=b8a5f0472934fdf7cda3fb4754d01945378d920cdaddc01f378617ddbb9c447f |
| 28 | +ENV LIBBOOST_VERSION=1.83.0 |
| 29 | + |
| 30 | +RUN set -ex \ |
| 31 | + && apt update \ |
| 32 | + && apt install -y \ |
| 33 | + libboost-atomic${LIBBOOST_VERSION} \ |
| 34 | + libboost-chrono${LIBBOOST_VERSION} \ |
| 35 | + libboost-graph${LIBBOOST_VERSION} \ |
| 36 | + libboost-date-time${LIBBOOST_VERSION} \ |
| 37 | + libboost-program-options${LIBBOOST_VERSION} \ |
| 38 | + libboost-system${LIBBOOST_VERSION} \ |
| 39 | + libboost-thread${LIBBOOST_VERSION} \ |
| 40 | + && apt install -y \ |
| 41 | + build-essential \ |
| 42 | + cmake \ |
| 43 | + curl \ |
| 44 | + libboost-graph-dev \ |
| 45 | + libpq-dev \ |
| 46 | + postgresql-server-dev-${PG_MAJOR} \ |
| 47 | + && curl -Lo pgrouting.tar.gz "https://github.com/pgRouting/pgrouting/archive/v${PGROUTING_VERSION}.tar.gz" \ |
| 48 | + && echo "$PGROUTING_SHA256 *pgrouting.tar.gz" | sha256sum -c - \ |
| 49 | + && mkdir -p /usr/src/pgrouting \ |
| 50 | + && tar \ |
| 51 | + --extract \ |
| 52 | + --file pgrouting.tar.gz \ |
| 53 | + --directory /usr/src/pgrouting \ |
| 54 | + --strip-components 1 \ |
| 55 | + && rm pgrouting.tar.gz \ |
| 56 | + && cd /usr/src/pgrouting \ |
| 57 | + && mkdir build \ |
| 58 | + && cd build \ |
| 59 | + && cmake .. \ |
| 60 | + && make -j $(nproc --all) \ |
| 61 | + && make install \ |
| 62 | + && cd / \ |
| 63 | + && rm -rf /usr/src/pgrouting \ |
| 64 | + && apt-mark manual postgresql-18 \ |
| 65 | + && apt purge -y --autoremove \ |
| 66 | + build-essential \ |
| 67 | + cmake \ |
| 68 | + libpq-dev \ |
| 69 | + libboost-graph-dev \ |
| 70 | + postgresql-server-dev-${PG_MAJOR} \ |
| 71 | + && rm -rf /var/lib/apt/lists/* |
| 72 | + |
| 73 | + |
| 74 | +# Create a baseline PostgreSQL server image with PostGIS and PgRouting extensions installed in. |
| 75 | +# Can and should be used as the "random postgresql container neede in place X", that is instead |
| 76 | +# of pulling in the normal postgres/postgis/pgrouting images where and whenever, use this instead. |
| 77 | +FROM pgrouting AS jore4-postgres |
| 78 | + |
| 79 | +# Change collations to use fi_FI |
| 80 | +RUN localedef -i fi_FI -c -f UTF-8 -A /usr/share/locale/locale.alias fi_FI.UTF-8 |
| 81 | +ENV LANG=fi_FI.utf8 |
| 82 | + |
| 83 | +RUN mkdir -p -m 0755 /jore4/migrations /jore4/scripts |
| 84 | + |
| 85 | +# Download script for reading docker secrets |
| 86 | +ADD --chmod=755 https://raw.githubusercontent.com/HSLdevcom/jore4-tools/main/docker/read-secrets.sh /jore4/scripts/read-secrets.sh |
| 87 | + |
| 88 | +# Read in secrets to ensure POSTGRES_USER and/or POSTGRES_DB are set |
| 89 | +HEALTHCHECK --interval=5s --timeout=5s --start-period=10s --retries=20 \ |
| 90 | + CMD bash -c "source /tmp/read-secrets.sh && pg_isready -h localhost -U \${POSTGRES_USER} -d \${POSTGRES_DB}" |
| 91 | + |
| 92 | + |
| 93 | +# The primary Database image |
| 94 | +FROM jore4-postgres AS jore4-postgres-azuredbmock |
| 95 | + |
| 96 | +COPY --chmod=644 migrations/azuredbmock /jore4/migrations/ |
| 97 | +COPY --chmod=755 replace-placeholders-in-sql-schema-migrations.sh /jore4/scripts/replace-placeholders-in-sql-schema-migrations.sh |
| 98 | +COPY --chmod=755 azuredbmock-entrypoint.sh /jore4/scripts/ |
| 99 | + |
| 100 | +ENTRYPOINT ["/jore4/scripts/azuredbmock-entrypoint.sh"] |
| 101 | +CMD ["postgres"] |
| 102 | + |
| 103 | + |
| 104 | +# The Map Matching service's image |
| 105 | +FROM jore4-postgres AS jore4-postgres-mapmatching |
| 106 | + |
| 107 | +COPY --chmod=644 migrations/mapmatching /docker-entrypoint-initdb.d/ |
| 108 | +ADD --chmod=644 https://stjore4dev001.blob.core.windows.net/jore4-digiroad/2026-08-04_create_routing_schema_digiroad_r_2026-01_mml_2026-08-04.sql /docker-entrypoint-initdb.d/02-digiroad_r_routing.sql |
| 109 | + |
| 110 | +ENTRYPOINT ["/jore4/scripts/mapmatching-entrypoint.sh"] |
| 111 | +CMD ["postgres"] |
0 commit comments