Skip to content

Commit fdc8010

Browse files
sxdNiccoloFeigbartolinimnencia
authored
chore: add system images to docker-bake.hcl (#282)
This change extends the bake build process by introducing the system image flavour. The system image is derived from the existing standard image and includes Barman Cloud support. Closes #283 Closes #286 Signed-off-by: Jonathan Gonzalez V <jonathan.gonzalez@enterprisedb.com> Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com> Signed-off-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com> Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com> Co-authored-by: Niccolò Fei <niccolo.fei@enterprisedb.com> Co-authored-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com> Co-authored-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
1 parent 3ea0821 commit fdc8010

6 files changed

Lines changed: 173 additions & 67 deletions

File tree

.github/workflows/bake.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Bake Images
2+
3+
on:
4+
schedule:
5+
# Build images once a week, on Mondays
6+
- cron: 0 8 * * 1
7+
workflow_dispatch:
8+
inputs:
9+
environment:
10+
type: choice
11+
options:
12+
- testing
13+
- production
14+
default: testing
15+
description: "Choose the environment to bake the target for"
16+
17+
permissions: {}
18+
19+
jobs:
20+
get_versions:
21+
name: Get PostgreSQL versions
22+
runs-on: ubuntu-24.04
23+
permissions:
24+
contents: read
25+
outputs:
26+
versions: ${{ steps.get_versions.outputs.versions }}
27+
steps:
28+
- name: Checkout Code
29+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
30+
31+
- name: Get supported PostgreSQL versions
32+
id: get_versions
33+
run: |
34+
VERSIONS="$(sed -n '/postgreSQLVersions = \[/,/\]/ s/.*"\(.*\)\..*".*/\"\1\"/p' docker-bake.hcl | xargs echo | tr ' ' ',')"
35+
echo "PostgreSQL versions: [$VERSIONS]"
36+
echo "versions=[$VERSIONS]" >> "$GITHUB_OUTPUT"
37+
38+
Bake:
39+
name: Bake
40+
needs: get_versions
41+
permissions:
42+
packages: write
43+
contents: read
44+
id-token: write
45+
security-events: write
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
version: ${{ fromJson(needs.get_versions.outputs.versions) }}
50+
uses: ./.github/workflows/bake_targets.yml
51+
with:
52+
environment: ${{ github.event.inputs.environment }}
53+
postgresql_version: ${{ matrix.version }}
Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
1-
name: Bake images
1+
name: Build target images
22

33
on:
4-
schedule:
5-
- cron: 0 8 * * 1
6-
workflow_dispatch:
4+
workflow_call:
75
inputs:
86
environment:
9-
type: choice
10-
options:
11-
- testing
12-
- production
13-
default: testing
14-
description: "Choose the environment to bake the images for"
15-
target:
7+
description: "The environment to build for"
8+
required: true
9+
type: string
10+
default: "testing"
11+
postgresql_version:
12+
description: "The PostgreSQL major version to bake"
13+
required: true
1614
type: string
17-
default: ""
18-
description: "A comma separated list of targets to build. If empty, all targets will be built."
1915

20-
permissions: read-all
16+
permissions: {}
2117

2218
jobs:
23-
# Start by building images for testing. We want to run security checks before pushing those to production.
2419
testbuild:
25-
name: Build for testing
26-
runs-on: ubuntu-latest
20+
# Start by building images for testing. We want to run security checks before pushing those to production.
21+
name: PostgreSQL ${{ inputs.postgresql_version }}
22+
runs-on: ubuntu-24.04
2723
permissions:
2824
contents: read
2925
packages: write
30-
security-events: write
3126
# Required by the cosign step
3227
id-token: write
3328
outputs:
@@ -37,6 +32,19 @@ jobs:
3732
- name: Checkout Code
3833
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
3934

35+
- name: List targets
36+
id: targets
37+
uses: docker/bake-action/subaction/matrix@v6
38+
with:
39+
target: "default"
40+
41+
- name: Filter by versions
42+
id: extract_targets
43+
run: |
44+
target=$(echo '${{ steps.targets.outputs.matrix }}' | jq -r '.[] | .[] | select(match("${{ inputs.postgresql_version }}"))' | xargs echo | sed 's/ /,/g')
45+
echo "Targets for PostgreSQL ${{ inputs.postgresql_version }}: $target"
46+
echo "filtered_targets=$target" >> "$GITHUB_OUTPUT"
47+
4048
- name: Log in to the GitHub Container registry
4149
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3
4250
with:
@@ -63,7 +71,7 @@ jobs:
6371
revision: ${{ github.sha }}
6472
with:
6573
push: true
66-
targets: ${{ github.event.inputs.target }}
74+
targets: ${{ steps.extract_targets.outputs.filtered_targets }}
6775

6876
# Get a list of the images that were built and pushed. We only care about a single tag for each image.
6977
- name: Generated images
@@ -86,6 +94,10 @@ jobs:
8694
security:
8795
name: Security checks
8896
runs-on: ubuntu-latest
97+
permissions:
98+
contents: read
99+
packages: read
100+
security-events: write
89101
needs:
90102
- testbuild
91103
strategy:
@@ -107,6 +119,9 @@ jobs:
107119
with:
108120
image: ${{ matrix.image }}
109121
exit-code: '1'
122+
failure-threshold: WARN
123+
accept-keywords: key
124+
accept-filenames: usr/share/postgresql-common/pgdg/apt.postgresql.org.asc,etc/ssl/private/ssl-cert-snakeoil.key,usr/local/lib/python3.9/dist-packages/azure/core/settings.py,usr/local/lib/python3.11/dist-packages/azure/core/settings.py,usr/local/lib/python3.13/dist-packages/azure/core/settings.py
110125

111126
- name: Snyk
112127
uses: snyk/actions/docker@master

BUILD.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ docker buildx bake --push
7373
7474
If you want to limit the build to a specific combination, you can specify the
7575
target in the `VERSION-TYPE-BASE` format. For example, to build an image for
76-
PostgreSQL 17 with the `minimal` format on the `bookworm` base image:
76+
PostgreSQL 17 with the `minimal` format on the `trixie` base image:
7777

7878
```bash
79-
docker buildx bake --push postgresql-17-minimal-bookworm
79+
docker buildx bake --push postgresql-17-minimal-trixie
8080
```
8181

8282
You can also limit the build to a single platform, for example AMD64, with:
@@ -90,7 +90,7 @@ The two can be mixed as well:
9090
```bash
9191
docker buildx bake --push \
9292
--set "*.platform=linux/amd64" \
93-
postgresql-17-minimal-bookworm
93+
postgresql-17-minimal-trixie
9494
```
9595

9696
## The Distribution Registry

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,25 @@ RUN apt-get update && \
2929
rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*
3030

3131
USER 26
32+
33+
FROM standard AS system
34+
ARG BARMAN_VERSION
35+
36+
# We need to break the system packages to install barman-cloud in bookworm and later
37+
ENV PIP_BREAK_SYSTEM_PACKAGES=1
38+
39+
USER root
40+
RUN apt-get update && \
41+
apt-get install -y --no-install-recommends \
42+
# We require build-essential and python3-dev to build lz4 on arm64 since there isn't a pre-compiled wheel available
43+
build-essential python3-dev \
44+
python3-pip \
45+
python3-psycopg2 \
46+
python3-setuptools \
47+
&& \
48+
pip3 install --no-cache-dir barman[cloud,azure,snappy,google,zstandard,lz4]==${BARMAN_VERSION} && \
49+
apt-get remove -y --purge --autoremove build-essential python3-dev && \
50+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
51+
rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/*
52+
53+
USER 26

README.md

Lines changed: 54 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
[![CloudNativePG](./logo/cloudnativepg.png)](https://cloudnative-pg.io/)
22

3-
> **IMPORTANT:** As of January 2025, we have transitioned to a new image build
4-
> process (see issue [#132](https://github.com/cloudnative-pg/postgres-containers/issues/132)
5-
> for details). Previously, the images were based on the
6-
> [Official Postgres image](https://hub.docker.com/_/postgres), maintained by the
7-
> [PostgreSQL Docker Community](https://github.com/docker-library/postgres),
8-
> and included Barman Cloud built from source.
9-
> This legacy approach, referred to as `system` images, will remain available
10-
> for backward compatibility but is planned for a future deprecation.
3+
> **IMPORTANT:** Starting in August 2025, the [Official Postgres Image](https://hub.docker.com/_/postgres),
4+
> maintained by the [PostgreSQL Docker Community](https://github.com/docker-library/postgres),
5+
> has discontinued support for Debian `bullseye`.
6+
> In response, the CloudNativePG project has completed the transition to the
7+
> new `bake`-based build process for all `system` images. We now build directly
8+
> on top of the official Debian slim images, fully detaching from the official
9+
> Postgres image. Additional changes are planned as part of epic #287.
1110
1211
---
1312

@@ -23,31 +22,52 @@ within Kubernetes environments.
2322

2423
## Key Features
2524

26-
The CNPG PostgreSQL Container Images:
25+
CloudNativePG PostgreSQL container images:
2726

28-
- Are based on Debian Linux `stable` and `oldstable`
29-
- Support **multi-architecture builds**, including `linux/amd64` and
27+
- Are built on top of **Debian Linux** (`stable` and `oldstable`).
28+
- Provide **multi-architecture support**, including `linux/amd64` and
3029
`linux/arm64`.
31-
- Include **build attestations**, such as Software Bills of Materials (SBOMs)
30+
- Ship with **build attestations**, such as Software Bills of Materials (SBOMs)
3231
and provenance metadata.
33-
- Are published on the
34-
[CloudNativePG GitHub Container Registry](https://github.com/cloudnative-pg/postgres-containers/pkgs/container/postgresql).
35-
- Are **automatically rebuilt weekly** (every Monday) to ensure they remain
36-
up-to-date.
32+
- Are published in the [CloudNativePG GitHub Container Registry](https://github.com/cloudnative-pg/postgres-containers/pkgs/container/postgresql).
33+
- Are **automatically rebuilt every week** (on Mondays) to remain up to date
34+
with the latest upstream security and bug fixes.
35+
36+
## Debian Releases
37+
38+
CloudNativePG PostgreSQL container images are based on the official `stable`
39+
and `oldstable` Debian releases, maintained and supported by the
40+
[Debian Project](https://www.debian.org/releases/).
41+
42+
The table below summarises the support lifecycle of relevant Debian versions,
43+
including End-of-Life (EOL) and Long-Term Support (LTS) dates.
44+
45+
| Name | Version | Release Date | EOL | LTS | Status |
46+
| ------------------------- | :-----: | :----------: | :--------: | :--------: | :--------- |
47+
| Trixie (`stable`) | 13 | 2025-08-09 | 2028-08-09 | 2030-06-30 | Supported |
48+
| Bookworm (`oldstable`) | 12 | 2023-06-10 | 2026-06-10 | 2028-06-30 | Supported |
49+
| Bullseye (`oldoldstable`) | 11 | 2021-08-14 | 2024-08-14 | 2026-08-31 | Deprecated |
50+
51+
> **IMPORTANT:** The CloudNativePG project provides full support for
52+
> Debian-based images until each release reaches its official End-of-Life
53+
> (EOL). After EOL and until the start of Long-Term Support (LTS), images for the
54+
> deprecated releases, such as `oldoldstable`, are maintained on a
55+
> **best-effort basis**. If discontinuation becomes necessary before the LTS
56+
> date, a minimum **three-month advance notice** will be posted on this page.
3757
3858
## Image Types
3959

40-
We currently build and support two primary types of PostgreSQL images:
60+
We currently provide and maintain three main types of PostgreSQL images:
4161

42-
- [`minimal`](#minimal-images)
43-
- [`standard`](#standard-images)
62+
* [`minimal`](#minimal-images)
63+
* [`standard`](#standard-images)
64+
* [`system`](#system-images) (*deprecated*)
4465

45-
Both `minimal` and `standard` images are intended to be used with backup
46-
plugins, such as [Barman Cloud](https://github.com/cloudnative-pg/plugin-barman-cloud).
66+
Both `minimal` and `standard` images are designed to work with backup plugins
67+
such as [Barman Cloud](https://github.com/cloudnative-pg/plugin-barman-cloud).
4768

48-
> **Note:** for backward compatibility, we also maintain the
49-
> [`system`](#system-images) image type. Switching from `system` images to
50-
> `minimal` or `standard` images on an existing cluster is not supported.
69+
The `system` images, built on top of the `standard` ones, also include the
70+
Barman Cloud binaries.
5171

5272
### Minimal Images
5373

@@ -57,7 +77,7 @@ They use the [APT PostgreSQL packages](https://wiki.postgresql.org/wiki/Apt)
5777
maintained by the PostgreSQL Global Development Group (PGDG).
5878

5979
These images are identified by the inclusion of `minimal` in their tag names,
60-
for example: `17.2-minimal-bookworm`.
80+
for example: `17.6-minimal-trixie`.
6181

6282
### Standard Images
6383

@@ -70,33 +90,23 @@ following additional features:
7090
- All Locales
7191

7292
Standard images are identifiable by the `standard` tag in their names, such as:
73-
`17.2-standard-bookworm`.
93+
`17.6-standard-trixie`.
7494

7595
> **Note:** Standard images are designed to offer functionality equivalent to
7696
> the legacy `system` images when used with CloudNativePG. To achieve parity,
7797
> you must use the [Barman Cloud Plugin](https://github.com/cloudnative-pg/plugin-barman-cloud)
7898
> as a replacement for the native Barman Cloud support in `system` images.
7999
80-
### System Images
81-
82-
System images are based on the [Official Postgres image](https://hub.docker.com/_/postgres),
83-
maintained by the
84-
[PostgreSQL Docker Community](https://github.com/docker-library/postgres).
85-
These images include additional software to extend PostgreSQL functionality:
86-
87-
- Barman Cloud
88-
- PGAudit
89-
- Postgres Failover Slots
90-
- pgvector
100+
### System Images (deprecated)
91101

92-
The [`Debian`](Debian) folder contains image catalogs, which can be used as:
93-
- [`ClusterImageCatalog`](https://cloudnative-pg.io/documentation/current/image_catalog/)
94-
- [`ImageCatalog`](https://cloudnative-pg.io/documentation/current/image_catalog/)
102+
Starting from September 2025, system images are based on the `standard` image
103+
and include Barman Cloud binaries.
95104

96-
> **Deprecation Notice:** System images and the associated Debian-based image
97-
> catalogs will be deprecated in future releases of CloudNativePG and
98-
> eventually removed. Users are encouraged to migrate to `minimal` or
99-
> `standard` images for new clusters as soon as feasible.
105+
> **IMPORTANT:** The `system` images are deprecated and will be removed once
106+
> in-core support for Barman Cloud in CloudNativePG is phased out. While you
107+
> can still use them as long as in-core Barman Cloud remains available, you
108+
> should plan to migrate to either a `minimal` or `standard` image together
109+
> with the Barman Cloud plugin—or adopt another supported backup solution.
100110
101111
## Build Attestations
102112

docker-bake.hcl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ postgreSQLVersions = [
2929
"17.6"
3030
]
3131

32+
// Barman version to build
33+
# renovate: datasource=github-releases depName=EnterpriseDB/barman versioning=loose
34+
barmanVersion = "3.14.0"
35+
3236
extensions = [
3337
"pgaudit",
3438
"pgvector",
@@ -39,7 +43,8 @@ target "default" {
3943
matrix = {
4044
tgt = [
4145
"minimal",
42-
"standard"
46+
"standard",
47+
"system"
4348
]
4449
pgVersion = postgreSQLVersions
4550
base = [
@@ -69,6 +74,7 @@ target "default" {
6974
PG_MAJOR = "${getMajor(pgVersion)}"
7075
BASE = "${base}"
7176
EXTENSIONS = "${getExtensionsString(pgVersion, extensions)}"
77+
BARMAN_VERSION = "${barmanVersion}"
7278
}
7379
attest = [
7480
"type=provenance,mode=max",

0 commit comments

Comments
 (0)