Dockerfile.alpine 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. FROM alpine:3.23
  2. RUN apk add --quiet --no-cache \
  3. bash \
  4. apache2 \
  5. ca-certificates \
  6. php \
  7. php-apache2 \
  8. php-ctype \
  9. php-phar \
  10. php-gd \
  11. php-openssl \
  12. php-pdo \
  13. php-pdo_mysql \
  14. php-pdo_pgsql \
  15. php-pdo_sqlite \
  16. php-pgsql \
  17. php-session \
  18. php-sqlite3
  19. RUN ln -sf /dev/stdout /var/log/apache2/access.log && \
  20. ln -sf /dev/stderr /var/log/apache2/error.log
  21. # This image has two PHP installs: the FROM php:8-alpine binary (conf.d at
  22. # /usr/local/etc/php/conf.d) and the apk-installed php-apache2 (conf.d at
  23. # /etc/phpXX/conf.d). mod_php uses the apk one — glob /etc/php*/conf.d to
  24. # find it without pinning the PHP major.
  25. COPY docker/librespeed-php.ini /tmp/librespeed-php.ini
  26. RUN set -eu; \
  27. scan_dir=""; \
  28. for d in /etc/php*/conf.d; do \
  29. [ -d "$d" ] && scan_dir="$d" && break; \
  30. done; \
  31. if [ -z "$scan_dir" ]; then \
  32. echo "ERROR: no /etc/php*/conf.d directory found; apk php-apache2 install layout may have changed" >&2; \
  33. exit 1; \
  34. fi; \
  35. install -D -m 0644 /tmp/librespeed-php.ini "$scan_dir/99-librespeed.ini"; \
  36. rm /tmp/librespeed-php.ini
  37. # Prepare files and folders
  38. RUN mkdir -p /speedtest/
  39. # Copy sources
  40. COPY backend/ /speedtest/backend
  41. COPY frontend/ /speedtest/frontend
  42. COPY results/*.php /speedtest/results/
  43. COPY results/*.ttf /speedtest/results/
  44. COPY *.js /speedtest/
  45. COPY index.html /speedtest/
  46. COPY index-classic.html /speedtest/
  47. COPY index-modern.html /speedtest/
  48. COPY config.json /speedtest/
  49. COPY stability.html /speedtest/
  50. COPY favicon.ico /speedtest/
  51. COPY docker/entrypoint.sh /
  52. # Prepare default environment variables
  53. ENV TITLE=LibreSpeed
  54. ENV TAGLINE="No Flash, No Java, No Websockets, No Bullsh*t"
  55. ENV MODE=standalone
  56. ENV PASSWORD=password
  57. ENV TELEMETRY=false
  58. ENV ENABLE_ID_OBFUSCATION=false
  59. ENV REDACT_IP_ADDRESSES=false
  60. ENV WEBPORT=8080
  61. ENV USE_NEW_DESIGN=false
  62. # https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
  63. STOPSIGNAL SIGWINCH
  64. # Add labels for better metadata
  65. LABEL org.opencontainers.image.title="LibreSpeed"
  66. LABEL org.opencontainers.image.description="A Free and Open Source speed test that you can host on your server(s)"
  67. LABEL org.opencontainers.image.vendor="LibreSpeed"
  68. LABEL org.opencontainers.image.url="https://github.com/librespeed/speedtest"
  69. LABEL org.opencontainers.image.source="https://github.com/librespeed/speedtest"
  70. LABEL org.opencontainers.image.documentation="https://github.com/librespeed/speedtest/blob/master/doc_docker.md"
  71. LABEL org.opencontainers.image.licenses="LGPL-3.0-or-later"
  72. # Add health check
  73. HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
  74. CMD wget --no-verbose --tries=1 --spider http://localhost:${WEBPORT}/ || exit 1
  75. WORKDIR /var/www/html
  76. # Final touches
  77. EXPOSE ${WEBPORT}
  78. CMD ["bash", "/entrypoint.sh"]