Skip to content

Commit

Permalink
Update drupal, postgres, and nginx (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
BretFisher authored May 7, 2023
1 parent f101ead commit 57fbb1f
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 21 deletions.
5 changes: 3 additions & 2 deletions compose-assignment-1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
[Docker Mastery Lecture](https://www.udemy.com/course/docker-mastery/learn/lecture/6775804)

- This empty directory is where you should create a docker-compose.yml
- Use the `drupal:9.3.13` image along with the `postgres:14.3` image
- Use the `drupal:9` image along with the `postgres:14` image
- 2020 UPDATE: No version needed in compose files! All 2.x and 3.x features supported without version key.
- Use `ports` to expose Drupal on 8080 (or your preferred port for localhost access)
- Be sure to setup the POSTGRES_PASSWORD environment variable on the postgres service
- Also note that the postgres official image defaults to user:postgres and database:postgres
- Walk through the Drupal config steps in browser at `http://localhost:8080`
- Tip: Drupal setup will assume the database runs on localhost, which is incorrect. You'll need to change it to the name of the service you gave to postgres
- Tip: Drupal setup will assume the database runs on localhost, which is incorrect. You'll need to change it under Advanced settings to the name of the Docker service you gave to postgres
- Use Docker Hub documentation to figure out the right environment and volume settings
- Extra Credit: Use volumes to store Drupal unique data
4 changes: 2 additions & 2 deletions compose-assignment-1/answer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

services:
drupal:
image: drupal:9.3.13
image: drupal:9
ports:
- "8080:80"
volumes:
Expand All @@ -13,7 +13,7 @@ services:
- drupal-sites:/var/www/html/sites
- drupal-themes:/var/www/html/themes
postgres:
image: postgres:14.3
image: postgres:14
environment:
- POSTGRES_PASSWORD=mypasswd

Expand Down
6 changes: 3 additions & 3 deletions compose-assignment-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It's always a good idea to do that so a new major version doesn't surprise you.
## Dockerfile

- First you need to build a custom Dockerfile in this directory,
`FROM drupal:9.3.13` NOTE: if it fails to build, try the latest 9 branch version with `FROM drupal:9`
`FROM drupal:9`
- Then RUN apt package manager command to install git: `apt-get update && apt-get install -y git`
- Remember to cleanup after your apt install with `rm -rf /var/lib/apt/lists/*` and use `\` and `&&` properly.
You can find examples of them in drupal official image. More on this below under Compose file.
Expand All @@ -31,11 +31,11 @@ to signify the next line is included in the command, and at start of next line y

- We're going to build a custom image in this compose file for drupal service.
Use Compose file from previous assignment for Drupal to start with, and we'll add to it, as well as change image name.
- Rename image to `custom-drupal` as we want to make a new image based on the official `drupal:9.3.13`.
- Rename image to `custom-drupal` as we want to make a new image based on the official `drupal:9`.
- We want to build the default Dockerfile in this directory by adding `build: .` to the `drupal` service.
When we add a build + image value to a compose service,
it knows to use the image name to write to in our image cache, rather then pull from Docker Hub.
- For the `postgres:14.3` service, you need the same password as in previous assignment,
- For the `postgres:14` service, you need the same password as in previous assignment,
but also add a volume for `drupal-data:/var/lib/postgresql/data` so the database will
persist across Compose restarts.

Expand Down
2 changes: 1 addition & 1 deletion compose-assignment-2/answer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM drupal:9.3.13
FROM drupal:9

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
Expand Down
2 changes: 1 addition & 1 deletion compose-assignment-2/answer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
- drupal-themes:/var/www/html/themes

postgres:
image: postgres:14.3
image: postgres:14
environment:
- POSTGRES_PASSWORD=mypasswd
volumes:
Expand Down
14 changes: 9 additions & 5 deletions dockerfile-sample-1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ FROM debian:bullseye-slim
LABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>"

# optional environment variable that's used in later lines and set as envvar when container is running
ENV NGINX_VERSION 1.23.2
ENV NJS_VERSION 0.7.7
ENV NGINX_VERSION 1.23.4
ENV NJS_VERSION 0.7.11
ENV PKG_RELEASE 1~bullseye


Expand All @@ -25,15 +25,19 @@ RUN set -x \
&& apt-get install --no-install-recommends --no-install-suggests -y gnupg1 ca-certificates \
&& \
NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
NGINX_GPGKEY_PATH=/usr/share/keyrings/nginx-archive-keyring.gpg; \
export GNUPGHOME="$(mktemp -d)"; \
found=''; \
for server in \
hkp://keyserver.ubuntu.com:80 \
pgp.mit.edu \
; do \
echo "Fetching GPG key $NGINX_GPGKEY from $server"; \
apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
gpg1 --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
done; \
test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
gpg1 --export "$NGINX_GPGKEY" > "$NGINX_GPGKEY_PATH" ; \
rm -rf "$GNUPGHOME"; \
apt-get remove --purge --auto-remove -y gnupg1 && rm -rf /var/lib/apt/lists/* \
&& dpkgArch="$(dpkg --print-architecture)" \
&& nginxPackages=" \
Expand All @@ -46,13 +50,13 @@ RUN set -x \
&& case "$dpkgArch" in \
amd64|arm64) \
# arches officialy built by upstream
echo "deb https://nginx.org/packages/mainline/debian/ bullseye nginx" >> /etc/apt/sources.list.d/nginx.list \
echo "deb [signed-by=$NGINX_GPGKEY_PATH] https://nginx.org/packages/mainline/debian/ bullseye nginx" >> /etc/apt/sources.list.d/nginx.list \
&& apt-get update \
;; \
*) \
# we're on an architecture upstream doesn't officially build for
# let's build binaries from the published source packages
echo "deb-src https://nginx.org/packages/mainline/debian/ bullseye nginx" >> /etc/apt/sources.list.d/nginx.list \
echo "deb-src [signed-by=$NGINX_GPGKEY_PATH] https://nginx.org/packages/mainline/debian/ bullseye nginx" >> /etc/apt/sources.list.d/nginx.list \
\
# new directory for storing sources and .deb files
&& tempDir="$(mktemp -d)" \
Expand Down
4 changes: 2 additions & 2 deletions swarm-secrets-assignment-1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ We are starting with a `docker-compose.yml` in the same directory as this README
## Compose File

- Since we're using Swarm, we need to update `version:` at the top to the latest 3.x version (3.9).
- Change the Drupal image to use the official version we've tested: `drupal:9.3.13`, and remove any build options (since Swarm can't build an image).
- For the `postgres:14.3` service, you'll need to set a password. This time we want it to use the password stored in the Swarm Secret, which Swarm will mount on the file system for us inside the Postgres container. See the Postgres Docker Hub page to find out more about the POSTGRES_PASSWORD_FILE environment variable.
- Change the Drupal image to use the official version we've tested: `drupal:9`, and remove any build options (since Swarm can't build an image).
- For the `postgres:14` service, you'll need to set a password. This time we want it to use the password stored in the Swarm Secret, which Swarm will mount on the file system for us inside the Postgres container. See the Postgres Docker Hub page to find out more about the POSTGRES_PASSWORD_FILE environment variable.
- Add an external secret and tell the postgres service to mount it.

## Docker Swarm
Expand Down
4 changes: 2 additions & 2 deletions swarm-secrets-assignment-1/answer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.9'
services:

drupal:
image: drupal:9.3.13
image: drupal:9
ports:
- "8080:80"
volumes:
Expand All @@ -13,7 +13,7 @@ services:
- drupal-themes:/var/www/html/themes

postgres:
image: postgres:14.3
image: postgres:14
environment:
- POSTGRES_PASSWORD_FILE=/run/secrets/psql-pw
secrets:
Expand Down
2 changes: 1 addition & 1 deletion swarm-secrets-assignment-1/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
- drupal-themes:/var/www/html/themes

postgres:
image: postgres:14.3
image: postgres:14
environment:
- POSTGRES_PASSWORD=mypasswd
volumes:
Expand Down
2 changes: 1 addition & 1 deletion swarm-stack-3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM drupal:9.3.13
FROM drupal:9


RUN apt-get update \
Expand Down
2 changes: 1 addition & 1 deletion swarm-stack-3/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ services:
image: custom-drupal:latest

postgres:
image: postgres:14.3
image: postgres:14

0 comments on commit 57fbb1f

Please sign in to comment.