diff --git a/Dockerfile b/Dockerfile index 1df68994d..f6d5d160d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # -# Using --build-arg PGVERSION=14 we can build pg_auto_failover for any +# Using --build-arg PGVERSION=17 we can build pg_auto_failover for any # target version of Postgres. In the Makefile, we use that to our advantage # and tag test images such as pg_auto_failover_test:pg14. # @@ -10,15 +10,25 @@ ARG PGVERSION=17 # # This base image contains all our target Postgres versions. # -FROM debian:bullseye-slim AS base +FROM debian:bookworm-slim AS base ARG PGVERSION RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - build-essential \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ curl \ + postgresql-common + +RUN curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc +RUN echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.list + +# bypass initdb of a "main" cluster +RUN echo 'create_main_cluster = false' >> /etc/postgresql-common/createcluster.conf + +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + build-essential \ gnupg \ git \ gawk \ @@ -60,21 +70,11 @@ RUN apt-get update \ less \ mg \ valgrind \ - postgresql-common \ - && rm -rf /var/lib/apt/lists/* + postgresql-server-dev-${PGVERSION} \ + postgresql-${PGVERSION} \ + && rm -rf /var/lib/apt/lists/* -RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - -RUN echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.list - -# bypass initdb of a "main" cluster -RUN echo 'create_main_cluster = false' | sudo tee -a /etc/postgresql-common/createcluster.conf -RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - postgresql-server-dev-${PGVERSION} \ - postgresql-${PGVERSION} \ - && rm -rf /var/lib/apt/lists/* - -RUN pip3 install pyroute2>=0.5.17 +RUN pip3 install --break-system-packages pyroute2>=0.5.17 RUN adduser --disabled-password --gecos '' docker RUN adduser docker sudo @@ -136,38 +136,38 @@ ENV PATH /usr/lib/postgresql/${PGVERSION}/bin:/usr/local/sbin:/usr/local/bin:/us # # And finally our "run" images with the bare minimum for run-time. # -FROM debian:bullseye-slim AS run +FROM debian:bookworm-slim AS run ARG PGVERSION RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ - curl \ - gnupg \ + curl \ + postgresql-common + +RUN curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc +RUN echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.list + +# bypass initdb of a "main" cluster +RUN echo 'create_main_cluster = false' | sudo tee -a /etc/postgresql-common/createcluster.conf + +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + gnupg \ make \ sudo \ tmux \ - watch \ + watch \ libncurses6 \ lsof \ psutils \ dnsutils \ bind9-host \ - libcurl4-gnutls-dev \ + libcurl4-gnutls-dev \ libzstd-dev \ - postgresql-common \ libpq-dev \ - && rm -rf /var/lib/apt/lists/* - -RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - -RUN echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.list - -# bypass initdb of a "main" cluster -RUN echo 'create_main_cluster = false' | sudo tee -a /etc/postgresql-common/createcluster.conf -RUN apt-get update\ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends postgresql-${PGVERSION} \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* RUN adduser --disabled-password --gecos '' --home /var/lib/postgres docker RUN adduser docker sudo @@ -189,7 +189,7 @@ COPY --from=build /usr/lib/postgresql/${PGVERSION}/bin/pg_autoctl /usr/local/bin # pg_autoctl has the necessary set of privileges. # RUN mkdir -p /var/lib/postgres \ - && chown -R docker /var/lib/postgres + && chown -R docker /var/lib/postgres USER docker ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/postgresql/${PGVERSION}/bin diff --git a/Dockerfile.docs b/Dockerfile.docs index 4932a0ad5..1bbd3bfa1 100644 --- a/Dockerfile.docs +++ b/Dockerfile.docs @@ -1,4 +1,4 @@ -FROM debian:bullseye-slim +FROM debian:bookworm-slim RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ @@ -18,7 +18,7 @@ RUN apt-get update \ poppler-utils \ && rm -rf /var/lib/apt/lists/* -RUN pip3 install sphinx_rtd_theme +RUN pip3 install --break-system-packages sphinx_rtd_theme WORKDIR /usr/src/pg_auto_failover diff --git a/README.md b/README.md index 96acfdb4b..94b73ae36 100644 --- a/README.md +++ b/README.md @@ -84,8 +84,10 @@ To avoid debian creating a default Postgres data directory and service, follow these steps before installing the previous packages. ```bash -$ curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - -$ echo "deb http://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list +$ apt install curl ca-certificates +$ install -d /usr/share/postgresql-common/pgdg +$ curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc +$ echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list # bypass initdb of a "main" cluster $ echo 'create_main_cluster = false' | sudo tee -a /etc/postgresql-common/createcluster.conf diff --git a/docs/citus/Dockerfile b/docs/citus/Dockerfile index d7d168218..3b0b1576e 100644 --- a/docs/citus/Dockerfile +++ b/docs/citus/Dockerfile @@ -1,7 +1,7 @@ -FROM debian:bullseye-slim +FROM debian:bookworm-slim -ARG PGVERSION=14 -ARG CITUS=postgresql-14-citus-11.1 +ARG PGVERSION=17 +ARG CITUS=postgresql-17-citus-13.0 RUN apt-get update \ && apt-get install -y --no-install-recommends \ @@ -19,9 +19,9 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* # we use apt.postgresql.org -RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - -RUN echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.list -RUN echo "deb-src http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.src.list +RUN curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc +RUN echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.list +RUN echo "deb-src [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.src.list # bypass initdb of a "main" cluster RUN echo 'create_main_cluster = false' | sudo tee -a /etc/postgresql-common/createcluster.conf diff --git a/docs/citus/Dockerfile.app b/docs/citus/Dockerfile.app index d978fbd0d..651c2251a 100644 --- a/docs/citus/Dockerfile.app +++ b/docs/citus/Dockerfile.app @@ -1,6 +1,6 @@ -FROM debian:bullseye-slim +FROM debian:bookworm-slim -ARG PGVERSION=14 +ARG PGVERSION=17 RUN apt-get update \ && apt-get install -y --no-install-recommends \ @@ -17,9 +17,10 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* # we use apt.postgresql.org -RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - -RUN echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.list -RUN echo "deb-src http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.src.list +RUN install -d /usr/share/postgresql-common/pgdg +RUN curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc +RUN echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.list +RUN echo "deb-src [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.src.list RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ diff --git a/docs/install.rst b/docs/install.rst index c0db40bac..6de241050 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -41,8 +41,10 @@ debian package, follow those steps: :: - $ curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - - $ echo "deb http://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list + $ apt install curl ca-certificates + $ install -d /usr/share/postgresql-common/pgdg + $ curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc + $ echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list # bypass initdb of a "main" cluster $ echo 'create_main_cluster = false' | sudo tee -a /etc/postgresql-common/createcluster.conf @@ -116,12 +118,12 @@ install`. For this to work please consider adding both the binary and the source repositories to your debian distribution by using the following apt sources, -as an example targetting the debian bullseye distribution: +as an example targetting the debian bookworm distribution: :: - deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main - deb-src http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main + deb https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main + deb-src https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main Then we can install the build dependencies for Postgres, knowing that pg_auto_failover uses the same build dependencies: diff --git a/docs/tutorial/Dockerfile b/docs/tutorial/Dockerfile index 3ce4536f9..eae72c2e8 100644 --- a/docs/tutorial/Dockerfile +++ b/docs/tutorial/Dockerfile @@ -1,7 +1,7 @@ -FROM debian:bullseye-slim +FROM debian:bookworm-slim -ARG PGVERSION=14 -ARG CITUS=postgresql-14-citus-11.1 +ARG PGVERSION=17 +ARG CITUS=postgresql-17-citus-13.0 RUN apt-get update \ && apt-get install -y --no-install-recommends \ @@ -19,9 +19,9 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* # we use apt.postgresql.org -RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - -RUN echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.list -RUN echo "deb-src http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.src.list +RUN curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc +RUN echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.list +RUN echo "deb-src [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.src.list # bypass initdb of a "main" cluster RUN echo 'create_main_cluster = false' | sudo tee -a /etc/postgresql-common/createcluster.conf diff --git a/docs/tutorial/Dockerfile.app b/docs/tutorial/Dockerfile.app index d978fbd0d..651c2251a 100644 --- a/docs/tutorial/Dockerfile.app +++ b/docs/tutorial/Dockerfile.app @@ -1,6 +1,6 @@ -FROM debian:bullseye-slim +FROM debian:bookworm-slim -ARG PGVERSION=14 +ARG PGVERSION=17 RUN apt-get update \ && apt-get install -y --no-install-recommends \ @@ -17,9 +17,10 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* # we use apt.postgresql.org -RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - -RUN echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.list -RUN echo "deb-src http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.src.list +RUN install -d /usr/share/postgresql-common/pgdg +RUN curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc +RUN echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.list +RUN echo "deb-src [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main ${PGVERSION}" > /etc/apt/sources.list.d/pgdg.src.list RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ diff --git a/src/bin/pg_autoctl/cli_do_tmux_compose.c b/src/bin/pg_autoctl/cli_do_tmux_compose.c index 4395e0509..bc4af5c5e 100644 --- a/src/bin/pg_autoctl/cli_do_tmux_compose.c +++ b/src/bin/pg_autoctl/cli_do_tmux_compose.c @@ -361,13 +361,13 @@ tmux_compose_docker_build(TmuxOptions *options) if (!get_env_copy("PGVERSION", pgversion, sizeof(pgversion))) { /* errors have already been logged */ - log_warn("Using PGVERSION=14"); - strlcpy(pgversion, "14", sizeof(pgversion)); + log_warn("Using PGVERSION=17"); + strlcpy(pgversion, "17", sizeof(pgversion)); } } else { - strlcpy(pgversion, "14", sizeof(pgversion)); + strlcpy(pgversion, "17", sizeof(pgversion)); } /* prepare Postgres/Citus compatibility matrix */ diff --git a/tests/tablespaces/Dockerfile b/tests/tablespaces/Dockerfile index fc1cbbb5f..82b01a768 100644 --- a/tests/tablespaces/Dockerfile +++ b/tests/tablespaces/Dockerfile @@ -1,6 +1,6 @@ ARG PGVERSION=14 -FROM pg_auto_failover_test:pg${PGVERSION} as test +FROM pg_auto_failover_test:pg${PGVERSION} AS test USER root RUN mkdir -p /extra_volumes/extended_a && chown -R docker /extra_volumes/extended_a