speedtest/Dockerfile.alpine

79 lines
2.5 KiB
Text
Executable file

FROM php:8.3-alpine3.19
# Use the mlocati helper to install PHP extensions in a platform-agnostic way.
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
# Install runtime packages and let the helper install/compile PHP extensions
RUN apk add --no-cache \
bash \
apache2 \
wget \
curl \
&& apk add --no-cache --virtual .build-deps \
build-base \
autoconf \
libpng-dev \
libjpeg-turbo-dev \
libwebp-dev \
freetype-dev \
libxml2-dev \
mariadb-connector-c-dev \
postgresql-dev \
sqlite-dev \
&& install-php-extensions iconv gd pdo pdo_mysql pdo_pgsql pdo_sqlite pgsql zip \
&& apk del .build-deps
# Note: PHP extensions are provided via Alpine `php-*` packages above.
# The docker-php-extension-installer is redundant when using those packages,
# so it's intentionally removed to simplify the image.
RUN ln -sf /dev/stdout /var/log/apache2/access.log && \
ln -sf /dev/stderr /var/log/apache2/error.log
# Prepare files and folders
RUN mkdir -p /speedtest/
# Copy sources
COPY backend/ /speedtest/backend
COPY results/*.php /speedtest/results/
COPY results/*.ttf /speedtest/results/
COPY *.js /speedtest/
COPY favicon.ico /speedtest/
COPY docker/servers.json /servers.json
COPY docker/*.php /speedtest/
COPY docker/entrypoint.sh /
# Prepare default environment variables
ENV TITLE=LibreSpeed
ENV MODE=standalone
ENV PASSWORD=password
ENV TELEMETRY=false
ENV ENABLE_ID_OBFUSCATION=false
ENV REDACT_IP_ADDRESSES=false
ENV WEBPORT=8080
# https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
STOPSIGNAL SIGWINCH
# Add labels for better metadata
LABEL org.opencontainers.image.title="LibreSpeed"
LABEL org.opencontainers.image.description="A Free and Open Source speed test that you can host on your server(s)"
LABEL org.opencontainers.image.vendor="LibreSpeed"
LABEL org.opencontainers.image.url="https://github.com/librespeed/speedtest"
LABEL org.opencontainers.image.source="https://github.com/librespeed/speedtest"
LABEL org.opencontainers.image.documentation="https://github.com/librespeed/speedtest/blob/master/doc_docker.md"
LABEL org.opencontainers.image.licenses="LGPL-3.0-or-later"
# Add health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:${WEBPORT}/ || exit 1
WORKDIR /var/www/html
# Final touches
EXPOSE ${WEBPORT}
CMD ["bash", "/entrypoint.sh"]