Files
docker-daloradius/Dockerfile
Ryan Hamilton 4a3f761ead
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 2m41s
Change pear install method and refactor Dockerfile for clarity
2025-08-12 08:08:02 -05:00

77 lines
2.7 KiB
Docker

# syntax=docker/dockerfile:1.7
############################################
# Stage 1: fetch source (pin to tag/sha)
############################################
FROM alpine:3.20 AS source
ARG DALOREF=master
ARG MIRROR_URL=https://gitea.portal.tulsacounty.org/external-repos/daloradius.git
RUN apk add --no-cache git && \
git clone --depth=1 --branch ${DALOREF} ${MIRROR_URL} /src
############################################
# Stage 2: runtime (PHP 8, Apache)
############################################
FROM php:8.3-apache
ENV TZ=UTC
# System deps (no php-pear package here)
RUN apt-get update && apt-get -y upgrade && \
apt-get install -y --no-install-recommends \
ca-certificates tzdata curl git \
libpng-dev libjpeg62-turbo-dev libfreetype6-dev libwebp-dev \
libmariadb-dev \
&& rm -rf /var/lib/apt/lists/* && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone && \
update-ca-certificates -f
# PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && \
docker-php-ext-install gd mysqli pdo_mysql
# Install PEAR manually, then required PEAR packages
RUN curl -fsSL https://pear.php.net/install-pear-nozlib.phar -o /tmp/pear.phar \
&& php /tmp/pear.phar \
&& rm /tmp/pear.phar \
&& pear channel-update pear.php.net \
&& pear install -a -f DB \
&& pear install -a -f Mail \
&& pear install -a -f Mail_Mime
# App
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/contrib/scripts/apache-config.sh /usr/local/bin/apache-config.sh
# Apache + perms
RUN chown -R www-data:www-data /var/www/html && \
chmod +x /usr/local/bin/apache-config.sh && \
a2enmod rewrite
# Entry script renders config from env
COPY <<'EOF' /entrypoint.sh
#!/usr/bin/env bash
set -euo pipefail
: "${DBHOST:?set DBHOST}"
: "${DBNAME:?set DBNAME}"
: "${DBUSER:?set DBUSER}"
: "${DBPASS:?set DBPASS}"
sed -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_PASS'\].*|\$configValues['CONFIG_DB_PASS'] = '${DBPASS}';|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
[ -x /usr/local/bin/apache-config.sh ] && /usr/local/bin/apache-config.sh || true
exec apachectl -DFOREGROUND
EOF
RUN chmod +x /entrypoint.sh
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=5s --retries=5 CMD curl -fsS http://localhost/ || exit 1
ENTRYPOINT ["/entrypoint.sh"]