Compare commits

...

6 Commits
0.58 ... 0.59

Author SHA1 Message Date
cytopia
e55469f7c1 Merge pull request #78 from devilbox/release-0.59
Custom startup scripts
2018-12-24 16:42:40 +01:00
cytopia
85991d2e3f Adding 'cron' binary 2018-12-24 13:58:30 +01:00
cytopia
70764c268c Add tests for custom startup scripts 2018-12-24 13:46:58 +01:00
cytopia
023ad2af60 Allow for custom user-supplied startup scripts 2018-12-24 13:46:41 +01:00
cytopia
4f1a054f8c Renamed entrypoint scripts to allow for more 2018-12-24 13:12:19 +01:00
cytopia
3f08a762f5 Use Docker VOLUME sections only where applicable 2018-12-24 12:19:42 +01:00
41 changed files with 140 additions and 78 deletions

View File

@@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
@@ -72,9 +73,6 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
###
### Volumes
###
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
@@ -72,9 +73,6 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
###
### Volumes
###
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
@@ -72,9 +73,6 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
###
### Volumes
###
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
@@ -72,9 +73,6 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
###
### Volumes
###
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
@@ -72,9 +73,6 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
###
### Volumes
###
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
@@ -72,9 +73,6 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
###
### Volumes
###
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
@@ -72,9 +73,6 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
###
### Volumes
###
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
@@ -72,9 +73,6 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
###
### Volumes
###
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
@@ -72,9 +73,6 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
###
### Volumes
###
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
@@ -72,9 +73,6 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
###
### Volumes
###
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
############################################################
# Functions
############################################################
###
### Execute custom uesr-supplied scripts
###
execute_custom_scripts() {
local script_dir="${1}"
local debug="${2}"
if [ ! -d "${script_dir}" ]; then
run "mkdir -p ${script_dir}" "${debug}"
fi
script_files="$( find "${script_dir}" -type f -iname '*.sh' )"
# loop over them line by line
IFS='
'
for script_f in ${script_files}; do
script_name="$( basename "${script_f}" )"
log "info" "Executing custom startup script: ${script_name}" "${debug}"
if ! bash "${script_f}"; then
log "err" "Failed to execute script" "${debug}"
exit 1
fi
done
}
############################################################
# Sanity Checks
############################################################
if ! command -v find >/dev/null 2>&1; then
echo "find not found, but required."
exit 1
fi
if ! command -v basename >/dev/null 2>&1; then
echo "basename not found, but required."
exit 1
fi

View File

@@ -178,6 +178,13 @@ enable_modules "ENABLE_MODULES" "${DEBUG_LEVEL}"
disable_modules "DISABLE_MODULES" "${DEBUG_LEVEL}"
###
### Run custom user supplied scripts
###
execute_custom_scripts "/startup.d" "${DEBUG_LEVEL}"
###
###
### Startup
###

View File

@@ -328,10 +328,6 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox
###
### Volumes
###
VOLUME /etc/bashrc-devilbox.d
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /shared/backups
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -371,10 +371,6 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox
###
### Volumes
###
VOLUME /etc/bashrc-devilbox.d
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /shared/backups
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -404,10 +404,6 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox
###
### Volumes
###
VOLUME /etc/bashrc-devilbox.d
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /shared/backups
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -418,10 +418,6 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox
###
### Volumes
###
VOLUME /etc/bashrc-devilbox.d
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /shared/backups
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -432,10 +432,6 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox
###
### Volumes
###
VOLUME /etc/bashrc-devilbox.d
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /shared/backups
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -432,10 +432,6 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox
###
### Volumes
###
VOLUME /etc/bashrc-devilbox.d
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /shared/backups
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -432,10 +432,6 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox
###
### Volumes
###
VOLUME /etc/bashrc-devilbox.d
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /shared/backups
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -432,10 +432,6 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox
###
### Volumes
###
VOLUME /etc/bashrc-devilbox.d
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /shared/backups
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -420,10 +420,6 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox
###
### Volumes
###
VOLUME /etc/bashrc-devilbox.d
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /shared/backups
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -420,10 +420,6 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox
###
### Volumes
###
VOLUME /etc/bashrc-devilbox.d
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /shared/backups
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -206,6 +206,12 @@ run "chmod 0755 /shared/httpd" "${DEBUG_LEVEL}"
update_ca_certificates "/ca" "${DEBUG_LEVEL}"
###
### Run custom user supplied scripts
###
execute_custom_scripts "/startup.d" "${DEBUG_LEVEL}"
###
### Startup
###

