Skip to content

Commit

Permalink
Merge pull request #864 from uselagoon/py_pgsql_images
Browse files Browse the repository at this point in the history
Add python-3.12 and postgres-16 images
  • Loading branch information
tobybellwood authored Nov 2, 2023
2 parents 51b16d6 + 642d7dc commit 11a2034
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 7 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ versioned-images := php-8.0-fpm \
python-3.9 \
python-3.10 \
python-3.11 \
python-3.12 \
node-18 \
node-18-builder \
node-18-cli \
Expand All @@ -210,6 +211,8 @@ versioned-images := php-8.0-fpm \
postgres-14-drupal \
postgres-15 \
postgres-15-drupal \
postgres-16 \
postgres-16-drupal \
redis-6 \
redis-6-persistent \
redis-7 \
Expand Down Expand Up @@ -282,16 +285,17 @@ build/php-8.2-cli: build/php-8.2-fpm
build/php-8.0-cli-drupal: build/php-8.0-cli
build/php-8.1-cli-drupal: build/php-8.1-cli
build/php-8.2-cli-drupal: build/php-8.2-cli
build/python-3.8 build/python-3.9 build/python-3.10 build/python-3.11: build/commons
build/python-3.7 build/python-3.8 build/python-3.9 build/python-3.10 build/python-3.11 build/python-3.12: build/commons
build/node-18 build/node-20: 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/postgres-11 build/postgres-12 build/postgres-13 build/postgres-14 build/postgres-15: build/commons
build/postgres-11 build/postgres-12 build/postgres-13 build/postgres-14 build/postgres-15 build/postgres-16: 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/redis-6 build/redis-7: build/commons
build/redis-6-persistent: build/redis-6
build/redis-7-persistent: build/redis-7
Expand Down
16 changes: 14 additions & 2 deletions helpers/TESTING_base_images_dockercompose.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,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 python-3-9
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep python-3-10
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep python-3-11
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep python-3-12
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep ruby-3-0
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep ruby-3-1
docker ps --filter label=com.docker.compose.project=all-images | grep Up | grep ruby-3-2
Expand Down Expand Up @@ -216,14 +217,25 @@ docker-compose exec -T commons sh -c "curl python-3-10:3000/tmp/test" | grep "Py
# python-3-11 should be version 3.11
docker-compose exec -T python-3-11 sh -c "python -V" | grep "3.11"

# python-3-10 should have basic tools installed
# python-3-11 should have basic tools installed
docker-compose exec -T python-3-11 sh -c "pip list --no-cache-dir" | grep "pip"
docker-compose exec -T python-3-11 sh -c "pip list --no-cache-dir" | grep "setuptools"
docker-compose exec -T python-3-11 sh -c "pip list --no-cache-dir" | grep "virtualenv"

# python-3-10 should be serving content
# python-3-11 should be serving content
docker-compose exec -T commons sh -c "curl python-3-11:3000/tmp/test" | grep "Python 3.11"

# python-3-12 should be version 3.12
docker-compose exec -T python-3-12 sh -c "python -V" | grep "3.12"

# python-3-12 should have basic tools installed
docker-compose exec -T python-3-12 sh -c "pip list --no-cache-dir" | grep "pip"
docker-compose exec -T python-3-12 sh -c "pip list --no-cache-dir" | grep "setuptools"
docker-compose exec -T python-3-12 sh -c "pip list --no-cache-dir" | grep "virtualenv"

# python-3-12 should be serving content
docker-compose exec -T commons sh -c "curl python-3-12:3000/tmp/test" | grep "Python 3.12"

# node-18 should have Node 18
docker-compose exec -T node-18 sh -c "node -v" | grep "v18"

Expand Down
18 changes: 15 additions & 3 deletions helpers/TESTING_service_images_dockercompose.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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-13:5432 -timeout 1m
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://mongo-4:27017 -timeout 1m
docker run --rm --net all-images_default jwilder/dockerize dockerize -wait tcp://rabbitmq:15672 -timeout 1m
docker run --rm --net all-images_default jwilder/dockerize dockerize -wait tcp://redis-6:6379 -timeout 1m
Expand All @@ -56,6 +57,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-13
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 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 @@ -249,9 +251,6 @@ docker-compose exec -T commons sh -c "curl -kL http://internal-services-test:300
# postgres-15 should be version 15 client
docker-compose exec -T postgres-15 bash -c "psql --version" | grep "psql" | grep "15."

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

