Skip to content

Commit

Permalink
Merge pull request #1133 from uselagoon/add_postgres_17
Browse files Browse the repository at this point in the history
build: add postgres-17 image
  • Loading branch information
tobybellwood authored Oct 16, 2024
2 parents 4c00180 + 1d48361 commit 497fd55
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ versioned-images := php-8.1-fpm \
postgres-15-drupal \
postgres-16 \
postgres-16-drupal \
postgres-17 \
postgres-17-drupal \
redis-6 \
redis-6-persistent \
redis-7 \
Expand Down Expand Up @@ -295,13 +297,14 @@ build/node-18 build/node-20 build/node-22: build/commons
build/node-18-builder build/node-18-cli: build/node-18
build/node-20-builder build/node-20-cli: build/node-20
build/node-22-builder build/node-22-cli: build/node-22
build/postgres-11 build/postgres-12 build/postgres-13 build/postgres-14 build/postgres-15 build/postgres-16: build/commons
build/postgres-11 build/postgres-12 build/postgres-13 build/postgres-14 build/postgres-15 build/postgres-16 build/postgres-17: build/commons
build/postgres-11-ckan build/postgres-11-drupal: build/postgres-11
build/postgres-12-drupal: build/postgres-12
build/postgres-13-drupal: build/postgres-13
build/postgres-14-drupal: build/postgres-14
build/postgres-15-drupal: build/postgres-15
build/postgres-16-drupal: build/postgres-16
build/postgres-17-drupal: build/postgres-17
build/redis-6 build/redis-7: build/commons
build/redis-6-persistent: build/redis-6
build/redis-7-persistent: build/redis-7
Expand Down
17 changes: 17 additions & 0 deletions helpers/TESTING_service_images_dockercompose.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ docker run --rm --net all-images_default jwilder/dockerize dockerize -wait tcp:/
docker run --rm --net all-images_default jwilder/dockerize dockerize -wait tcp://postgres-14:5432 -timeout 1m
docker run --rm --net all-images_default jwilder/dockerize dockerize -wait tcp://postgres-15:5432 -timeout 1m
docker run --rm --net all-images_default jwilder/dockerize dockerize -wait tcp://postgres-16:5432 -timeout 1m
docker run --rm --net all-images_default jwilder/dockerize dockerize -wait tcp://postgres-17:5432 -timeout 1m
docker run --rm --net all-images_default jwilder/dockerize dockerize -wait tcp://mongo-4:27017 -timeout 1m
docker run --rm --net all-images_default jwilder/dockerize dockerize -wait tcp://opensearch-2:9200 -timeout 1m
docker run --rm --net all-images_default jwilder/dockerize dockerize -wait tcp://rabbitmq:15672 -timeout 1m
Expand Down Expand Up @@ -64,6 +65,7 @@ docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep postgres-14
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep postgres-15
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep postgres-16
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep postgres-17
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep rabbitmq
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep redis-6
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep redis-7
Expand Down Expand Up @@ -342,6 +344,21 @@ docker compose exec -T postgres-16 bash -c "psql -U lagoon -d lagoon < /tmp/list
docker compose exec -T commons sh -c "curl -kL http://internal-services-test:3000/postgres?service=postgres-16" | grep "SERVICE_HOST=PostgreSQL 16"
docker compose exec -T commons sh -c "curl -kL http://internal-services-test:3000/postgres?service=postgres-16" | grep "LAGOON_TEST_VAR=all-images"

# postgres-17 should be version 17 client
docker compose exec -T postgres-17 bash -c "psql --version" | grep "psql" | grep "17."

# postgres-17 should be version 17 server
docker compose exec -T postgres-17 bash -c "echo U0VMRUNUIHZlcnNpb24oKTs= | base64 -d > /tmp/selectversion.sql"
docker compose exec -T postgres-17 bash -c "psql -U lagoon -d lagoon < /tmp/selectversion.sql" | grep "PostgreSQL" | grep "17."

# postgres-17 should have lagoon database
docker compose exec -T postgres-17 bash -c "echo XGwrIGxhZ29vbg== | base64 -d > /tmp/listlagoon.sql"
docker compose exec -T postgres-17 bash -c "psql -U lagoon -d lagoon < /tmp/listlagoon.sql" | grep "lagoon"

# postgres-17 should be able to read/write data
docker compose exec -T commons sh -c "curl -kL http://internal-services-test:3000/postgres?service=postgres-17" | grep "SERVICE_HOST=PostgreSQL 17"
docker compose exec -T commons sh -c "curl -kL http://internal-services-test:3000/postgres?service=postgres-17" | grep "LAGOON_TEST_VAR=all-images"

