Skip to content

Commit 0c4aa59

Browse files
committed
feat: Upgrade to postgres 15
Remove pg_squeeze as it causes issues during upgrades
1 parent fcdb111 commit 0c4aa59

File tree

3 files changed

+25
-34
lines changed

3 files changed

+25
-34
lines changed

Dockerfile

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,43 +20,39 @@ RUN set -e \
2020
# Alias gosu as the scripts are still used for alpine linux
2121
ln -s /usr/sbin/gosu /usr/sbin/su-exec && \
2222
>&2 echo "Install Postgres" && \
23-
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main 14" > /etc/apt/sources.list.d/pgdg.list' && \
23+
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main 15" > /etc/apt/sources.list.d/pgdg.list' && \
2424
sh -c 'curl -s https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -' && \
2525
apt-get update && \
2626
apt-get install -y --no-install-recommends postgresql-common && \
2727
sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf && \
28-
apt-get install -y --no-install-recommends "postgresql-14=14.5-1.pgdg110+1" && \
28+
apt-get install -y --no-install-recommends "postgresql-15=15.0-1.pgdg110+1" && \
2929
>&2 echo 'Install pg_auto_failover' && \
30-
apt-get install -y pg-auto-failover-cli postgresql-14-auto-failover && \
30+
apt-get install -y pg-auto-failover-cli postgresql-15-auto-failover && \
3131
>&2 echo 'Install wal-g' && \
32-
curl -s -L https://github.com/wal-g/wal-g/releases/download/v2.0.0/wal-g-pg-ubuntu-18.04-amd64 > /usr/local/bin/wal-g && \
32+
curl -s -L https://github.com/wal-g/wal-g/releases/download/v2.0.1/wal-g-pg-ubuntu-18.04-amd64 > /usr/local/bin/wal-g && \
3333
chmod +x /usr/local/bin/wal-g && \
3434
# We need to have locales enabled for postgres
3535
grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker && \
3636
sed -ri '/\/usr\/share\/locale/d' /etc/dpkg/dpkg.cfg.d/docker && \
3737
! grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker && \
3838
apt-get update; apt-get install -y --no-install-recommends locales && \
3939
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 && \
40-
>&2 echo "Install pg_squeeze" && \
41-
apt-get install -y postgresql-server-dev-14 build-essential && \
42-
git clone https://github.com/cybertec-postgresql/pg_squeeze.git /tmp/pg_squeeze && \
43-
cd /tmp/pg_squeeze && git checkout REL1_4 && make && make install && \
4440
>&2 echo "Cleanup" && \
45-
apt-get purge -y --auto-remove apt-transport-https gnupg git postgresql-server-dev-14 build-essential && \
41+
apt-get purge -y --auto-remove apt-transport-https gnupg git postgresql-server-dev-15 build-essential && \
4642
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/log/*
4743

4844
USER postgres
49-
ENV PG_MAJOR=14
45+
ENV PG_MAJOR=15
5046
ENV PGUSER=postgres
5147
ENV PGHOST /var/run/postgresql
5248
ENV PGPORT 5432
5349
ENV PGDATA /var/lib/postgresql/data
5450
ENV PAGER 'pspg -s 0'
55-
ENV PATH="$PATH:/usr/lib/postgresql/14/bin:/scripts"
51+
ENV PATH="$PATH:/usr/lib/postgresql/15/bin:/scripts"
5652
ENV WALG_CONFIG_FILE=/var/lib/postgresql/.walg.json
5753
ENV LANG en_US.utf8
5854

59-
COPY --from=postgres:14 /usr/local/bin/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
55+
COPY --from=postgres:15 /usr/local/bin/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
6056
ADD ./scripts /scripts
6157

6258
STOPSIGNAL SIGINT

Dockerfile.upgrade

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
FROM livingdocs/postgres:14.5
1+
FROM livingdocs/postgres:15.0
22
USER root
33
RUN set -e \
44
export DEBIAN_FRONTEND=noninteractive && \
5-
apt-get update && apt-get install -y git build-essential postgresql-9.6 postgresql-11 postgresql-12 postgresql-13 postgresql-server-dev-12 postgresql-server-dev-13 && \
6-
# Install pg_squeeze
7-
git clone https://github.com/cybertec-postgresql/pg_squeeze.git /tmp/pg_squeeze && \
8-
cd /tmp/pg_squeeze && git checkout REL1_4 && \
9-
export PATH="/usr/lib/postgresql/12/bin:$PATH" && make && make install && \
10-
export PATH="/usr/lib/postgresql/13/bin:$PATH" && make && make install && \
5+
apt-get update && apt-get install -y git build-essential postgresql-9.6 postgresql-11 postgresql-12 postgresql-13 postgresql-14 && \
116
# Cleanup
12-
apt-get purge -y --auto-remove apt-transport-https git postgresql-server-dev-12 postgresql-server-dev-13 build-essential && \
7+
apt-get purge -y --auto-remove apt-transport-https git postgresql-server-dev-12 postgresql-server-dev-13 postgresql-server-dev-14 build-essential && \
138
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/log/*
149

1510
STOPSIGNAL SIGINT

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# [Postgres 14.5](https://github.com/livingdocsIO/dockerfile-postgres) [![](https://shields.beevelop.com/docker/pulls/livingdocs/postgres.svg?style=flat-square)](https://hub.docker.com/r/livingdocs/postgres)
1+
# [Postgres 15.0](https://github.com/livingdocsIO/dockerfile-postgres) [![](https://shields.beevelop.com/docker/pulls/livingdocs/postgres.svg?style=flat-square)](https://hub.docker.com/r/livingdocs/postgres)
22

33
- Based on Debian
4-
- Includes `postgres-contrib`, enables the extensions `pg_stat_statements` and `pg_squeeze` by default
4+
- Includes `postgres-contrib`, enables the extensions `pg_stat_statements` by default
55
- Includes [wal-g](https://github.com/wal-g/wal-g) for WAL archiving and shipping
66
- Includes [pg_auto_failover](https://github.com/citusdata/pg_auto_failover) for automatic failover
77
- Runs as postgres user with uid (1000), gid (1000)
@@ -13,40 +13,40 @@
1313

1414
```bash
1515
# Secured with a password, by default the image is secure
16-
docker run -d --name postgres -p 5432:5432 -v postgres:/var/lib/postgresql -e POSTGRES_PASSWORD=somepassword livingdocs/postgres:14.5
16+
docker run -d --name postgres -p 5432:5432 -v postgres:/var/lib/postgresql -e POSTGRES_PASSWORD=somepassword livingdocs/postgres:15.0
1717
```
1818

1919
## Upgrade an existing postgres container
2020

2121
```bash
2222
# Let's assume you've created a container previously
23-
docker run -d --name postgres -p 5432:5432 -v postgres:/var/lib/postgresql livingdocs/postgres:13.4
23+
docker run -d --name postgres -p 5432:5432 -v postgres:/var/lib/postgresql livingdocs/postgres:14.5
2424

2525
# First stop it, then run the upgrade image
2626
docker stop postgres
27-
docker run --rm -v postgres:/var/lib/postgresql livingdocs/postgres:14.5-upgrade
27+
docker run --rm -v postgres:/var/lib/postgresql livingdocs/postgres:15.0-upgrade
2828

2929
# After it succeeds, you can run the new image and mount the existing volume
30-
docker run -d --name postgres -p 5432:5432 -v postgres:/var/lib/postgresql livingdocs/postgres:14.5
30+
docker run -d --name postgres -p 5432:5432 -v postgres:/var/lib/postgresql livingdocs/postgres:15.0
3131
```
3232

3333
## To build this image manually
3434

3535
```bash
36-
docker build -t livingdocs/postgres:14.5 .
36+
docker build -t livingdocs/postgres:15.0 .
3737

3838
# To build and push the multi-arch manifest to docker hub
39-
docker buildx build --platform linux/amd64,linux/arm64 -t livingdocs/postgres:14.5 --push .
40-
docker buildx build --platform linux/amd64,linux/arm64 -t livingdocs/postgres:14.5-upgrade --push -f Dockerfile.upgrade .
39+
docker buildx build --platform linux/amd64,linux/arm64 -t livingdocs/postgres:15.0 --push .
40+
docker buildx build --platform linux/amd64,linux/arm64 -t livingdocs/postgres:15.0-upgrade --push -f Dockerfile.upgrade .
4141
```
4242

4343
## Set up streaming replication
4444

4545
### Simple setup
4646
```bash
4747
# Create the containers
48-
docker run -d -p 5433:5432 --name postgres-1 livingdocs/postgres:14.5
49-
docker run -d -p 5434:5432 --name postgres-2 livingdocs/postgres:14.5 standby -d "host=host.docker.internal port=5433 user=postgres target_session_attrs=read-write"
48+
docker run -d -p 5433:5432 --name postgres-1 livingdocs/postgres:15.0
49+
docker run -d -p 5434:5432 --name postgres-2 livingdocs/postgres:15.0 standby -d "host=host.docker.internal port=5433 user=postgres target_session_attrs=read-write"
5050

5151
# Test the replication
5252
docker exec postgres-1 psql -c "CREATE TABLE hello (value text); INSERT INTO hello(value) VALUES('world');"
@@ -64,7 +64,7 @@ docker exec postgres-2 psql -c "SELECT * FROM hello;"
6464
docker network create local
6565

6666
# First create the database primary
67-
docker run -d -p 5433:5432 --name postgres-1 --network=local --network-alias=postgres -e POSTGRES_HOST_AUTH_METHOD=md5 livingdocs/postgres:14.5
67+
docker run -d -p 5433:5432 --name postgres-1 --network=local --network-alias=postgres -e POSTGRES_HOST_AUTH_METHOD=md5 livingdocs/postgres:15.0
6868

6969
# Create the users on database intialization
7070
# You could also mount an sql or script into /var/lib/postgresql/initdb.d during cluster startup to execute the script automatically.
@@ -73,8 +73,8 @@ docker exec postgres-1 psql -c "CREATE USER replication REPLICATION LOGIN ENCRYP
7373

7474
# The launch the replicas
7575
export DB_URL="host=postgres port=5432 user=replication password=some-replication-password target_session_attrs=read-write"
76-
docker run -d -p 5434:5432 --name postgres-2 --network=local --network-alias=postgres livingdocs/postgres:14.5 standby -d $DB_URL
77-
docker run -d -p 5435:5432 --name postgres-3 --network=local --network-alias=postgres livingdocs/postgres:14.5 standby -d $DB_URL
76+
docker run -d -p 5434:5432 --name postgres-2 --network=local --network-alias=postgres livingdocs/postgres:15.0 standby -d $DB_URL
77+
docker run -d -p 5435:5432 --name postgres-3 --network=local --network-alias=postgres livingdocs/postgres:15.0 standby -d $DB_URL
7878

7979
# Test the replication
8080
docker exec postgres-1 psql -c "CREATE TABLE hello (value text); INSERT INTO hello(value) VALUES('hello');"

0 commit comments

Comments
 (0)