Skip to content

Commit

Permalink
Lint Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentAntoine committed May 23, 2024
1 parent 779779e commit 4a1516c
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions infra/docker/database/pg13_16.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG PG_MAJOR
ARG TIMESCALEDB_VERSION
ARG POSTGIS_VERSION

FROM postgres:$PG_MAJOR-bookworm
FROM postgres:"$PG_MAJOR"-bookworm
ARG PG_MAJOR
ARG TIMESCALEDB_VERSION
ARG POSTGIS_VERSION
Expand All @@ -11,33 +11,34 @@ RUN \
apt-get update && \
apt-get install -y \
wget \
lsb-release
lsb-release && \
rm -rf /var/lib/apt/lists/*

# Install TimescaleDB extension
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 \
TIMESCALEDB_MAJOR=$(echo $TIMESCALEDB_VERSION | cut -c1) && \
TIMESCALEDB_MAJOR=$(echo "$TIMESCALEDB_VERSION" | cut -c1) && \
apt-get update && \
apt-get install -y \
timescaledb-$TIMESCALEDB_MAJOR-postgresql-$PG_MAJOR=$TIMESCALEDB_VERSION* \
timescaledb-$TIMESCALEDB_MAJOR-loader-postgresql-$PG_MAJOR=$TIMESCALEDB_VERSION* && \
timescaledb-"$TIMESCALEDB_MAJOR"-postgresql-"$PG_MAJOR"="$TIMESCALEDB_VERSION"* \
timescaledb-"$TIMESCALEDB_MAJOR"-loader-postgresql-"$PG_MAJOR"="$TIMESCALEDB_VERSION"* && \
rm -rf /var/lib/apt/lists/*

RUN for file in $(find /usr/share/postgresql -name 'postgresql.conf.sample'); do \
# We want timescaledb to be loaded in this image by every created cluster
sed -r -i "s/[#]*\s*(shared_preload_libraries)\s*=\s*'(.*)'/\1 = 'timescaledb,\2'/;s/,'/'/" $file \
sed -r -i "s/[#]*\s*(shared_preload_libraries)\s*=\s*'(.*)'/\1 = 'timescaledb,\2'/;s/,'/'/" "$file" \
# We need to listen on all interfaces, otherwise PostgreSQL is not accessible
&& echo "listen_addresses = '*'" >> $file; \
&& echo "listen_addresses = '*'" >> "$file"; \
done

# Install PostGIS extension
RUN \
POSTGIS_MAJOR=$(echo $POSTGIS_VERSION | cut -c1) && \
POSTGIS_MAJOR=$(echo "$POSTGIS_VERSION" | cut -c1) && \
apt update && \
apt install -y --no-install-recommends \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION* \
postgresql-$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 4a1516c

Please sign in to comment.