Skip to content

Commit ea61db8

Browse files
committed
fix: migrate away from deprecated bitnami image
BREAKING CHANGE: dropping support for postgres 13 BREAKING CHANGE: switching to official postgres image with alpine base
1 parent b468b1c commit ea61db8

File tree

4 files changed

+69
-26
lines changed

4 files changed

+69
-26
lines changed

.github/workflows/build-and-publish.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@ jobs:
1616
build:
1717
strategy:
1818
matrix:
19-
postgres_version: [13, 14, 15, 16, 17]
19+
postgres_version: [14, 15, 16, 17]
2020
major: [4,5]
2121
include:
2222
- partman_version: v4.7.4
2323
partman_checksum: 28e4fdb83ecc16525959ae9593bfbfd077db429285f5f7d8e2468bfff6cbdbf2c81ace79a9ddeb4f00f51eb709163dbd713fe6b221a432ac2ff766f98d4cf8e4
24-
default: "true"
24+
default: "false"
2525
major: 4
2626
- partman_version: v5.2.4
2727
partman_checksum: 8328a00ce1a55a5c9173d4adbf251e784fed62413fb76bba89dd893749a720a5ecb25ee668eb0b826b8e1f2b89d9dd7da219fd797bfd9ab1a43d05f5b3ac494f
28-
default: "false"
28+
default: "true"
2929
major: 5
30-
exclude:
31-
- major: 5
32-
postgres_version: 13 # partman 5.x does not support postgres 13
3330
runs-on: ubuntu-latest
3431
permissions:
3532
contents: read
@@ -63,7 +60,7 @@ jobs:
6360
with:
6461
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
6562
tags: |
66-
type=raw,value=latest,enable=${{ matrix.postgres_version == '15' && matrix.default == 'true' }}
63+
type=raw,value=latest,enable=${{ matrix.postgres_version == '17' && matrix.default == 'true' }}
6764
type=raw,value=${{ matrix.postgres_version }},enable=${{ matrix.default == 'true'}}
6865
${{ matrix.postgres_version }}-${{ matrix.major }}
6966

Dockerfile

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
ARG POSTGRESQL_VERSION="16"
1+
ARG POSTGRESQL_VERSION="17"
22
ARG JOBMON_VERSION="v1.4.1"
33
ARG PARTMAN_VERSION="v5.2.4"
44

5-
FROM bitnami/postgresql:$POSTGRESQL_VERSION AS builder
5+
FROM postgres:$POSTGRESQL_VERSION-alpine AS builder
66
LABEL org.opencontainers.image.source="https://github.com/dbsystel/postgresql-partman-container"
77
ARG JOBMON_VERSION
88
LABEL de.dbsystel.jobmon-version=$JOBMON_VERSION
@@ -14,24 +14,21 @@ ARG JOBMON_CHECKSUM="db67c068ecdc136305eafb25bd8fc737f6b9944d4ef3d59ecf700693368
1414
ARG PARTMAN_CHECKSUM="8328a00ce1a55a5c9173d4adbf251e784fed62413fb76bba89dd893749a720a5ecb25ee668eb0b826b8e1f2b89d9dd7da219fd797bfd9ab1a43d05f5b3ac494f"
1515
USER root
1616

17-
RUN install_packages wget gcc make build-essential \
18-
&& export C_INCLUDE_PATH=/opt/bitnami/postgresql/include/:/opt/bitnami/common/include/ \
19-
&& export LIBRARY_PATH=/opt/bitnami/postgresql/lib/:/opt/bitnami/common/lib/ \
20-
&& export LD_LIBRARY_PATH=/opt/bitnami/postgresql/lib/:/opt/bitnami/common/lib/
17+
RUN apk add --no-cache wget gcc make musl-dev postgresql-dev $DOCKER_PG_LLVM_DEPS
2118

