Skip to content

Commit

Permalink
✨ Add symlink creation for PHP storage directory (#7)
Browse files Browse the repository at this point in the history
* ✨ Add symlink creation for PHP storage directory

Create a symlink for the PHP storage directory to avoid running script on container start. Also ensure directory ownership by webserver user.

* feat: use existing env vars

reuse the DRUPAL_FILES_DIR instead of appending "files" to DRUPAL_SITE_DIR
  • Loading branch information
esolitos authored May 13, 2024
1 parent e8c127e commit 8e1183e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions templates/drupal-cron/default.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ ENV DRUPAL_ROOT=${APP_ROOT}/${DRUPAL_ROOT}
ENV DRUPAL_SITE_DIR=$(DRUPAL_ROOT)/sites/$(DRUPAL_SITE)
ENV DRUPAL_FILES_DIR=${DRUPAL_SITE_DIR}/files
ENV DRUPAL_FILES_SYNC_SALT=not-in-use-but-required
ENV DRUPAL_PHP_STORAGE_DIR=/tmp/php

# Creates a symlink to the default location where the persistent files are stored.
#
# This is usually done at runtime by calling the makefiles script, but to avoid
# having to run the script every time the container is started, we do it here for
# the default location.
RUN set -e ;\
rm -rvf "${DRUPAL_FILES_DIR}" ;\
ln -vs "${FILES_DIR}/public" "${DRUPAL_FILES_DIR}"

USER root

Expand All @@ -29,4 +39,8 @@ RUN set -e ;\
chown www-data:www-data ${DRUPAL_LOGS_DIR} ;\
chmod 775 ${DRUPAL_LOGS_DIR}

# Ensure the PHP storage directory exists and it is owned by the webserver user
RUN mkdir ${DRUPAL_PHP_STORAGE_DIR} ;\
chown -R www-data:www-data ${DRUPAL_PHP_STORAGE_DIR}

USER wodby
14 changes: 14 additions & 0 deletions templates/drupal-php/default.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ ENV DRUPAL_ROOT=${APP_ROOT}/${DRUPAL_ROOT}
ENV DRUPAL_SITE_DIR=$(DRUPAL_ROOT)/sites/$(DRUPAL_SITE)
ENV DRUPAL_FILES_DIR=${DRUPAL_SITE_DIR}/files
ENV DRUPAL_FILES_SYNC_SALT=not-in-use-but-required
ENV DRUPAL_PHP_STORAGE_DIR=/tmp/php

# Creates a symlink to the default location where the persistent files are stored.
#
# This is usually done at runtime by calling the makefiles script, but to avoid
# having to run the script every time the container is started, we do it here for
# the default location.
RUN set -e ;\
rm -rvf "${DRUPAL_FILES_DIR}" ;\
ln -vs "${FILES_DIR}/public" "${DRUPAL_FILES_DIR}"

USER root

Expand All @@ -26,4 +36,8 @@ RUN set -e ;\
chown www-data:www-data ${DRUPAL_LOGS_DIR} ;\
chmod 775 ${DRUPAL_LOGS_DIR}

# Ensure the PHP storage directory exists and it is owned by the webserver user
RUN mkdir ${DRUPAL_PHP_STORAGE_DIR} ;\
chown -R www-data:www-data ${DRUPAL_PHP_STORAGE_DIR}

USER wodby

0 comments on commit 8e1183e

Please sign in to comment.