Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom startup scripts #78

Merged
merged 5 commits into from
Dec 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Dockerfiles/prod/Dockerfile-5.2
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions Dockerfiles/prod/Dockerfile-5.3
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions Dockerfiles/prod/Dockerfile-5.4
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions Dockerfiles/prod/Dockerfile-5.5
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions Dockerfiles/prod/Dockerfile-5.6
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions Dockerfiles/prod/Dockerfile-7.0
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions Dockerfiles/prod/Dockerfile-7.1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions Dockerfiles/prod/Dockerfile-7.2
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions Dockerfiles/prod/Dockerfile-7.3
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions Dockerfiles/prod/Dockerfile-7.4
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN set -x \
locales-all \
postfix \
postfix-pcre \
cron \
rsyslog \
socat \
supervisor \
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions Dockerfiles/prod/data/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
###
Expand Down
4 changes: 0 additions & 4 deletions Dockerfiles/work/Dockerfile-5.2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Dockerfiles/work/Dockerfile-5.3
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Dockerfiles/work/Dockerfile-5.4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Dockerfiles/work/Dockerfile-5.5
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Dockerfiles/work/Dockerfile-5.6
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Dockerfiles/work/Dockerfile-7.0
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Dockerfiles/work/Dockerfile-7.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Dockerfiles/work/Dockerfile-7.2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Dockerfiles/work/Dockerfile-7.3
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions Dockerfiles/work/Dockerfile-7.4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Dockerfiles/work/data/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
###
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
Loading