Skip to content

Commit

Permalink
Changed local base image to use prod as base
Browse files Browse the repository at this point in the history
  • Loading branch information
tuutti committed Dec 10, 2024
1 parent 716a7d6 commit 0231d5c
Show file tree
Hide file tree
Showing 26 changed files with 274 additions and 577 deletions.
56 changes: 30 additions & 26 deletions local/drupal/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,41 +1,45 @@
ARG PHP_VERSION
ARG PHP_SHORT_VERSION
FROM druidfi/drupal-web:php-${PHP_VERSION} AS base
ARG PHP_VERSION=8.4
ARG PHP_SHORT_VERSION=84
FROM ghcr.io/city-of-helsinki/drupal-docker-base:${PHP_VERSION}-dev AS base

COPY --from=ghcr.io/city-of-helsinki/drupal-oc-cli:latest /usr/bin/oc /usr/bin/oc
ENV DRUPAL_DB_NAME=drupal \
DRUPAL_DB_USER=drupal \
DRUPAL_DB_PASS=drupal \
DRUPAL_DB_HOST=db \
DRUPAL_DB_PORT=3306

RUN sudo apk add --no-cache jq openssl
ENV SIMPLETEST_DB="mysql://${DRUPAL_DB_USER}:${DRUPAL_DB_PASS}@${DRUPAL_DB_HOST}:${DRUPAL_DB_PORT}/${DRUPAL_DB_NAME}"

RUN sudo composer self-update
COPY --from=ghcr.io/city-of-helsinki/drupal-oc-cli:latest /usr/bin/oc /usr/bin/oc

COPY entrypoints/ /entrypoints
COPY files/ /

# Override default fpm pool conf to run nginx and php-fpm as same user.
COPY php-fpm-pool.conf /etc/php${PHP_SHORT_VERSION}/php-fpm.d/www.conf
RUN chmod +x /entrypoints/*

# Add druid user to nginx group to prevent permission issues with drush and 'asset://'
# files.
RUN sudo addgroup druid nginx
COPY files/etc/nginx /etc/nginx

RUN sudo -u root touch /tmp/xdebug.log && \
sudo chmod 666 /tmp/xdebug.log
# The old druidfi/drupal-web image used /app folder. Symlink it to
# keep this compatible with it.
RUN ln -s /var/www/html /app

RUN sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
ARG PHP_SHORT_VERSION
# Remove opcache-recommended.ini because we make several performance
# changes to OPcache settings that may hinder local development.
RUN rm /etc/php${PHP_SHORT_VERSION}/conf.d/opcache-recommended.ini

# Generate a self-signed cert for nginx. We use selenium+chromium to run
# Functional javascript tests and it forces all requests to use https now.
# We have a nginx config with a self-signed cert to proxy https requests
# to 8080 port.
# @see files/etc/nginx/http.d/ssl-proxy.conf
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-subj "/C=FI/ST=Uusimaa/L=Helsinki" \
-keyout /etc/ssl/private/cert.key \
-out /etc/ssl/certs/cert.crt

ENV SIMPLETEST_DB="mysql://${DRUPAL_DB_USER}:${DRUPAL_DB_PASS}@${DRUPAL_DB_HOST}:${DRUPAL_DB_PORT}/${DRUPAL_DB_NAME}"

FROM base AS php83
RUN sudo apk --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing \
--repository=https://dl-cdn.alpinelinux.org/alpine/edge/main \
--repository=https://dl-cdn.alpinelinux.org/alpine/edge/community \
--repository=https://dl-cdn.alpinelinux.org/alpine/edge/releases add php83-pecl-imagick php83-pecl-pcov

FROM base AS php84
RUN sudo apk --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing \
RUN apk --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing \
--repository=https://dl-cdn.alpinelinux.org/alpine/edge/main \
--repository=https://dl-cdn.alpinelinux.org/alpine/edge/community \
--repository=https://dl-cdn.alpinelinux.org/alpine/edge/releases add php84-pecl-imagick php84-pecl-pcov
--repository=https://dl-cdn.alpinelinux.org/alpine/edge/releases add php84-pecl-xdebug php84-pecl-pcov

COPY files/etc/php /etc/php84
10 changes: 4 additions & 6 deletions local/drupal/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Local Drupal docker image

Based on [druidfi/drupal-web](https://github.com/druidfi/docker-images) with few additions:
Based on [City-of-Helsinki/drupal-docker-base](/openshift/drupal) image with a few additions:

- [OpenShift origin client (OC)](/local/oc)
- Force HTTPS nginx fastcgi parameter `on` to make sure Drupal generates URLs using `https`
- Run php-fpm and nginx as same user to prevent some weird permission issues
- Xdebug

Available PHP versions: `8.3`, `8.2`, `8.1`:
Available PHP versions: `8.3`, `8.4`:

- `ghcr.io/city-of-helsinki/drupal-web:8.3`
- `ghcr.io/city-of-helsinki/drupal-web:8.2`
- `ghcr.io/city-of-helsinki/drupal-web:8.1`
- `ghcr.io/city-of-helsinki/drupal-web:8.4`

## Development

Expand Down
Empty file removed local/drupal/entrypoints/.keep
Empty file.
20 changes: 20 additions & 0 deletions local/drupal/entrypoints/15-xdebug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

XDEBUG_INI=/etc/php$PHP_INSTALL_VERSION/conf.d/xdebug.ini

if [ "$XDEBUG_ENABLE" = "true" ]; then
echo "- Start with Xdebug enabled. Remove XDEBUG_ENABLE=true ENV variable to disable it."
if [ -f "$XDEBUG_INI" ]; then
echo "- Already enabled..."
else
mv "$XDEBUG_INI".disabled "$XDEBUG_INI"
touch /tmp/xdebug.log && chmod 666 /tmp/xdebug.log
fi
else
echo "- Start with Xdebug disabled. Add XDEBUG_ENABLE=true ENV variable to enable it."
if [ -f "$XDEBUG_INI" ]; then
mv "$XDEBUG_INI" "$XDEBUG_INI".disabled
else
echo "- Already disabled..."
fi
fi
55 changes: 0 additions & 55 deletions local/drupal/files/etc/nginx/fastcgi.conf

This file was deleted.

Empty file.
149 changes: 0 additions & 149 deletions local/drupal/files/etc/nginx/http.d/default.conf

This file was deleted.

Loading

0 comments on commit 0231d5c

Please sign in to comment.