Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentAntoine committed May 22, 2024
1 parent 34611de commit ccd05e2
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions infra/docker/database/pg16_debian.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
ARG TO_PG_MAJOR
ARG TIMESCALEDB_VERSION
ARG POSTGIS_VERSION
ARG DISTRIBUTION

FROM postgres:$TO_PG_MAJOR-$DISTRIBUTION
ARG TO_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
RUN echo "deb https://packagecloud.io/timescale/timescaledb/debian/ $(lsb_release -c -s) main"
RUN echo "deb https://packagecloud.io/timescale/timescaledb/debian/ $(lsb_release -c -s) main" > /etc/apt/sources.list.d/timescaledb.list
RUN wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | apt-key add -
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*

# 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 \
&& rm -rf /var/lib/apt/lists/*

0 comments on commit ccd05e2

Please sign in to comment.