Skip to content

Commit

Permalink
pg-slim: build latest Pg version for the given major (#65)
Browse files Browse the repository at this point in the history
* pg-slim: build latest Pg version for the given major

* Remove pg_release from CI
  • Loading branch information
vrmiguel authored Mar 27, 2024
1 parent c82bf17 commit c886b8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_tembo_pg_slim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Append PostgreSQL configurations to matrix
id: append_pg_configs
run: |
PG_CONFIGS='[{"pg_release": "14.10", "pg_version": "14"}, {"pg_release": "15.3", "pg_version": "15"}, {"pg_release": "16.1", "pg_version": "16"}]'
PG_CONFIGS='[{"pg_version": "14"}, {"pg_version": "15"}, {"pg_version": "16"}]'
MODIFIED_MATRIX=$(echo $PG_CONFIGS | jq -c '{include: .}')
echo "build_matrix=$MODIFIED_MATRIX" >> $GITHUB_OUTPUT
- name: Determine which tags to publish
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
- name: Build Docker images based on conditions
run: |
IMAGE_NAME=$CONTAINER_NAME:${{ matrix.pg_version }}
docker build ./$CONTAINER_NAME --build-arg PG_RELEASE=${{ matrix.pg_release }} --build-arg PG_VERSION=${{ matrix.pg_version }} -t $IMAGE_NAME
docker build ./$CONTAINER_NAME --build-arg PG_VERSION=${{ matrix.pg_version }} -t $IMAGE_NAME
shell: bash
- name: Login to Tembo Quay
uses: docker/login-action@v2
Expand Down
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_//') && \
echo $PG_RELEASE && \
git checkout REL_$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 c886b8d

Please sign in to comment.