View File

@@ -760,7 +760,7 @@ Have a look at the following table to see all offered volumes for each Docker im
</thead>
<tbody>
<tr>
<td rowspan="5"><strong>prod</strong><br/><br/><strong>work</strong></td>
<td rowspan="6"><strong>prod</strong><br/><br/><strong>work</strong></td>
<td><code>/etc/php-custom.d</code></td>
<td>Mount this directory into your host computer and add custom <code>\*.ini</code> files in order to alter php behaviour.</td>
</tr>
@@ -772,6 +772,10 @@ Have a look at the following table to see all offered volumes for each Docker im
<td><code>/etc/php-modules.d</code></td>
<td>Mount this directory into your host computer and add custo <code>\*.so</code> files in order to add your php modules.<br/><br/><strong>Note:</strong>Your should then also provide a custom <code>\*.ini</code> file in order to actually load your custom provided module.</td>
</tr>
<tr>
<td><code>/startup.d</code></td>
<td>Any executable scripts ending by <code>\*.sh</code> found in this directory will be executed during startup. This is useful to supply additional commands (such as installing custom software) when the container starts up.</td>
</tr>
<tr>
<td><code>/var/log/php</code></td>
<td>When setting environment variable <code>DOCKER_LOGS</code> to <code>0</code>, log files will be available under this directory.</td>

View File

@@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
@@ -74,9 +75,6 @@ COPY ./data/supervisord.conf /etc/supervisor/supervisord.conf
###
### Volumes
###
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -246,10 +246,6 @@ COPY ./data/sudo-devilbox /etc/sudoers.d/devilbox
###
### Volumes
###
VOLUME /etc/bashrc-devilbox.d
VOLUME /etc/php-custom.d
VOLUME /etc/php-fpm-custom.d
VOLUME /etc/php-modules.d
VOLUME /shared/backups
VOLUME /var/log/php
VOLUME /var/mail

View File

@@ -0,0 +1,62 @@
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
IMAGE="${1}"
VERSION="${2}"
FLAVOUR="${3}"
# shellcheck disable=SC1090
. "${CWD}/../.lib.sh"
############################################################
# Tests
############################################################
###
### Check if PHP still starts up with working scripts
###
RUN_SH_HOST="$( mktemp -d )"
RUN_SH_CONT="/startup.d"
# Fix mount permissions
chmod 0777 "${RUN_SH_HOST}"
# Add a startup script to execute
printf "#!/bin/bash\\necho 'abcdefghijklmnopq';\\n" > "${RUN_SH_HOST}/myscript1.sh"
chmod +x "${RUN_SH_HOST}/myscript1.sh"
# Start PHP-FPM
did="$( docker_run "${IMAGE}:${VERSION}-${FLAVOUR}" "-e DEBUG_ENTRYPOINT=2 -e NEW_UID=$(id -u) -e NEW_GID=$(id -g) -v ${RUN_SH_HOST}:${RUN_SH_CONT}" )"
# Wait for both containers to be up and running
run "sleep 10"
# Check entrypoint for script run
if ! run "docker logs ${did} | grep 'myscript1.sh'"; then
docker_logs "${did}" || true
docker_stop "${did}" || true
rm -rf "${RUN_SH_HOST}"
echo "Failed"
exit 1
fi
# Check entrypoint for script output
if ! run "docker logs ${did} | grep 'abcdefghijklmnopq'"; then
docker_logs "${did}" || true
docker_stop "${did}" || true
rm -rf "${RUN_SH_HOST}"
echo "Failed"
exit 1
fi
# Cleanup
docker_stop "${did}"
rm -rf "${RUN_SH_HOST}"