# postgres-15 should be version 15 server
docker-compose exec -T postgres-15 bash -c "psql -U lagoon -d lagoon -c \'SELECT version();\'" | grep "PostgreSQL" | grep "15."

Expand All @@ -262,6 +261,19 @@ docker-compose exec -T postgres-15 bash -c "psql -U lagoon -d lagoon -c \'\\l+ l
docker-compose exec -T commons sh -c "curl -kL http://internal-services-test:3000/postgres-15" | grep "SERVICE_HOST=PostgreSQL 15"
docker-compose exec -T commons sh -c "curl -kL http://internal-services-test:3000/postgres-15" | grep "LAGOON_TEST_VAR=all-images"

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

# postgres-16 should be version 16 server
docker-compose exec -T postgres-16 bash -c "psql -U lagoon -d lagoon -c \'SELECT version();\'" | grep "PostgreSQL" | grep "16."

# postgres-16 should have lagoon database
docker-compose exec -T postgres-16 bash -c "psql -U lagoon -d lagoon -c \'\\l+ lagoon\'" | grep "lagoon"

# postgres-16 should be able to read/write data
docker-compose exec -T commons sh -c "curl -kL http://internal-services-test:3000/postgres-16" | grep "SERVICE_HOST=PostgreSQL 16"
docker-compose exec -T commons sh -c "curl -kL http://internal-services-test:3000/postgres-16" | 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
10 changes: 10 additions & 0 deletions helpers/images-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ services:
exec python -m http.server 3000
"]
python-3-12:
image: uselagoon/python-3.12:latest
ports:
- "3000"
<< : *default-user # uses the defined user from top
command: ["sh", "-c", "
python -V | xargs > tmp/test;
exec python -m http.server 3000
"]
ruby-3-0:
image: uselagoon/ruby-3.0:latest
ports:
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 @@ -71,6 +71,12 @@ services:
- "5432"
<< : *default-user # uses the defined user from top

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

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

LABEL org.opencontainers.image.authors="The Lagoon Authors" maintainer="The Lagoon Authors"
LABEL org.opencontainers.image.source="https://github.com/uselagoon/lagoon-images" repository="https://github.com/uselagoon/lagoon-images"

# 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
42 changes: 42 additions & 0 deletions images/postgres/16.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/commons as commons
FROM postgres:16.0-alpine3.18

LABEL org.opencontainers.image.authors="The Lagoon Authors" maintainer="The Lagoon Authors"
LABEL org.opencontainers.image.source="https://github.com/uselagoon/lagoon-images" repository="https://github.com/uselagoon/lagoon-images"

ARG LAGOON_VERSION
ENV LAGOON_VERSION=$LAGOON_VERSION

# 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 fix-permissions /etc/passwd \
&& mkdir -p /home

ENV LAGOON=postgres

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"]
40 changes: 40 additions & 0 deletions images/python/3.12.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
ARG IMAGE_REPO
FROM ${IMAGE_REPO:-lagoon}/commons as commons

FROM python:3.12.0-alpine3.18

LABEL org.opencontainers.image.authors="The Lagoon Authors" maintainer="The Lagoon Authors"
LABEL org.opencontainers.image.source="https://github.com/uselagoon/lagoon-images" repository="https://github.com/uselagoon/lagoon-images"

ENV LAGOON=python

# 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

RUN fix-permissions /etc/passwd \
&& mkdir -p /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 add --no-cache --virtual .build-deps \
build-base \
&& pip install --upgrade pip \
&& pip install virtualenv \
&& apk del \
.build-deps

# Make sure shells are not running forever
COPY 80-shell-timeout.sh /lagoon/entrypoints/
RUN echo "source /lagoon/entrypoints/80-shell-timeout.sh" >> /home/.bashrc

ENTRYPOINT ["/sbin/tini", "--", "/lagoon/entrypoints.sh"]
CMD ["python"]

0 comments on commit 11a2034

Please sign in to comment.