Skip to content

Commit

Permalink
Add debian based database image
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentAntoine committed May 22, 2024
1 parent ccd05e2 commit 288326c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ jobs:
postgis_version: "3.4.2"
dockerfile: "pg13_16.Dockerfile"
image_version: "pg16-ts2.14.2-postgis3.4.2"
- pg_major: "16"
timescaledb_version: "2.14.2"
postgis_version: "3.4.2"
dockerfile: "pg16_debian.Dockerfile"
image_version: "bookworm-pg16-ts2.14.2-postgis3.4.2"
permissions:
contents: read
packages: write
Expand Down
34 changes: 6 additions & 28 deletions infra/docker/database/pg16_debian.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
ARG TO_PG_MAJOR
ARG PG_MAJOR
ARG TIMESCALEDB_VERSION
ARG POSTGIS_VERSION
ARG DISTRIBUTION

FROM postgres:$TO_PG_MAJOR-$DISTRIBUTION
ARG TO_PG_MAJOR
FROM postgres:$PG_MAJOR-bookworm
ARG PG_MAJOR
ARG TIMESCALEDB_VERSION
ARG POSTGIS_VERSION

ENV PGBINNEW /usr/lib/postgresql/$TO_PG_MAJOR/bin

ENV PGDATANEW /var/lib/postgresql/$TO_PG_MAJOR/data

RUN set -eux; \
mkdir -p "$PGDATANEW"; \
chown -R postgres:postgres /var/lib/postgresql

WORKDIR /var/lib/postgresql

COPY infra/docker/database/docker-upgrade /usr/local/bin/

ENTRYPOINT ["docker-upgrade"]

# recommended: --link
CMD ["pg_upgrade"]


# Install TimescaleDB extension in both versions of Postgres
RUN apt-get update
RUN apt-get install -y wget lsb-release
Expand All @@ -36,16 +17,13 @@ RUN apt-get update

RUN \
TIMESCALEDB_MAJOR=$(echo $TIMESCALEDB_VERSION | cut -c1) && \
apt-get install -y timescaledb-$TIMESCALEDB_MAJOR-postgresql-$FROM_PG_MAJOR=$TIMESCALEDB_VERSION* timescaledb-$TIMESCALEDB_MAJOR-loader-postgresql-$FROM_PG_MAJOR=$TIMESCALEDB_VERSION* && \
apt-get install -y timescaledb-$TIMESCALEDB_MAJOR-postgresql-$TO_PG_MAJOR=$TIMESCALEDB_VERSION* timescaledb-$TIMESCALEDB_MAJOR-loader-postgresql-$TO_PG_MAJOR=$TIMESCALEDB_VERSION*
apt-get install -y timescaledb-$TIMESCALEDB_MAJOR-postgresql-$PG_MAJOR=$TIMESCALEDB_VERSION* timescaledb-$TIMESCALEDB_MAJOR-loader-postgresql-$PG_MAJOR=$TIMESCALEDB_VERSION*

# Install PostGIS extension in both versions of Postgres
RUN apt update
RUN \
POSTGIS_MAJOR=$(echo $POSTGIS_VERSION | cut -c1) && \
apt install -y --no-install-recommends \
postgresql-$FROM_PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION* \
postgresql-$FROM_PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
postgresql-$TO_PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION* \
postgresql-$TO_PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION* \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
&& rm -rf /var/lib/apt/lists/*

0 comments on commit 288326c

Please sign in to comment.