Skip to content
Draft
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
34 changes: 28 additions & 6 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,53 @@ permissions:
contents: read

jobs:
publish_jore_postgres_docker_image_to_acr:
name: Publish Generic Jore4 PostgreSQL Docker image to ACR
permissions:
id-token: write
contents: read
uses: HSLdevcom/jore4-tools/.github/workflows/shared-build-and-publish-docker-image.yml@main
with:
docker_image_name: jore4-postgres
build_arm64_image: true
context: ${{ github.server_url }}/${{ github.repository }}.git#${{ github.ref }}:./joredb
target: jore4-postgres
secrets:
azure_client_id: ${{ secrets.AZURE_CLIENT_ID }}
azure_tenant_id: ${{ secrets.AZURE_TENANT_ID }}
azure_subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

publish_mapmatching_docker_image_to_acr:
name: Publish Map Matching Docker image to ACR
needs:
- publish_jore_postgres_docker_image_to_acr
permissions:
id-token: write
contents: read
uses: HSLdevcom/jore4-tools/.github/workflows/shared-build-and-publish-docker-image.yml@shared-build-and-publish-docker-image-v6
uses: HSLdevcom/jore4-tools/.github/workflows/shared-build-and-publish-docker-image.yml@main
with:
docker_image_name: jore4-postgres-mapmatching
build_arm64_image: true
context: ${{ github.server_url }}/${{ github.repository }}.git#${{ github.ref }}:./mapmatching
context: ${{ github.server_url }}/${{ github.repository }}.git#${{ github.ref }}:./joredb
target: jore4-postgres-mapmatching
secrets:
azure_client_id: ${{ secrets.AZURE_CLIENT_ID }}
azure_tenant_id: ${{ secrets.AZURE_TENANT_ID }}
azure_subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

publish_azuredbmock_docker_image_to_acr:
name: Publish Azure DB Mock Docker image to ACR
needs:
- publish_jore_postgres_docker_image_to_acr
permissions:
id-token: write
contents: read
uses: HSLdevcom/jore4-tools/.github/workflows/shared-build-and-publish-docker-image.yml@shared-build-and-publish-docker-image-v6
uses: HSLdevcom/jore4-tools/.github/workflows/shared-build-and-publish-docker-image.yml@main
with:
docker_image_name: jore4-postgres-azuredbmock
build_arm64_image: true
context: ${{ github.server_url }}/${{ github.repository }}.git#${{ github.ref }}:./azuredbmock
context: ${{ github.server_url }}/${{ github.repository }}.git#${{ github.ref }}:./joredb
target: jore4-postgres-azuredbmock
secrets:
azure_client_id: ${{ secrets.AZURE_CLIENT_ID }}
azure_tenant_id: ${{ secrets.AZURE_TENANT_ID }}
Expand All @@ -46,7 +68,7 @@ jobs:
needs:
- publish_mapmatching_docker_image_to_acr
- publish_azuredbmock_docker_image_to_acr
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
env:
POSTGRES_DB: testdb
POSTGRES_USER: user
Expand Down Expand Up @@ -151,7 +173,7 @@ jobs:
- name: Verify that postgres database is up and can be connected to
id: healthcheck
continue-on-error: true
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@main
with:
command:
'psql -h localhost -p 6432 -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-renovatebot-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ permissions:
jobs:
validate:
name: Validate renovatebot config
uses: HSLdevcom/jore4-tools/.github/workflows/shared-check-renovatebot-config.yml@shared-check-renovatebot-config-v2
uses: HSLdevcom/jore4-tools/.github/workflows/shared-check-renovatebot-config.yml@main
with:
config_file_path: .github/renovate.json5
6 changes: 3 additions & 3 deletions .github/workflows/test-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:
jobs:
test-docker-compose:
name: verify docker-compose setup
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04

steps:
- name: Checkout code
Expand All @@ -25,7 +25,7 @@ jobs:
- name: Verify that mapmatching database is up and can be connected to
id: mapmatching_healthcheck
continue-on-error: true
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@main
env:
POSTGRES_USER: username
POSTGRES_DB: testdb
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Verify that azuredbmock database is up and can be connected to
id: azuredbmock_healthcheck
continue-on-error: true
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@main
env:
POSTGRES_USER: username
POSTGRES_DB: testdb
Expand Down
51 changes: 0 additions & 51 deletions azuredbmock/Dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions azuredbmock/archive.sources.list

This file was deleted.

41 changes: 0 additions & 41 deletions azuredbmock/migrations/10_postgis.sh

This file was deleted.

6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
services:
mapmatchingdb:
build:
context: "./mapmatching"
context: ./joredb
target: jore4-postgres-mapmatching
container_name: mapmatchingdb
restart: "unless-stopped"
networks:
Expand All @@ -20,7 +21,8 @@ services:

azuredbmock:
build:
context: "./azuredbmock"
context: ./joredb
target: jore4-postgres-azuredbmock
container_name: azuredbmock
restart: "unless-stopped"
networks:
Expand Down
71 changes: 46 additions & 25 deletions mapmatching/Dockerfile → joredb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
## relase ARM64 versions of the image at the moment (they did in the past).
## And thus, we have to build the ARM version our selves.

FROM docker.io/postgres:15-bullseye AS postgis
FROM docker.io/postgres:18-trixie AS postgis

ENV POSTGIS_MAJOR=3
ENV POSTGIS_VERSION=3.5.2+dfsg-1.pgdg110+1

# Switch to Debian Archive for EOL disto version
RUN rm /etc/apt/sources.list
ADD archive.sources.list /etc/apt/sources.list
ENV POSTGIS_VERSION=3.6.4+dfsg-2.pgdg13+1

