From 05a5839ef60f4455fbf46021f999cf69c38fb2aa Mon Sep 17 00:00:00 2001 From: tuutti Date: Wed, 11 Dec 2024 13:28:23 +0200 Subject: [PATCH] Support custom webroot --- openshift/drupal/Dockerfile | 18 ++++++++++++++---- openshift/drupal/Makefile | 2 +- .../drupal/files/entrypoints/15-syslog.sh | 12 ------------ .../files/entrypoints/20-prepare-nginx.sh | 7 +++++++ openshift/drupal/files/entrypoints/99-nginx.sh | 5 ----- .../drupal/files/etc/nginx/http.d/default.conf | 2 +- 6 files changed, 23 insertions(+), 23 deletions(-) delete mode 100644 openshift/drupal/files/entrypoints/15-syslog.sh create mode 100644 openshift/drupal/files/entrypoints/20-prepare-nginx.sh diff --git a/openshift/drupal/Dockerfile b/openshift/drupal/Dockerfile index 74b36f9..181d8a9 100644 --- a/openshift/drupal/Dockerfile +++ b/openshift/drupal/Dockerfile @@ -5,7 +5,6 @@ ARG ALPINE_VERSION=3.20 FROM alpine:${ALPINE_VERSION} AS php # Install required tools (https://docs.acquia.com/blt/install/) -# alpine-sdk required for the make script in composer.json RUN set -eux; \ apk update && apk upgrade && \ apk add --no-cache git \ @@ -14,7 +13,13 @@ RUN set -eux; \ rsync \ bash \ mariadb-client \ - alpine-sdk \ + # This is required by MySQL 8 (caching_sha2_password plugin) + mariadb-connector-c \ + grep \ + make \ + git \ + tar \ + openssl \ nginx \ bash \ jq \ @@ -25,8 +30,8 @@ RUN \ echo 'export PS1="[${APP_ENV:-env}] \[\e[1;31m\][${HOSTNAME:-hostname}] \[\e[1;33m\]\w\[\e[0m\] $ "' | tee /etc/profile /etc/bash/ps1.sh ENV ENV="/etc/profile" -# Install Composer COPY --from=composer:latest /usr/bin/composer /usr/local/bin/ +COPY --from=amazeeio/envplate:v1.0.3 /usr/local/bin/ep /usr/local/bin/ep ENV PATH=${PATH}:/app/vendor/bin:/var/www/html/vendor/bin ENV COMPOSER_HOME=/.composer @@ -63,7 +68,8 @@ RUN \ # Correct permissions to nginx folders. chmod -R a+rwx /var/lib/nginx && \ chmod -R a+rwx /var/log/nginx && \ - chmod -R a+rwx /etc/nginx/conf.d + chmod -R a+rwx /etc/nginx/conf.d && \ + chmod -R a+rwx /etc/nginx/http.d ENTRYPOINT ["/sbin/tini", "--"] @@ -91,9 +97,11 @@ RUN set -eux; \ php83-xmlreader \ php83-xmlwriter \ php83-simplexml \ + php83-sockets \ php83-ctype \ php83-gd \ php83-sodium \ + php83-bcmath \ php83-pecl-apcu \ php83-pecl-redis; \ apk --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community --repository=https://dl-cdn.alpinelinux.org/alpine/edge/main add \ @@ -114,6 +122,7 @@ RUN set -eux; \ php84-openssl \ php84-phar \ php84-session \ + php84-sockets \ php84-zip \ php84-dom \ php84-pdo \ @@ -125,6 +134,7 @@ RUN set -eux; \ php84-ctype \ php84-gd \ php84-sodium \ + php84-bcmath \ php84-pecl-apcu \ php84-pecl-redis \ php84-pecl-imagick; \ diff --git a/openshift/drupal/Makefile b/openshift/drupal/Makefile index 67dd188..8f213e1 100644 --- a/openshift/drupal/Makefile +++ b/openshift/drupal/Makefile @@ -73,7 +73,7 @@ define run_tests endef define build_image - docker buildx bake $(BUILD_EXTRA_ARGS) --pull --push -f docker-bake.hcl $(1) + docker buildx bake $(BUILD_EXTRA_ARGS) --no-cache --pull --push -f docker-bake.hcl $(1) endef .PHONY: $(PHONY) diff --git a/openshift/drupal/files/entrypoints/15-syslog.sh b/openshift/drupal/files/entrypoints/15-syslog.sh deleted file mode 100644 index c040b8a..0000000 --- a/openshift/drupal/files/entrypoints/15-syslog.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -cd /var/www/html - -# @todo Remove this once all projects use monolog. -if ! composer show drupal/monolog -q 2>/dev/null; then - touch /tmp/drupal.log && chmod a+rw /tmp/drupal.log - tail -f /tmp/drupal.log & -else - echo "Found drupal/monolog. Skipping logger entrypoint ..." -fi - diff --git a/openshift/drupal/files/entrypoints/20-prepare-nginx.sh b/openshift/drupal/files/entrypoints/20-prepare-nginx.sh new file mode 100644 index 0000000..99404e6 --- /dev/null +++ b/openshift/drupal/files/entrypoints/20-prepare-nginx.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +if echo "$APP_ENV" | grep -Eq '(local|dev|development|test|testing|stage|staging)'; then + echo 'add_header X-Robots-Tag "noindex, nofollow";' >> /etc/nginx/conf.d/global-headers +fi + +ep /etc/nginx/http.d/default.conf diff --git a/openshift/drupal/files/entrypoints/99-nginx.sh b/openshift/drupal/files/entrypoints/99-nginx.sh index b1a00d8..0c3bdf1 100644 --- a/openshift/drupal/files/entrypoints/99-nginx.sh +++ b/openshift/drupal/files/entrypoints/99-nginx.sh @@ -1,9 +1,4 @@ #!/bin/sh - -if echo "$APP_ENV" | grep -Eq '(local|dev|development|test|testing|stage|staging)'; then - echo 'add_header X-Robots-Tag "noindex, nofollow";' >> /etc/nginx/conf.d/global-headers -fi - echo "Start up Nginx..." nginx -g 'daemon off;' diff --git a/openshift/drupal/files/etc/nginx/http.d/default.conf b/openshift/drupal/files/etc/nginx/http.d/default.conf index e60d0e4..df2c598 100644 --- a/openshift/drupal/files/etc/nginx/http.d/default.conf +++ b/openshift/drupal/files/etc/nginx/http.d/default.conf @@ -3,7 +3,7 @@ server { listen 8080 default_server; server_name _; - root /var/www/html/public; + root ${WEBROOT:-/var/www/html/public}; index index.php; # Support for the helfi_proxy module