Skip to content

Commit

Permalink
pg-slim: build latest Pg version for the given major
Browse files Browse the repository at this point in the history
  • Loading branch information
vrmiguel committed Mar 27, 2024
1 parent c82bf17 commit 8eb9338
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions tembo-pg-slim/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ ARG DEBIAN_FRONTEND=noninteractive
ARG ALTDIR=/var/lib/postgresql/data/tembo
ENV TZ=Etc/UTC
ENV PGDATA /var/lib/postgresql/data
ARG PG_RELEASE 15.3
ARG PG_VERSION 15
ENV PATH $PATH:/usr/lib/postgresql/$PG_VERSION/bin

Expand All @@ -20,7 +19,7 @@ RUN set -eux; \
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
mkdir -p /var/lib/postgresql; \
chown -R postgres:postgres /var/lib/postgresql; \
apt-get update; apt-get install -y curl ca-certificates gnupg lsb-release lbzip2
apt-get update; apt-get install -y curl ca-certificates gnupg lsb-release lbzip2 git

STOPSIGNAL SIGINT

Expand All @@ -35,9 +34,12 @@ ENV LANG en_US.utf8

RUN mkdir /docker-entrypoint-initdb.d

# Build Postgres from source
RUN curl https://ftp.postgresql.org/pub/source/v${PG_RELEASE}/postgresql-${PG_RELEASE}.tar.bz2 -o postgresql-${PG_RELEASE}.tar.bz2
RUN tar xf postgresql-${PG_RELEASE}.tar.bz2
RUN git clone https://github.com/postgres/postgres.git && \
cd postgres && \
PG_RELEASE=$(git tag | grep '^REL_'${PG_VERSION}'_' | grep -vE 'RC|BETA' | sort -V | tail -1 | sed 's/REL_//;s/_/./g') && \
echo $PG_RELEASE && \
git checkout $PG_RELEASE

RUN set -eux; \
apt-get update && apt-get install -y \
libreadline-dev \
Expand Down Expand Up @@ -65,12 +67,15 @@ RUN set -eux; \
libsystemd-dev \
libselinux1-dev \
libzstd-dev \
vim \
; \
vim \
flex \
bison; \
apt-get autoremove -y; \
apt-get clean -y; \
rm -rf /var/lib/apt/lists/*
WORKDIR postgresql-${PG_RELEASE}

WORKDIR postgres

ENV CFLAGS "-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer"
ENV LDFLAGS "-Wl,-z,relro -Wl,-z,now"
RUN ./configure --prefix=/usr/lib/postgresql/${PG_VERSION} \
Expand Down Expand Up @@ -101,10 +106,9 @@ RUN ./configure --prefix=/usr/lib/postgresql/${PG_VERSION} \

RUN make -j$(nproc)
RUN make install
RUN cd .. && rm postgresql-${PG_RELEASE}.tar.bz2

WORKDIR /
RUN rm -rf /postgresql-${PG_RELEASE}
RUN rm -rf /postgres

# Remove pre-installed pg_config
RUN rm /usr/bin/pg_config
Expand Down

0 comments on commit 8eb9338

Please sign in to comment.