fix Apache configuration and entrypoint script logic
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 2m47s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 2m47s
This commit is contained in:
35
Dockerfile
35
Dockerfile
@@ -44,33 +44,42 @@ COPY --from=source /src/app/ /var/www/html/daloradius/
|
|||||||
COPY --from=source /src/app/common/includes/daloradius.conf.php.sample /opt/daloradius.conf.php.tmpl
|
COPY --from=source /src/app/common/includes/daloradius.conf.php.sample /opt/daloradius.conf.php.tmpl
|
||||||
COPY --from=source /src/contrib/scripts/apache-config.sh /usr/local/bin/apache-config.sh
|
COPY --from=source /src/contrib/scripts/apache-config.sh /usr/local/bin/apache-config.sh
|
||||||
|
|
||||||
# Apache + perms
|
# Apache + perms (+ run helper to set DocumentRoot=/var/www/html/daloradius)
|
||||||
RUN chown -R www-data:www-data /var/www/html && \
|
RUN chown -R www-data:www-data /var/www/html && \
|
||||||
chmod +x /usr/local/bin/apache-config.sh && \
|
chmod +x /usr/local/bin/apache-config.sh && \
|
||||||
a2enmod rewrite
|
a2enmod rewrite && \
|
||||||
|
/usr/local/bin/apache-config.sh && \
|
||||||
|
printf 'ServerName localhost\n' > /etc/apache2/conf-available/servername.conf && a2enconf servername
|
||||||
|
|
||||||
# Entry script renders config from env
|
|
||||||
|
# Entry script renders config from env only if not bind-mounted or if forced
|
||||||
COPY <<'EOF' /entrypoint.sh
|
COPY <<'EOF' /entrypoint.sh
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
: "${DBHOST:?set DBHOST}"
|
CFG="/var/www/html/daloradius/common/includes/daloradius.conf.php"
|
||||||
: "${DBNAME:?set DBNAME}"
|
TMPL="/opt/daloradius.conf.php.tmpl"
|
||||||
: "${DBUSER:?set DBUSER}"
|
|
||||||
: "${DBPASS:?set DBPASS}"
|
|
||||||
|
|
||||||
sed -e "s|\$configValues\['CONFIG_DB_HOST'\].*|\$configValues['CONFIG_DB_HOST'] = '${DBHOST}';|g" \
|
# If no config present, seed from template
|
||||||
|
if [ ! -f "$CFG" ]; then
|
||||||
|
cp "$TMPL" "$CFG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Only edit if envs are provided and not explicitly skipped
|
||||||
|
if [ "${FORCE_RENDER:-0}" = "1" ] || [ ! -s "$CFG" ]; then
|
||||||
|
: "${DBHOST:?set DBHOST}"; : "${DBNAME:?set DBNAME}"; : "${DBUSER:?set DBUSER}"; : "${DBPASS:?set DBPASS}"
|
||||||
|
sed -i \
|
||||||
|
-e "s|\$configValues\['CONFIG_DB_HOST'\].*|\$configValues['CONFIG_DB_HOST'] = '${DBHOST}';|g" \
|
||||||
-e "s|\$configValues\['CONFIG_DB_USER'\].*|\$configValues['CONFIG_DB_USER'] = '${DBUSER}';|g" \
|
-e "s|\$configValues\['CONFIG_DB_USER'\].*|\$configValues['CONFIG_DB_USER'] = '${DBUSER}';|g" \
|
||||||
-e "s|\$configValues\['CONFIG_DB_PASS'\].*|\$configValues['CONFIG_DB_PASS'] = '${DBPASS}';|g" \
|
-e "s|\$configValues\['CONFIG_DB_PASS'\].*|\$configValues['CONFIG_DB_PASS'] = '${DBPASS}';|g" \
|
||||||
-e "s|\$configValues\['CONFIG_DB_NAME'\].*|\$configValues['CONFIG_DB_NAME'] = '${DBNAME}';|g" \
|
-e "s|\$configValues\['CONFIG_DB_NAME'\].*|\$configValues['CONFIG_DB_NAME'] = '${DBNAME}';|g" \
|
||||||
/opt/daloradius.conf.php.tmpl > /var/www/html/daloradius/common/includes/daloradius.conf.php
|
"$CFG"
|
||||||
|
fi
|
||||||
|
|
||||||
[ -x /usr/local/bin/apache-config.sh ] && /usr/local/bin/apache-config.sh || true
|
|
||||||
exec apachectl -DFOREGROUND
|
exec apachectl -DFOREGROUND
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --retries=5 CMD curl -fsS http://localhost/ || exit 1
|
||||||
|
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
EXPOSE 80
|
|
||||||
HEALTHCHECK --interval=30s --timeout=5s --retries=5 CMD curl -fsS http://localhost/ || exit 1
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
|
||||||
|
Reference in New Issue
Block a user