#!/bin/bash echo "Now in entrypoint.sh for Website" 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 APP_SECRET DATADIR TRUSTED_PROXIES ) 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)'" if [[ $DKR_BUILD_LOCALE == "true" ]]; then echo "Will build all locales..." locale-gen else echo "Will not build the locales..." 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 # 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 if [[ $(stat -c '%U' $WEBSITE_ROOT) != $APACHE_RUN_USER ]]; then chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $WEBSITE_ROOT fi # refresh commands if [[ $DKR_RUN_REFRESH == "false" ]]; then echo 'Will NOT run refresh commands.' else echo 'Running refresh commands...' php $WEBSITE_ROOT/bin/console refresh fi php $WEBSITE_ROOT/bin/console cache:clear php $WEBSITE_ROOT/bin/console cache:warm echo "Go!" exec apache2-foreground