Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions .github/workflows/reusable-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,7 @@ defaults:
# default failure handling for shell scripts in 'run' steps
shell: 'bash -Eeuo pipefail -x {0}'

permissions:
actions: none
attestations: none
checks: none
contents: none
deployments: none
id-token: none
issues: none
models: none
discussions: none
packages: none
pages: none
pull-requests: none
security-events: none
statuses: none
permissions: {}

jobs:
e2e-local:
Expand All @@ -66,7 +52,8 @@ jobs:
POSTGRES_VERSION: ${{ inputs.major_version }}
POSTGRES_IMG: ${{ inputs.postgres_img }}
POSTGRES_KIND: "PostgreSQL"
MAJOR_UPGRADE_IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}/postgresql-trunk"
POSTGRES_MAJOR_UPGRADE_IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}/postgresql-trunk"
POSTGIS_MAJOR_UPGRADE_IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}/postgresql-trunk"

DOCKER_SERVER: ghcr.io
DOCKER_USERNAME: ${{ github.actor }}
Expand Down
91 changes: 53 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,44 @@
#
ARG BASE=debian:13.1-slim

FROM $BASE AS build-layer
FROM $BASE AS minimal

ARG PG_REPO=https://git.postgresql.org/git/postgresql.git
ARG PG_BRANCH=master
ARG PG_MAJOR=19

COPY build-deps.txt /

ENV PATH=/usr/lib/postgresql/$PG_MAJOR/bin:$PATH

# Install runtime and build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-get install -y --no-install-recommends -o Dpkg::::="--force-confdef" -o Dpkg::::="--force-confold" \
gnupg \
dirmngr \
ca-certificates \
ssl-cert \
libnss-wrapper \
libgssapi-krb5-2 \
libprotobuf-c1 \
libnuma1 \
liburing2 \
libxml2 \
libllvm16 \
libllvm19 \
libxslt1.1 \
xz-utils \
zstd \
libicu76 \
postgresql-common \
$(cat /build-deps.txt) && \
rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*

RUN usermod -u 26 postgres

ENV PG_MAJOR=$PG_MAJOR
ENV PATH=/usr/lib/postgresql/$PG_MAJOR/bin:$PATH

# Build PostgreSQL
# Partially refer to https://github.com/docker-library/postgres/blob/master/16/alpine3.21/Dockerfile#L119-L159
RUN mkdir -p /usr/src/postgresql && \
$(cat /build-deps.txt) \
&& \
usermod -u 26 postgres && \
# Build PostgreSQL
mkdir -p /usr/src/postgresql && \
git clone -b "$PG_BRANCH" --single-branch "$PG_REPO" /usr/src/postgresql && \
cd /usr/src/postgresql && \
export LLVM_CONFIG="/usr/lib/llvm-16/bin/llvm-config" && \
export CLANG=clang-16 && \
export LLVM_CONFIG="/usr/lib/llvm-19/bin/llvm-config" && \
export CLANG=clang-19 && \
./configure \
--build=x86_64-linux-gnu \
--prefix=/usr \
Expand Down Expand Up @@ -86,6 +86,8 @@ RUN mkdir -p /usr/src/postgresql && \
--with-systemd \
--with-selinux \
--with-zstd \
--with-liburing \
--with-libnuma \
--with-extra-version=-$(git rev-parse --short HEAD) \
--datarootdir=/usr/share/ \
--infodir=/usr/share/info \
Expand All @@ -105,46 +107,59 @@ RUN mkdir -p /usr/src/postgresql && \
&& \
make -j "$(nproc)" world-bin && \
make install-world-bin && \
rm -rf /usr/src/postgresql