RUN apt-get update \
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
Expand All @@ -20,27 +16,27 @@ RUN apt-get update \
\
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir -p /docker-entrypoint-initdb.d
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /docker-entrypoint-initdb.d


# Inlined version of the pgrouting Dockerfile. Needed to add support for the ARM64 version.
FROM postgis AS pgrouting

ENV PGROUTING_VERSION=3.8.0
ENV PGROUTING_SHA256=b8a5f0472934fdf7cda3fb4754d01945378d920cdaddc01f378617ddbb9c447f
ENV LIBBOOST_VERSION=1.83.0

RUN set -ex \
&& apt update \
&& apt install -y \
libboost-atomic1.74.0 \
libboost-chrono1.74.0 \
libboost-graph1.74.0 \
libboost-date-time1.74.0 \
libboost-program-options1.74.0 \
libboost-system1.74.0 \
libboost-thread1.74.0 \
libboost-atomic${LIBBOOST_VERSION} \
libboost-chrono${LIBBOOST_VERSION} \
libboost-graph${LIBBOOST_VERSION} \
libboost-date-time${LIBBOOST_VERSION} \
libboost-program-options${LIBBOOST_VERSION} \
libboost-system${LIBBOOST_VERSION} \
libboost-thread${LIBBOOST_VERSION} \
&& apt install -y \
build-essential \
cmake \
Expand All @@ -61,11 +57,11 @@ RUN set -ex \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make \
&& make -j $(nproc --all) \
&& make install \
&& cd / \
&& rm -rf /usr/src/pgrouting \
&& apt-mark manual postgresql-15 \
&& apt-mark manual postgresql-18 \
&& apt purge -y --autoremove \
build-essential \
cmake \
Expand All @@ -75,16 +71,41 @@ RUN set -ex \
&& rm -rf /var/lib/apt/lists/*


FROM pgrouting
# Create a baseline PostgreSQL server image with PostGIS and PgRouting extensions installed in.
# Can and should be used as the "random postgresql container neede in place X", that is instead
# of pulling in the normal postgres/postgis/pgrouting images where and whenever, use this instead.
FROM pgrouting AS jore4-postgres

# download script for reading docker secrets
ADD --chmod=755 https://raw.githubusercontent.com/HSLdevcom/jore4-tools/main/docker/read-secrets.sh /tmp/read-secrets.sh
# Change collations to use fi_FI
RUN localedef -i fi_FI -c -f UTF-8 -A /usr/share/locale/locale.alias fi_FI.UTF-8
ENV LANG=fi_FI.utf8

COPY --chmod=755 entrypoint.sh /usr/local/bin/
RUN mkdir -p -m 0755 /jore4/migrations /jore4/scripts

ENTRYPOINT ["entrypoint.sh"]
CMD ["postgres"]
# Download script for reading docker secrets
ADD --chmod=755 https://raw.githubusercontent.com/HSLdevcom/jore4-tools/main/docker/read-secrets.sh /jore4/scripts/read-secrets.sh

# have to source the secrets here as well, otherwise the POSTGRES_USER and/or POSTGRES_DB variables might not exist
# Read in secrets to ensure POSTGRES_USER and/or POSTGRES_DB are set
HEALTHCHECK --interval=5s --timeout=5s --start-period=10s --retries=20 \
CMD bash -c "source /tmp/read-secrets.sh && pg_isready -h localhost -U \${POSTGRES_USER} -d \${POSTGRES_DB}"


# The primary Database image
FROM jore4-postgres AS jore4-postgres-azuredbmock

COPY --chmod=644 migrations/azuredbmock /jore4/migrations/
COPY --chmod=755 replace-placeholders-in-sql-schema-migrations.sh /jore4/scripts/replace-placeholders-in-sql-schema-migrations.sh
COPY --chmod=755 azuredbmock-entrypoint.sh /jore4/scripts/

ENTRYPOINT ["/jore4/scripts/azuredbmock-entrypoint.sh"]
CMD ["postgres"]


# The Map Matching service's image
FROM jore4-postgres AS jore4-postgres-mapmatching

COPY --chmod=644 migrations/mapmatching /docker-entrypoint-initdb.d/
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

ENTRYPOINT ["/jore4/scripts/mapmatching-entrypoint.sh"]
CMD ["postgres"]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -Eeuo pipefail
# read the secrets to environment variables
source /jore4/scripts/read-secrets.sh

# copy the migrations scripts to the docker-entrypoint-initdb.d folder so that the postgres entrypoint
# Copy the migrations scripts to the docker-entrypoint-initdb.d folder so that the postgres entrypoint
# executes them (together with the other migrations that might have been mapped as a volume)
mkdir -p /docker-entrypoint-initdb.d
cp /jore4/migrations/* /docker-entrypoint-initdb.d/
Expand Down
10 changes: 10 additions & 0 deletions joredb/mapmatching-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -Eeuo pipefail

# Read the secrets to environment variables.
source /tmp/read-secrets.sh

# Call the original entrypoint to continue startup.
echo 'Start postgres'
exec /usr/local/bin/docker-entrypoint.sh "$@"
2 changes: 2 additions & 0 deletions joredb/migrations/mapmatching/01-initialize.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE EXTENSION postgis;
CREATE EXTENSION pgrouting;
1 change: 1 addition & 0 deletions joredb/migrations/mapmatching/02-digiroad_r_routing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Actual SQL file is downloaded and placed in the Dockerfile
1 change: 1 addition & 0 deletions joredb/migrations/mapmatching/03-post-initialize.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER DATABASE ${POSTGRES_DB} SET search_path = routing, public;
7 changes: 0 additions & 7 deletions mapmatching/archive.sources.list

This file was deleted.

Loading
Loading