diff --git a/netdisco-postgresql/Dockerfile b/netdisco-postgresql/Dockerfile index ac89687..6c55009 100644 --- a/netdisco-postgresql/Dockerfile +++ b/netdisco-postgresql/Dockerfile @@ -1,5 +1,5 @@ # vim: ft=Dockerfile -FROM docker.io/postgres:13.4-alpine +FROM docker.io/postgres:17.2-alpine ARG BUILD_DATE ARG COMMITTISH=HEAD @@ -18,12 +18,14 @@ LABEL org.label-schema.docker.schema-version="1.0" \ org.netdisco.version=${COMMITTISH} RUN apk add --no-cache \ + su-exec \ curl \ tzdata \ tar COPY netdisco-initdb.sh /docker-entrypoint-initdb.d/ COPY netdisco-db-entrypoint.sh netdisco-updatedb.sh /usr/local/bin/ +COPY README_UPGRADE.md / RUN chmod +x /usr/local/bin/netdisco-* WORKDIR /var/lib/postgresql/netdisco-sql diff --git a/netdisco-postgresql/README_UPGRADE.md b/netdisco-postgresql/README_UPGRADE.md new file mode 100644 index 0000000..543b762 --- /dev/null +++ b/netdisco-postgresql/README_UPGRADE.md @@ -0,0 +1,47 @@ + +Beginning from version 2.09000 netdisco-docker includes Postgres 17, +while the existing database is an older major version. + +It's possible to upgrade the old database in-place using pgautoupgrade, +executed in the directory where docker-compose.yml is located. Make +sure all other netdisco containers are stopped. + +``` +docker run --rm -it \ + --mount type=bind,source=$PWD/netdisco/pgdata,target=/var/lib/postgresql/data \ + -e PGAUTO_ONESHOT=yes \ + pgautoupgrade/pgautoupgrade:17-alpine +``` + +Before doing so, please make sure to have a working backup. If you don't +have one already, a simple way to create one is: + +``` +docker-compose exec -u postgres netdisco-postgresql \ + pg_dump -c -d netdisco -C --format=p > $HOME/netdisco-backup.sql + +``` + +For the above command to work, or to avoid upgrading right now, edit +docker-compose.yml to use the last version of the images that used +Postgres 13: + +``` + image: netdisco/netdisco:2.080003-postgresql + image: netdisco/netdisco:2.080003-backend + image: netdisco/netdisco:2.080003-web + image: netdisco/netdisco:2.080003-do +``` + +When you are ready to use Postgres 17, set the version numbers in image: +to `latest` again. + +``` + image: netdisco/netdisco:latest-postgresql + etc... +``` + +We apologize for the inconvenience. While we can not offer full +Postgres DBA support or any responsibility for data loss, we try to +help with reported issues on github or the IRC channel. + diff --git a/netdisco-postgresql/netdisco-db-entrypoint.sh b/netdisco-postgresql/netdisco-db-entrypoint.sh index e680b0b..80937e7 100644 --- a/netdisco-postgresql/netdisco-db-entrypoint.sh +++ b/netdisco-postgresql/netdisco-db-entrypoint.sh @@ -10,6 +10,11 @@ if [ ! -s "${PGDATA}/PG_VERSION" ]; then /usr/local/bin/docker-entrypoint.sh "$@" fi +if ! grep -q "17" "${PGDATA}/PG_VERSION" ; then + cat /README_UPGRADE.md + exit 1 +fi + if [ "$1" = 'postgres' ]; then echo >&2 -e "${COL}netdisco-db-entrypoint: starting pg privately to container${NC}" "${su[@]}" pg_ctl -D "$PGDATA" -o "-c listen_addresses='localhost' -c log_min_error_statement=LOG -c log_min_messages=LOG" -w start