# nginx should be served by openresty
docker compose exec -T commons sh -c "curl -kL http://nginx:8080" | grep "hr" | grep "openresty"

Expand Down
6 changes: 6 additions & 0 deletions helpers/services-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ services:
- "5432"
<< : *default-user # uses the defined user from top

postgres-17:
image: uselagoon/postgres-17:latest
ports:
- "5432"
<< : *default-user # uses the defined user from top

rabbitmq:
image: uselagoon/rabbitmq:latest
ports:
Expand Down
20 changes: 20 additions & 0 deletions images/postgres-drupal/17.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/postgres-17

ARG LAGOON_VERSION
ENV LAGOON_VERSION=$LAGOON_VERSION
LABEL org.opencontainers.image.authors="The Lagoon Authors"
LABEL org.opencontainers.image.source="https://github.com/uselagoon/lagoon-images/blob/main/images/postgres-drupal/17.Dockerfile"
LABEL org.opencontainers.image.url="https://github.com/uselagoon/lagoon-images"
LABEL org.opencontainers.image.version="${LAGOON_VERSION}"
LABEL org.opencontainers.image.description="PostgreSQL 17 image optimised for Drupal workloads running in Lagoon in production and locally"
LABEL org.opencontainers.image.title="uselagoon/postgres-17-drupal"
LABEL org.opencontainers.image.base.name="docker.io/uselagoon/postgres-17"

# change log_min_error_statement and log_min_messages from `error` to `log` as drupal is prone to cause some errors which are all logged (yes `log` is a less verbose mode than `error`)
RUN sed -i "s/#log_min_error_statement = error/log_min_error_statement = log/" /usr/local/share/postgresql/postgresql.conf.sample \
&& sed -i "s/#log_min_messages = warning/log_min_messages = log/" /usr/local/share/postgresql/postgresql.conf.sample

ENV POSTGRES_PASSWORD=drupal \
POSTGRES_USER=drupal \
POSTGRES_DB=drupal
52 changes: 52 additions & 0 deletions images/postgres/17.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/commons AS commons
FROM postgres:17.0-alpine3.20

ARG LAGOON_VERSION
ENV LAGOON_VERSION=$LAGOON_VERSION
LABEL org.opencontainers.image.authors="The Lagoon Authors"
LABEL org.opencontainers.image.source="https://github.com/uselagoon/lagoon-images/blob/main/images/postgres/17.Dockerfile"
LABEL org.opencontainers.image.url="https://github.com/uselagoon/lagoon-images"
LABEL org.opencontainers.image.version="${LAGOON_VERSION}"
LABEL org.opencontainers.image.description="PostgreSQL 17 image optimised for running in Lagoon in production and locally"
LABEL org.opencontainers.image.title="uselagoon/postgres-17"
LABEL org.opencontainers.image.base.name="docker.io/postgres:17-alpine3.20"

ENV LAGOON=postgres

# Copy commons files
COPY --from=commons /lagoon /lagoon
COPY --from=commons /bin/fix-permissions /bin/ep /bin/docker-sleep /bin/wait-for /bin/
COPY --from=commons /sbin/tini /sbin/
COPY --from=commons /home /home

ENV TMPDIR=/tmp \
TMP=/tmp \
HOME=/home \
# When Bash is invoked via `sh` it behaves like the old Bourne Shell and sources a file that is given in `ENV`
ENV=/home/.bashrc \
# When Bash is invoked as non-interactive (like `bash -c command`) it sources a file that is given in `BASH_ENV`
BASH_ENV=/home/.bashrc

RUN apk update \
&& apk add --no-cache \
rsync \
tar \
&& rm -rf /var/cache/apk/*

RUN fix-permissions /etc/passwd \
&& mkdir -p /home

COPY postgres-backup.sh /lagoon/

RUN echo -e "local all all md5\nhost all all 0.0.0.0/0 md5" >> /usr/local/share/postgresql/pg_hba.conf

ENV PGUSER=postgres \
POSTGRES_PASSWORD=lagoon \
POSTGRES_USER=lagoon \
POSTGRES_DB=lagoon \
PGDATA=/var/lib/postgresql/data/pgdata

# Postgresql entrypoint file needs bash, so start the entrypoints with bash
ENTRYPOINT ["/sbin/tini", "--", "/lagoon/entrypoints.bash"]
CMD ["/usr/local/bin/docker-entrypoint.sh", "postgres"]

0 comments on commit 497fd55

Please sign in to comment.