Skip to content

Commit

Permalink
Merge pull request #1 from Islandora-Devops/main
Browse files Browse the repository at this point in the history
Updating from upstream
  • Loading branch information
emudojo authored Dec 4, 2020
2 parents b2e65cf + a1afabc commit c8d7b88
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 14 deletions.
18 changes: 18 additions & 0 deletions base/rootfs/etc/cont-init.d/00-load-secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/with-contenv bash
set -e

# Read any secret files specified in environment variables.
echo "$(env | grep '=secret:')" | while read line
do
# Skip empty lines
[[ -z $line ]] && continue

# Hack out the path to the secret.
environment_variable=$(echo $line | cut -d= -f1)
secret=$(echo $line | cut -d= -f2 | cut -d: -f2)

# Load the secret's value into the environment variable
if [ -f ${secret} ]; then
s6-env -i ${environment_variable}="$(cat ${secret})" s6-dumpenv -- /var/run/s6/container_environment
fi
done
2 changes: 1 addition & 1 deletion crayfish/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:experimental
FROM local/nginx:latest

ARG COMMIT=1.1.1
ARG COMMIT=85a8206a9ed1db302fdeb123f9d5391ef8aae001

RUN --mount=id=downloads,type=cache,target=/opt/downloads \
DOWNLOAD_CACHE_DIRECTORY="/opt/downloads" && \
Expand Down
2 changes: 1 addition & 1 deletion crayfits/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:experimental
FROM local/nginx:latest

ARG COMMIT=4e0faeb31f84e74e7cecc083b2f096d55e425fbb
ARG COMMIT=6e95f2f325c910b254a2b7bd1cedf25b17874d30

