BUGFIX: added splitted dockerfiles
This commit is contained in:
parent
3b25940cb7
commit
2c61095df0
38
Dockerfile.daemon
Normal file
38
Dockerfile.daemon
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
FROM php:8.1
|
||||||
|
RUN apt-get update -y && apt-get install -y git
|
||||||
|
ENV APACHE_DOCUMENT_ROOT=/var/www/webcron/public/
|
||||||
|
ENV WEBCRON_ROOT=/var/www/webcron/
|
||||||
|
ENV TZ=Europe/Brussels
|
||||||
|
ENV COMPOSER_ALLOW_SUPERUSER=1 DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
RUN git clone https://git.jeroened.be/webcron/webcron.git ${WEBCRON_ROOT}
|
||||||
|
|
||||||
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
|
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin
|
||||||
|
RUN set -eux; \
|
||||||
|
chmod uga+x /usr/local/bin/install-php-extensions && sync
|
||||||
|
|
||||||
|
RUN set -eux;install-php-extensions intl bcmath pdo_mysql opcache memcached pcntl zip
|
||||||
|
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
|
||||||
|
RUN printf "[PHP]\ndate.timezone = \"$TZ\"\n" > /usr/local/etc/php/conf.d/tzone.ini
|
||||||
|
|
||||||
|
COPY wait-for-it.sh /usr/local/bin/wait-for-it.sh
|
||||||
|
COPY entrypoint.daemon.sh /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
|
RUN set -eux; \
|
||||||
|
chown -R www-data:www-data ${WEBCRON_ROOT} && \
|
||||||
|
chmod uga+x /usr/local/bin/wait-for-it.sh && \
|
||||||
|
chmod uga+x /usr/local/bin/entrypoint.sh && sync
|
||||||
|
|
||||||
|
USER www-data
|
||||||
|
WORKDIR ${WEBCRON_ROOT}
|
||||||
|
RUN mv .env.sample .env
|
||||||
|
RUN composer install
|
||||||
|
|
||||||
|
RUN bash -c "if [ -n \"${VERSION}\" ] ; then echo ${VERSION} > ${WEBCRON_ROOT}/version ; fi"
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
52
Dockerfile.webui
Normal file
52
Dockerfile.webui
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
FROM node:16 as nodebuilder
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
RUN apt-get update -y && apt-get install -y git
|
||||||
|
|
||||||
|
RUN git clone https://git.jeroened.be/webcron/webcron.git /tmp/buildir/webcron
|
||||||
|
WORKDIR /tmp/buildir/webcron
|
||||||
|
RUN npm install
|
||||||
|
RUN npm run build
|
||||||
|
RUN rm -rf node_modules
|
||||||
|
|
||||||
|
FROM php:8.1-apache
|
||||||
|
ENV APACHE_DOCUMENT_ROOT=/var/www/webcron/public/
|
||||||
|
ENV WEBCRON_ROOT=/var/www/webcron/
|
||||||
|
ENV TZ=Europe/Brussels
|
||||||
|
ENV COMPOSER_ALLOW_SUPERUSER=1 DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
COPY --from=nodebuilder --chown=www-data:www-data /tmp/buildir/webcron ${WEBCRON_ROOT}
|
||||||
|
|
||||||
|
RUN sed -ri -e "s!/var/www/html!${APACHE_DOCUMENT_ROOT}!g" /etc/apache2/sites-available/*.conf
|
||||||
|
RUN sed -ri -e "s!/var/www/!${APACHE_DOCUMENT_ROOT}!g" /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
|
||||||
|
RUN a2enmod rewrite
|
||||||
|
|
||||||
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
|
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin
|
||||||
|
RUN set -eux; \
|
||||||
|
chmod uga+x /usr/local/bin/install-php-extensions && sync
|
||||||
|
|
||||||
|
RUN set -eux;install-php-extensions intl bcmath pdo_mysql opcache memcached pcntl zip
|
||||||
|
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
|
||||||
|
RUN printf "[PHP]\ndate.timezone = \"$TZ\"\n" > /usr/local/etc/php/conf.d/tzone.ini
|
||||||
|
|
||||||
|
COPY wait-for-it.sh /usr/local/bin/wait-for-it.sh
|
||||||
|
COPY apache2-foreground /usr/local/bin/apache2-foreground
|
||||||
|
COPY entrypoint.webui.sh /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
|
RUN set -eux; \
|
||||||
|
chmod uga+x /usr/local/bin/wait-for-it.sh && \
|
||||||
|
chmod uga+x /usr/local/bin/entrypoint.sh && \
|
||||||
|
chmod uga+x /usr/local/bin/apache2-foreground && sync
|
||||||
|
|
||||||
|
USER www-data
|
||||||
|
WORKDIR ${WEBCRON_ROOT}
|
||||||
|
RUN mv .env.sample .env
|
||||||
|
RUN composer install
|
||||||
|
|
||||||
|
RUN bash -c "if [ -n \"${VERSION}\" ] ; then echo ${VERSION} > ${WEBCRON_ROOT}/version ; fi"
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
152
entrypoint.daemon.sh
Normal file
152
entrypoint.daemon.sh
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Now in entrypoint.sh for Webcron Management"
|
||||||
|
echo "Script: 1.0.21 (2022-02-17)"
|
||||||
|
echo "User: '$(whoami)'"
|
||||||
|
echo "Group: '$(id -g -n)'"
|
||||||
|
echo "Working dir: '$(pwd)'"
|
||||||
|
|
||||||
|
# https://github.com/docker-library/wordpress/blob/master/docker-entrypoint.sh
|
||||||
|
# usage: file_env VAR [DEFAULT]
|
||||||
|
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
|
||||||
|
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
|
||||||
|
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
|
||||||
|
file_env() {
|
||||||
|
local var="$1"
|
||||||
|
local fileVar="${var}_FILE"
|
||||||
|
local def="${2:-}"
|
||||||
|
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
|
||||||
|
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
local val="$def"
|
||||||
|
if [ "${!var:-}" ]; then
|
||||||
|
val="${!var}"
|
||||||
|
elif [ "${!fileVar:-}" ]; then
|
||||||
|
val="$(< "${!fileVar}")"
|
||||||
|
fi
|
||||||
|
export "$var"="$val"
|
||||||
|
unset "$fileVar"
|
||||||
|
}
|
||||||
|
|
||||||
|
# envs that can be appended with _FILE
|
||||||
|
envs=(
|
||||||
|
APP_ENV
|
||||||
|
DATABASE_URL
|
||||||
|
DEMO_MODE
|
||||||
|
DEMO_USER
|
||||||
|
DEMO_PASS
|
||||||
|
APP_SECRET
|
||||||
|
ENCRYPTION_METHOD
|
||||||
|
HASHING_METHOD
|
||||||
|
DEBUG
|
||||||
|
COOKIE_LIFETIME
|
||||||
|
TRUSTED_PROXIES
|
||||||
|
MAILER_DSN
|
||||||
|
MAILER_FROM
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "Now parsing _FILE variables."
|
||||||
|
for e in "${envs[@]}"; do
|
||||||
|
file_env "$e"
|
||||||
|
done
|
||||||
|
echo "done!"
|
||||||
|
|
||||||
|
|
||||||
|
echo "Dump envs to .env..."
|
||||||
|
rm -rf .env
|
||||||
|
touch .env
|
||||||
|
for e in "${envs[@]}"; do
|
||||||
|
echo "$e=\"${!e}\"" >> .env
|
||||||
|
done
|
||||||
|
echo "Dump auto load..."
|
||||||
|
composer dump-autoload
|
||||||
|
|
||||||
|
echo "Current working dir is '$(pwd)'"
|
||||||
|
echo "Parsing database url."
|
||||||
|
|
||||||
|
DB_CONNECTION=$(php -r "echo parse_url('$DATABASE_URL')['scheme'];")
|
||||||
|
DB_HOST=$(php -r "echo parse_url('$DATABASE_URL')['host'];")
|
||||||
|
DB_PORT=$(php -r "echo parse_url('$DATABASE_URL')['port'];")
|
||||||
|
DB_NAME=$(php -r "echo parse_url('$DATABASE_URL')['path'];")
|
||||||
|
echo "Wait for the database."
|
||||||
|
if [[ -z "$DB_PORT" ]]; then
|
||||||
|
if [[ $DB_CONNECTION == "mysql" ]]; then
|
||||||
|
DB_PORT=3306
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ -n "$DB_PORT" ]]; then
|
||||||
|
/usr/local/bin/wait-for-it.sh "${DB_HOST}:${DB_PORT}" -t 60 -- echo "DB is up."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Wait another 5 seconds in case the DB needs to boot."
|
||||||
|
sleep 5
|
||||||
|
echo "Done waiting for the DB to boot."
|
||||||
|
|
||||||
|
if [[ $DKR_BUILD_LOCALE == "true" ]]; then
|
||||||
|
echo "Will build all locales..."
|
||||||
|
locale-gen
|
||||||
|
else
|
||||||
|
echo "Will not build the locales..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Run various symfony commands..."
|
||||||
|
|
||||||
|
if [[ $DKR_RUN_MIGRATION == "false" ]]; then
|
||||||
|
echo "Will NOT run migration commands."
|
||||||
|
else
|
||||||
|
echo "Running migration commands..."
|
||||||
|
php bin/console doctrine:migrations:migrate --no-interaction
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Current working dir is '$(pwd)'"
|
||||||
|
|
||||||
|
|
||||||
|
# there are 0 upgrade commands
|
||||||
|
if [[ $DKR_RUN_UPGRADE == "false" ]]; then
|
||||||
|
echo 'Will NOT run upgrade commands.'
|
||||||
|
else
|
||||||
|
echo 'Running upgrade commands...'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# there are 0 verify commands
|
||||||
|
if [[ $DKR_RUN_VERIFY == "false" ]]; then
|
||||||
|
echo 'Will NOT run verification commands.'
|
||||||
|
else
|
||||||
|
echo 'Running verification commands...'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# report commands
|
||||||
|
if [[ $DKR_RUN_REPORT == "false" ]]; then
|
||||||
|
echo 'Will NOT run report commands.'
|
||||||
|
else
|
||||||
|
echo 'Running report commands...'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# report commands
|
||||||
|
if [[ $DEMO_MODE == "true" ]]; then
|
||||||
|
echo 'Installing demo data'
|
||||||
|
su - www-data -s "/bin/bash" -c "php $WEBCRON_ROOT/bin/console webcron:demodata"
|
||||||
|
fi
|
||||||
|
|
||||||
|
php bin/console cache:clear
|
||||||
|
php bin/console cache:warm
|
||||||
|
|
||||||
|
# set docker var.
|
||||||
|
export IS_DOCKER=true
|
||||||
|
|
||||||
|
if [ -z $APACHE_RUN_USER ]
|
||||||
|
then
|
||||||
|
APACHE_RUN_USER='www-data'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $APACHE_RUN_GROUP ]
|
||||||
|
then
|
||||||
|
APACHE_RUN_GROUP='www-data'
|
||||||
|
fi
|
||||||
|
|
||||||
|
chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $WEBCRON_ROOT/var
|
||||||
|
|
||||||
|
echo "Go!"
|
||||||
|
|
||||||
|
su - www-data -s "/bin/bash" -c "php $WEBCRON_ROOT/bin/console webcron:daemon"
|
151
entrypoint.webui.sh
Normal file
151
entrypoint.webui.sh
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Now in entrypoint.sh for Webcron Management"
|
||||||
|
echo "Script: 1.0.21 (2022-02-17)"
|
||||||
|
echo "User: '$(whoami)'"
|
||||||
|
echo "Group: '$(id -g -n)'"
|
||||||
|
echo "Working dir: '$(pwd)'"
|
||||||
|
|
||||||
|
# https://github.com/docker-library/wordpress/blob/master/docker-entrypoint.sh
|
||||||
|
# usage: file_env VAR [DEFAULT]
|
||||||
|
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
|
||||||
|
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
|
||||||
|
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
|
||||||
|
file_env() {
|
||||||
|
local var="$1"
|
||||||
|
local fileVar="${var}_FILE"
|
||||||
|
local def="${2:-}"
|
||||||
|
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
|
||||||
|
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
local val="$def"
|
||||||
|
if [ "${!var:-}" ]; then
|
||||||
|
val="${!var}"
|
||||||
|
elif [ "${!fileVar:-}" ]; then
|
||||||
|
val="$(< "${!fileVar}")"
|
||||||
|
fi
|
||||||
|
export "$var"="$val"
|
||||||
|
unset "$fileVar"
|
||||||
|
}
|
||||||
|
|
||||||
|
# envs that can be appended with _FILE
|
||||||
|
envs=(
|
||||||
|
APP_ENV
|
||||||
|
DATABASE_URL
|
||||||
|
DEMO_MODE
|
||||||
|
DEMO_USER
|
||||||
|
DEMO_PASS
|
||||||
|
APP_SECRET
|
||||||
|
ENCRYPTION_METHOD
|
||||||
|
HASHING_METHOD
|
||||||
|
DEBUG
|
||||||
|
COOKIE_LIFETIME
|
||||||
|
TRUSTED_PROXIES
|
||||||
|
MAILER_DSN
|
||||||
|
MAILER_FROM
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "Now parsing _FILE variables."
|
||||||
|
for e in "${envs[@]}"; do
|
||||||
|
file_env "$e"
|
||||||
|
done
|
||||||
|
echo "done!"
|
||||||
|
|
||||||
|
|
||||||
|
echo "Dump envs to .env..."
|
||||||
|
rm -rf .env
|
||||||
|
touch .env
|
||||||
|
for e in "${envs[@]}"; do
|
||||||
|
echo "$e=\"${!e}\"" >> .env
|
||||||
|
done
|
||||||
|
echo "Dump auto load..."
|
||||||
|
composer dump-autoload
|
||||||
|
|
||||||
|
echo "Current working dir is '$(pwd)'"
|
||||||
|
echo "Parsing database url."
|
||||||
|
|
||||||
|
DB_CONNECTION=$(php -r "echo parse_url('$DATABASE_URL')['scheme'];")
|
||||||
|
DB_HOST=$(php -r "echo parse_url('$DATABASE_URL')['host'];")
|
||||||
|
DB_PORT=$(php -r "echo parse_url('$DATABASE_URL')['port'];")
|
||||||
|
DB_NAME=$(php -r "echo parse_url('$DATABASE_URL')['path'];")
|
||||||
|
echo "Wait for the database."
|
||||||
|
if [[ -z "$DB_PORT" ]]; then
|
||||||
|
if [[ $DB_CONNECTION == "mysql" ]]; then
|
||||||
|
DB_PORT=3306
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ -n "$DB_PORT" ]]; then
|
||||||
|
/usr/local/bin/wait-for-it.sh "${DB_HOST}:${DB_PORT}" -t 60 -- echo "DB is up."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Wait another 5 seconds in case the DB needs to boot."
|
||||||
|
sleep 5
|
||||||
|
echo "Done waiting for the DB to boot."
|
||||||
|
|
||||||
|
if [[ $DKR_BUILD_LOCALE == "true" ]]; then
|
||||||
|
echo "Will build all locales..."
|
||||||
|
locale-gen
|
||||||
|
else
|
||||||
|
echo "Will not build the locales..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Run various symfony commands..."
|
||||||
|
|
||||||
|
if [[ $DKR_RUN_MIGRATION == "false" ]]; then
|
||||||
|
echo "Will NOT run migration commands."
|
||||||
|
else
|
||||||
|
echo "Running migration commands..."
|
||||||
|
php bin/console doctrine:migrations:migrate --no-interaction
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Current working dir is '$(pwd)'"
|
||||||
|
|
||||||
|
|
||||||
|
# there are 0 upgrade commands
|
||||||
|
if [[ $DKR_RUN_UPGRADE == "false" ]]; then
|
||||||
|
echo 'Will NOT run upgrade commands.'
|
||||||
|
else
|
||||||
|
echo 'Running upgrade commands...'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# there are 0 verify commands
|
||||||
|
if [[ $DKR_RUN_VERIFY == "false" ]]; then
|
||||||
|
echo 'Will NOT run verification commands.'
|
||||||
|
else
|
||||||
|
echo 'Running verification commands...'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# report commands
|
||||||
|
if [[ $DKR_RUN_REPORT == "false" ]]; then
|
||||||
|
echo 'Will NOT run report commands.'
|
||||||
|
else
|
||||||
|
echo 'Running report commands...'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# report commands
|
||||||
|
if [[ $DEMO_MODE == "true" ]]; then
|
||||||
|
echo 'Installing demo data'
|
||||||
|
su - www-data -s "/bin/bash" -c "php $WEBCRON_ROOT/bin/console webcron:demodata"
|
||||||
|
fi
|
||||||
|
|
||||||
|
php bin/console cache:clear
|
||||||
|
php bin/console cache:warm
|
||||||
|
|
||||||
|
# set docker var.
|
||||||
|
export IS_DOCKER=true
|
||||||
|
|
||||||
|
if [ -z $APACHE_RUN_USER ]
|
||||||
|
then
|
||||||
|
APACHE_RUN_USER='www-data'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $APACHE_RUN_GROUP ]
|
||||||
|
then
|
||||||
|
APACHE_RUN_GROUP='www-data'
|
||||||
|
fi
|
||||||
|
|
||||||
|
chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $WEBCRON_ROOT/var
|
||||||
|
|
||||||
|
|
||||||
|
exec apache2-foreground
|
Loading…
Reference in New Issue
Block a user