Skip to content

Commit bf9eb4b

Browse files
authored
Merge pull request #365 from s01ipsist/postgres18
Postgres 18
2 parents e18872f + 0cdda77 commit bf9eb4b

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FROM postgres:17.5
1+
FROM postgres:18.1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# dokku postgres [![Build Status](https://img.shields.io/github/actions/workflow/status/dokku/dokku-postgres/ci.yml?branch=master&style=flat-square "Build Status")](https://github.com/dokku/dokku-postgres/actions/workflows/ci.yml?query=branch%3Amaster) [![IRC Network](https://img.shields.io/badge/irc-libera-blue.svg?style=flat-square "IRC Libera")](https://webchat.libera.chat/?channels=dokku)
22

3-
Official postgres plugin for dokku. Currently defaults to installing [postgres 17.5](https://hub.docker.com/_/postgres/).
3+
Official postgres plugin for dokku. Currently defaults to installing [postgres 18.1](https://hub.docker.com/_/postgres/).
44

55
## Requirements
66

functions

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ service_create_container() {
7878

7979
rm -f "$SERVICE_ROOT/ID"
8080
declare -a DOCKER_ARGS
81+
82+
# Determine correct data directory for PostgreSQL version
83+
local DATA_DIR="/var/lib/postgresql/data"
84+
local PG_MAJOR="${PLUGIN_IMAGE_VERSION%%[^0-9]*}"
85+
if [[ -n "$PG_MAJOR" && "$PG_MAJOR" -ge 18 ]]; then
86+
DATA_DIR="/var/lib/postgresql"
87+
fi
88+
8189
DOCKER_ARGS=()
8290
DOCKER_ARGS+=("--cidfile=$SERVICE_ROOT/ID")
8391
DOCKER_ARGS+=("--env-file=$SERVICE_ROOT/ENV")
@@ -87,7 +95,7 @@ service_create_container() {
8795
DOCKER_ARGS+=("--label=dokku=service")
8896
DOCKER_ARGS+=("--name=$SERVICE_NAME")
8997
DOCKER_ARGS+=("--restart=always")
90-
DOCKER_ARGS+=("--volume=$SERVICE_HOST_ROOT/data:/var/lib/postgresql/data")
98+
DOCKER_ARGS+=("--volume=$SERVICE_HOST_ROOT/data:$DATA_DIR")
9199

92100
declare -a LINK_CONTAINER_DOCKER_ARGS
93101
LINK_CONTAINER_DOCKER_ARGS=()
@@ -150,7 +158,7 @@ service_create_container() {
150158
dokku_log_verbose_quiet "Securing connection to database"
151159
service_pause "$SERVICE" >/dev/null
152160
"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/scripts/create_ssl_certs.sh" "$SERVICE_ROOT" &>/dev/null
153-
"$DOCKER_BIN" container run --rm -i -v "$SERVICE_HOST_ROOT/data:/var/lib/postgresql/data" -v "$SERVICE_HOST_ROOT/certs:/var/lib/postgresql/certs" "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" bash -s <"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/scripts/enable_ssl.sh" &>/dev/null
161+
"$DOCKER_BIN" container run --rm -i -v "$SERVICE_HOST_ROOT/data:$DATA_DIR" -v "$SERVICE_HOST_ROOT/certs:/var/lib/postgresql/certs" "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" bash -s <"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/scripts/enable_ssl.sh" &>/dev/null
154162
rm -rf "$SERVICE_HOST_ROOT/certs"
155163

156164
suppress_output "$DOCKER_BIN" container start "$(cat "$SERVICE_ROOT/ID")"

scripts/enable_ssl.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,28 @@
22

33
set -e
44

5-
cd /var/lib/postgresql/data
5+
# Determine data directory: prefer PGDATA if set by the image, otherwise
6+
# fall back to common location used by Postgres images.
7+
if [ -n "$PGDATA" ] && [ -d "$PGDATA" ]; then
8+
data_dir="$PGDATA"
9+
elif [ -d /var/lib/postgresql/data ]; then
10+
data_dir="/var/lib/postgresql/data"
11+
else
12+
echo "No postgres data directory found" >&2
13+
exit 1
14+
fi
615

7-
cp ../certs/* .
8-
chown postgres:postgres server.key
9-
chmod 600 server.key
16+
cd "$data_dir"
1017

18+
# Certs are mounted to /var/lib/postgresql/certs by the plugin; copy them
19+
# into the data directory if present.
20+
certs_src="/var/lib/postgresql/certs"
21+
if [ -d "$certs_src" ] && [ "$(ls -A "$certs_src" 2>/dev/null || true)" ]; then
22+
cp "$certs_src"/* .
23+
chown postgres:postgres server.key
24+
chmod 600 server.key
25+
fi
26+
27+
# Enable SSL in postgresql.conf
1128
sed -i "s/^#ssl = off/ssl = on/" postgresql.conf
1229
sed -i "s/^#ssl_ciphers =.*/ssl_ciphers = 'AES256+EECDH:AES256+EDH'/" postgresql.conf

0 commit comments

Comments
 (0)