RUN --mount=type=cache,target=/root/.composer/cache \
--mount=id=downloads,type=cache,target=/opt/downloads \
Expand Down
9 changes: 4 additions & 5 deletions demo/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM local/nginx:latest as composer
RUN --mount=type=cache,target=/root/.composer/cache \
--mount=id=downloads,type=cache,target=/opt/downloads \
DOWNLOAD_CACHE_DIRECTORY="/opt/downloads" && \
composer create-project islandora/drupal-project:8.8.1 \
composer create-project drupal/recommended-project:^8.9 \
--prefer-dist \
--no-interaction \
--stability stable \
Expand All @@ -16,7 +16,6 @@ RUN --mount=type=cache,target=/root/.composer/cache \
cd /var/www/drupal && \
composer require --update-no-dev -- \
drupal/admin_toolbar:^2.0 \
drupal/console:~1.0 \
drupal/content_browser:^1.0@alpha \
drupal/devel:^2.0 \
drupal/facets:^1.3 \
Expand All @@ -27,11 +26,11 @@ RUN --mount=type=cache,target=/root/.composer/cache \
drupal/restui:^1.16 \
drupal/search_api_solr:^3.8 \
drupal/transliterate_filenames:^1.3 \
drush/drush:^9.7.1 \
islandora-rdm/islandora_fits:dev-master \
drush/drush:^10.3 \
islandora-rdm/islandora_fits:dev-8.x-1.x \
islandora/carapace:dev-8.x-3.x \
islandora/islandora_defaults:dev-8.x-1.x \
zaporylie/composer-drupal-optimizations:^1.0 \
zaporylie/composer-drupal-optimizations:^1.1 \
&& \
mkdir -p /var/www/drupal/web/libraries && \
MASONRY_VERSION="3.3.2" && \
Expand Down
17 changes: 17 additions & 0 deletions drupal/rootfs/etc/confd/templates/setup-environment.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,22 @@
# -*- mode: sh -*-
# vi: set ft=sh:
with-contenv
# If traefik is not found allow any IP address.
backtick -D 0.0.0.0 -n TRAEFIK_IP {
redirfd -w 2 /dev/null
backtick -i -n CAPTURE {
getent hosts traefik
}
importas CAPTURE CAPTURE
pipeline {
echo ${CAPTURE}
}
awk "{ print $1 }"
}
multisubstitute
{
# Non-site specific variables
importas REVERSE_PROXY_IPS TRAEFIK_IP
# Default settings to apply if none given.
define ACCOUNT_EMAIL "[email protected]"
define ACCOUNT_NAME "admin"
Expand Down Expand Up @@ -49,6 +63,9 @@ foreground {
# environment as seen by linked containers.
# Variables can only be seen when using '#!/usr/bin/with-contenv'
s6-env -i
# Non-site specific variables.
DRUPAL_REVERSE_PROXY_IPS="{{ getv "/reverse/proxy/ips" "${REVERSE_PROXY_IPS}" }}"
# Default site.
DRUPAL_DEFAULT_ACCOUNT_EMAIL="{{ getv "/default/account/email" "${ACCOUNT_EMAIL}" }}"
DRUPAL_DEFAULT_ACCOUNT_NAME="{{ getv "/default/account/name" "${ACCOUNT_NAME}" }}"
DRUPAL_DEFAULT_ACCOUNT_PASSWORD="{{ getv "/default/account/password" "${ACCOUNT_PASSWORD}" }}"
Expand Down
1 change: 1 addition & 0 deletions drupal/rootfs/etc/islandora/utilities.sh
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ function update_settings_php {
drush -l "${site_url}" islandora:settings:create-settings-if-missing
drush -l "${site_url}" islandora:settings:set-hash-salt "${salt}"
drush -l "${site_url}" islandora:settings:set-flystem-fedora-url "${fedora_url}"
drush -l "${site_url}" islandora:settings:set-reverse-proxy "${DRUPAL_REVERSE_PROXY_IPS}"
drush -l "${site_url}" islandora:settings:set-database-settings \
"${db_name}" \
"${user}" \
Expand Down
9 changes: 8 additions & 1 deletion drupal/rootfs/usr/local/bin/drush
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ set -e
# Ensures drush runs as the correct user, and does not run out of memory.
# Takes precedence due to order of $PATH. Preferred to an alias as it will apply
# regardless of which shell is used or how it is started (login, interactive, etc)
s6-setuidgid nginx php -d memory_limit=-1 /usr/bin/drush "${@}"
if test $(id -u) -eq 0; then
# If root run as nginx.
s6-setuidgid nginx php -d memory_limit=-1 /usr/bin/drush "${@}"
else
# If non-root user, then run as current user
# as we do not have permissions to switch user.
php -d memory_limit=-1 /usr/bin/drush "${@}"
fi
26 changes: 26 additions & 0 deletions drupal/rootfs/usr/share/drush/Commands/UpdateSettingsCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,32 @@ public function setTrustedHostPatterns($patterns)
$this->writeSettings($settings);
}

/**
* Set `reverse_proxy` in settings.php
*
* @command islandora:settings:set-reverse-proxy
* @bootstrap site
* @param $reverse_proxy_ips List of comma separated ip adresses for the reverse proxy.
* @usage drush islandora:settings:set-reverse-proxy
* Sets `reverse_proxy` in settings.php.
* Be aware that shell escaping can have an affect on the arguments.
*/
public function setReverseProxySettings($reverse_proxy_ips) {
$settings['settings']['reverse_proxy'] = (object) [
'value' => TRUE,
'required' => TRUE,
];
$settings['settings']['reverse_proxy_addresses'] = (object) [
'value' => explode(',', $reverse_proxy_ips),
'required' => TRUE,
];
$settings['settings']['reverse_proxy_trusted_headers'] = (object) [
'value' => \Symfony\Component\HttpFoundation\Request::HEADER_X_FORWARDED_ALL | \Symfony\Component\HttpFoundation\Request::HEADER_FORWARDED,
'required' => TRUE,
];
$this->writeSettings($settings);
}

/**
* Determine which settings file to update.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ foreground {
FCREPO_DB_NAME="{{ getv "/db/name" "fcrepo" }}"
FCREPO_DB_PASSWORD="{{ getv "/db/password" "password" }}"
FCREPO_DB_PORT="{{ getv "/db/port" "3306" }}"
FCREPO_DB_ROOT_PASSWORD="{{ getv "/db/root/password" "passwod" }}"
FCREPO_DB_ROOT_PASSWORD="{{ getv "/db/root/password" "password" }}"
FCREPO_DB_ROOT_USER="{{ getv "/db/root/user" "root" }}"
FCREPO_DB_USER="{{ getv "/db/user" "fcrepo" }}"
FCREPO_PERSISTENCE_TYPE="{{ getv "/persistence/type" "file" }}"
Expand Down
20 changes: 18 additions & 2 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ FROM local/base:latest
RUN --mount=type=cache,target=/var/cache/apk \
--mount=type=cache,target=/etc/cache/apk \
apk-install.sh \
composer \
nginx \
php7 \
php7-ctype \
php7-curl \
php7-dom \
php7-fileinfo \
php7-fpm \
php7-gd \
php7-iconv \
php7-json \
php7-mbstring \
php7-mysqli \
php7-opcache \
php7-openssl \
php7-pdo \
php7-pdo_mysql \
php7-pdo_pgsql \
php7-mysqli \
php7-phar \
php7-session \
php7-simplexml \
php7-tokenizer \
Expand All @@ -26,4 +31,15 @@ RUN --mount=type=cache,target=/var/cache/apk \
&& \
cleanup.sh

# https://getcomposer.org/download/
RUN --mount=id=downloads,type=cache,target=/opt/downloads \
DOWNLOAD_CACHE_DIRECTORY="/opt/downloads" && \
COMPOSER_VERSION="2.0.4" && \
COMPOSER_FILE="composer.phar" && \
COMPOSER_URL="https://getcomposer.org/download/${COMPOSER_VERSION}/${COMPOSER_FILE}" && \
COMPOSER_SHA256="c3b2bc477429c923c69f7f9b137e06b2a93c6a1e192d40ffad1741ee5d54760d" && \
download.sh --url "${COMPOSER_URL}" --sha256 "${COMPOSER_SHA256}" "${DOWNLOAD_CACHE_DIRECTORY}" && \
cp "${DOWNLOAD_CACHE_DIRECTORY}/${COMPOSER_FILE}" /usr/bin/composer && \
chmod a+x /usr/bin/composer

COPY rootfs /
2 changes: 1 addition & 1 deletion nginx/rootfs/etc/confd/templates/php-fpm.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
; Pid file
; Note: the default prefix is /var
; Default Value: none
pid = run/php-fpm7.pid
;pid = run/php-fpm7.pid

; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
Expand Down
2 changes: 1 addition & 1 deletion nginx/rootfs/etc/confd/templates/www.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ group = nginx
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /var/run/php-fpm7/php-fpm7.sock
listen = php-fpm7.sock

; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
Expand Down
2 changes: 1 addition & 1 deletion nginx/rootfs/etc/services.d/fpm/run
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/execlineb -P
# -*- mode: sh -*-
# vi: set ft=sh:
/usr/sbin/php-fpm7
/usr/sbin/php-fpm7 --pid /var/run/php-fpm7/php-fpm7.pid --prefix /var/run/php-fpm7 --fpm-config /etc/php7/php-fpm.conf

0 comments on commit c8d7b88

Please sign in to comment.