# DoD 2.3 - remove setuid/setgid from any binary that not strictly requires it, and before doing that list them on the stdout
RUN find / -not -path "/proc/*" -perm /6000 -type f -exec ls -ld {} \; -exec chmod a-s {} \; || true
apt-get purge -y --auto-remove $(cat /build-deps.txt) && \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/* /usr/src/postgresql


FROM build-layer AS minimal
RUN apt-get purge -y --auto-remove $(cat /build-deps.txt) && \
rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*
USER 26

FROM build-layer AS standard
# TODO: re-enable once https://github.com/pgaudit/pgaudit/issues/257 is fixed
FROM minimal AS standard
USER root

# Build PgAudit
# See to https://github.com/pgaudit/pgaudit/blob/master/README.md#compile-and-install
# RUN mkdir -p /usr/src/pgaudit && \
# TODO: uncomment when https://github.com/pgaudit/pgaudit/issues/257 is fixed
#RUN apt-get update && \
# apt-get install -y --no-install-recommends \
# build-essential \
# git \
# libssl-dev \
# libkrb5-dev \
# && \
# mkdir -p /usr/src/pgaudit && \
# git clone -b main --single-branch https://github.com/pgaudit/pgaudit.git /usr/src/pgaudit && \
# cd /usr/src/pgaudit && \
# make install USE_PGXS=1 PG_CONFIG=/usr/lib/postgresql/$PG_MAJOR/bin/pg_config && \
# rm -rf /usr/src/pgaudit
# apt-get purge -y --auto-remove \
# build-essential \
# git \
# libssl-dev \
# libkrb5-dev \
# && \
# apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
# rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/* /usr/src/pgaudit

# Install all locales
RUN apt-get update && \
apt-get install -y --no-install-recommends locales-all

RUN apt-get purge -y --auto-remove $(cat /build-deps.txt) && \
apt-get install -y --no-install-recommends locales-all && \
rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*

USER 26

FROM build-layer AS postgis
FROM standard AS postgis
USER root
ARG POSTGIS_REPO=https://github.com/postgis/postgis.git
ARG POSTGIS_BRANCH=master

RUN apt-get update && \
apt-get install -y --no-install-recommends \
$(cat /build-deps.txt) \
# runtime deps
libproj25 \
libpq5 \
libgdal32 \
libgeos-c1v5 \
libsfcgal1 \
libgdal36 \
libgeos-c1t64 \
libsfcgal2 \
&& \
mkdir -p /usr/src/postgis && \
git clone -b "$POSTGIS_BRANCH" --single-branch "$POSTGIS_REPO" /usr/src/postgis && \
Expand All @@ -153,8 +168,8 @@ RUN apt-get update && \
./configure --with-pgconfig=/usr/lib/postgresql/$PG_MAJOR/bin/pg_config --with-sfcgal && \
make -j$(nproc) && \
make install && \
rm -rf /usr/src/postgis
apt-get purge -y --auto-remove $(cat /build-deps.txt) && \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/* /usr/src/postgis

RUN apt-get purge -y --auto-remove $(cat /build-deps.txt) && \
rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*
USER 26
11 changes: 6 additions & 5 deletions build-deps.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
autoconf
automake
bison
libjson-c-dev
build-essential
clang-16
clang-19
cmake
docbook-xml
docbook5-xml
docbook-xml
flex
gettext
git
Expand All @@ -18,11 +17,12 @@ libgdal-dev
libgeos-dev
libgmp-dev
libipc-run-perl
libjson-c-dev
libkrb5-dev
libldap-dev
liblz4-dev
libnuma-dev
libpam0g-dev
libpcre3-dev
libperl-dev
libproj-dev
libprotobuf-c-dev
Expand All @@ -34,10 +34,11 @@ libssl-dev
libsystemd-dev
libtiff-dev
libtool
liburing-dev
libxml2-utils
libxslt1-dev
libzstd-dev
llvm-16-dev
llvm-19-dev
pkg-config
protobuf-c-compiler
python3-dev
Expand Down
2 changes: 1 addition & 1 deletion defaults.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"PG_IMAGE": "ghcr.io/cloudnative-pg/postgresql-trunk:19-minimal-bookworm",
"PG_IMAGE": "ghcr.io/cloudnative-pg/postgresql-trunk:19-minimal-trixie",
"PG_MAJOR": 19,
"CNPG_BRANCH": "main",
"TEST_DEPTH": 4,
Expand Down