2219
RUN wget "https://github.com/omniti-labs/pg_jobmon/archive/refs/tags/${JOBMON_VERSION}.tar.gz" \
23-
&& echo "${JOBMON_CHECKSUM} ${JOBMON_VERSION}.tar.gz" | sha512sum --check \
20+
&& echo "${JOBMON_CHECKSUM} ${JOBMON_VERSION}.tar.gz" | sha512sum -c \
2421
&& tar zxf ${JOBMON_VERSION}.tar.gz && cd pg_jobmon-${JOBMON_VERSION#v}\
2522
&& make \
2623
&& make install
2724

2825
RUN wget "https://github.com/pgpartman/pg_partman/archive/refs/tags/${PARTMAN_VERSION}.tar.gz" \
29-
&& echo "${PARTMAN_CHECKSUM} ${PARTMAN_VERSION}.tar.gz" | sha512sum --check \
26+
&& echo "${PARTMAN_CHECKSUM} ${PARTMAN_VERSION}.tar.gz" | sha512sum -c \
3027
&& tar zxf ${PARTMAN_VERSION}.tar.gz && cd pg_partman-${PARTMAN_VERSION#v}\
3128
&& make \
3229
&& make install
3330

34-
FROM bitnami/postgresql:$POSTGRESQL_VERSION
31+
FROM postgres:$POSTGRESQL_VERSION-alpine
3532
LABEL org.opencontainers.image.source="https://github.com/dbsystel/postgresql-partman-container"
3633
ARG JOBMON_VERSION
3734
LABEL de.dbsystel.jobmon-version=$JOBMON_VERSION
@@ -40,8 +37,9 @@ LABEL de.dbsystel.partman-version=$PARTMAN_VERSION
4037
ARG POSTGRESQL_VERSION
4138
LABEL de.dbsystel.postgres-version=$POSTGRESQL_VERSION
4239

43-
COPY --from=builder pg_jobmon-${JOBMON_VERSION#v}/sql/pg_jobmon--${JOBMON_VERSION#v}.sql pg_jobmon-${JOBMON_VERSION#v}/pg_jobmon.control pg_partman-${PARTMAN_VERSION#v}/sql/pg_partman--${PARTMAN_VERSION#v}.sql pg_partman-${PARTMAN_VERSION#v}/pg_partman.control /opt/bitnami/postgresql/share/extension/
44-
COPY --from=builder /opt/bitnami/postgresql/lib/pg_partman_bgw.so /opt/bitnami/postgresql/lib/pg_partman_bgw.so
45-
COPY --from=builder pg_partman-${PARTMAN_VERSION#v}/bin/common/* /opt/bitnami/lib/postgresql/bin/
40+
COPY --from=builder /usr/local/share/postgresql/extension/pg_jobmon* /usr/local/share/postgresql/extension/
41+
COPY --from=builder /usr/local/share/postgresql/extension/pg_partman* /usr/local/share/postgresql/extension/
42+
COPY --from=builder /usr/local/lib/postgresql/pg_partman_bgw.so /usr/local/lib/postgresql/
43+
COPY --from=builder pg_partman-*/bin/common/* /usr/local/bin/
4644

47-
USER 1001
45+
USER postgres

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,41 @@
11
# PostgreSQL container image with pg_partman
22

3-
This repo is meant to provide an OCI (Docker) container image that is based on the popular [bitnami/postgresql](https://hub.docker.com/r/bitnami/postgresql) image, that comes preinstalled with the [pg_partman](https://github.com/pgpartman/pg_partman) and [pg_jobmon](https://github.com/omniti-labs/pg_jobmon) PostgreSQL extensions.
3+
This repo is meant to provide an OCI (Docker) container image that is based on the official [postgres](https://hub.docker.com/_/postgres) image in the alpine variant, that comes preinstalled with the [pg_partman](https://github.com/pgpartman/pg_partman) and [pg_jobmon](https://github.com/omniti-labs/pg_jobmon) PostgreSQL extensions.
44

55
It pushes a nightly latest image of all tag versions to [ghcr.io](https://github.com/orgs/dbsystel/packages/container/package/postgresql-partman)
66

77
## Usage
88

99
```shell
1010
docker run ghcr.io/dbsystel/postgresql-partman
11-
docker run ghcr.io/dbsystel/postgresql-partman:{13,14,15,16,17}
12-
docker run ghcr.io/dbsystel/postgresql-partman:{13-4,14-4,15-4,16-4,17-4}
11+
docker run ghcr.io/dbsystel/postgresql-partman:{14,15,16,17}
12+
docker run ghcr.io/dbsystel/postgresql-partman:{14-4,15-4,16-4,17-4}
1313
docker run ghcr.io/dbsystel/postgresql-partman:{14-5,15-5,16-5,17-5}
1414
```
1515

1616
The first part of the tag represents the PostgreSQL major version, the second part represents the partman major version. If you leave out the second part, you will get the default version of partman as specified by this repository. Be aware, that this can change without notice.
1717

1818
You can find out the actual versions used by looking at the labels of an image.
1919

20-
`docker inspect ghcr.io/dbsystel/postgresql-partman:13`
20+
`docker inspect ghcr.io/dbsystel/postgresql-partman:17`
2121

2222
````
23-
"de.dbsystel.partman-version" : "v4.7.4",
24-
"de.dbsystel.postgres-version" : "13",
23+
"de.dbsystel.partman-version" : "v5.2.4",
24+
"de.dbsystel.postgres-version" : "17",
2525
````
2626

27+
## Development
28+
29+
### test-build.sh
30+
31+
The `test-build.sh` script builds all PostgreSQL and partman version combinations locally for testing purposes. It extracts version information from the GitHub workflow to ensure consistency.
32+
33+
```shell
34+
./test-build.sh
35+
```
36+
37+
This builds Docker images for all supported PostgreSQL versions with both partman v4 and v5, tagged as `test-partman:{pg_version}-{partman_major}`.
38+
2739
## License
2840

2941
This project is licensed under the Apache-2.0 license, see [LICENSE](LICENSE).

test-build.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Test build script for all PostgreSQL versions and partman combinations
4+
# Extracts versions and checksums from GitHub workflow to stay DRY
5+
6+
set -e
7+
8+
# Extract data from workflow file
9+
WORKFLOW_FILE=".github/workflows/build-and-publish.yml"
10+
11+
# Parse PostgreSQL versions
12+
POSTGRES_VERSIONS=($(yq '.jobs.build.strategy.matrix.postgres_version[]' $WORKFLOW_FILE))
13+
14+
# Parse partman versions and checksums
15+
PARTMAN_V4_VERSION=$(yq '.jobs.build.strategy.matrix.include[] | select(.major == 4) | .partman_version' $WORKFLOW_FILE)
16+
PARTMAN_V4_CHECKSUM=$(yq '.jobs.build.strategy.matrix.include[] | select(.major == 4) | .partman_checksum' $WORKFLOW_FILE)
17+
PARTMAN_V5_VERSION=$(yq '.jobs.build.strategy.matrix.include[] | select(.major == 5) | .partman_version' $WORKFLOW_FILE)
18+
PARTMAN_V5_CHECKSUM=$(yq '.jobs.build.strategy.matrix.include[] | select(.major == 5) | .partman_checksum' $WORKFLOW_FILE)
19+
20+
for pg_version in "${POSTGRES_VERSIONS[@]}"; do
21+
echo "Building PostgreSQL $pg_version with partman v5..."
22+
docker build \
23+
--build-arg POSTGRESQL_VERSION=$pg_version \
24+
--build-arg PARTMAN_VERSION=$PARTMAN_V5_VERSION \
25+
--build-arg PARTMAN_CHECKSUM=$PARTMAN_V5_CHECKSUM \
26+
-t test-partman:$pg_version-5 .
27+
28+
echo "Building PostgreSQL $pg_version with partman v4..."
29+
docker build \
30+
--build-arg POSTGRESQL_VERSION=$pg_version \
31+
--build-arg PARTMAN_VERSION=$PARTMAN_V4_VERSION \
32+
--build-arg PARTMAN_CHECKSUM=$PARTMAN_V4_CHECKSUM \
33+
-t test-partman:$pg_version-4 .
34+
done
35+
36+
echo "All builds completed successfully!"

0 commit comments

Comments
 (0)