Skip to content

Commit a9e6f36

Browse files
committed
export source code
0 parents  commit a9e6f36

File tree

255 files changed

+30024
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

255 files changed

+30024
-0
lines changed

.docker/apache/vhost.conf

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
ServerName localhost
2+
3+
<VirtualHost *:80>
4+
ServerName pccd.dites.cat
5+
AddDefaultCharset utf-8
6+
AddCharset utf-8 .css .js .svg .xml
7+
DocumentRoot /srv/app/docroot
8+
ErrorDocument 400 /400.html
9+
ErrorDocument 401 /401.html
10+
ErrorDocument 403 /403.html
11+
ErrorDocument 404 /404.html
12+
ErrorDocument 500 /500.html
13+
FileETag None
14+
ErrorLog /var/log/apache2/error.log
15+
CustomLog /var/log/apache2/access.log combined
16+
17+
<Directory "/srv/app/docroot">
18+
Require all granted
19+
AllowOverride None
20+
</Directory>
21+
22+
# Route all non-file requests to index.php (routing handled in PHP).
23+
FallbackResource /index.php
24+
25+
<IfModule mod_headers.c>
26+
Header always set Cross-Origin-Opener-Policy "same-origin"
27+
Header always set Strict-Transport-Security "max-age=31536000"
28+
Header always set X-Content-Type-Options "nosniff"
29+
30+
<FilesMatch "(?i)\.(avif|css|gif|ico|jpg|js|mp3|png|svg|webp)$">
31+
Header set Cache-Control "public, max-age=31536000, immutable"
32+
</FilesMatch>
33+
</IfModule>
34+
35+
<IfModule mod_filter.c>
36+
<IfModule mod_brotli.c>
37+
AddOutputFilterByType BROTLI_COMPRESS application/javascript
38+
AddOutputFilterByType BROTLI_COMPRESS application/json
39+
AddOutputFilterByType BROTLI_COMPRESS application/xml
40+
AddOutputFilterByType BROTLI_COMPRESS image/svg+xml
41+
AddOutputFilterByType BROTLI_COMPRESS text/css
42+
AddOutputFilterByType BROTLI_COMPRESS text/html
43+
AddOutputFilterByType BROTLI_COMPRESS text/javascript
44+
AddOutputFilterByType BROTLI_COMPRESS text/plain
45+
AddOutputFilterByType BROTLI_COMPRESS text/xml
46+
</IfModule>
47+
48+
<IfModule mod_deflate.c>
49+
AddOutputFilterByType DEFLATE application/javascript
50+
AddOutputFilterByType DEFLATE application/json
51+
AddOutputFilterByType DEFLATE application/xml
52+
AddOutputFilterByType DEFLATE image/svg+xml
53+
AddOutputFilterByType DEFLATE text/css
54+
AddOutputFilterByType DEFLATE text/html
55+
AddOutputFilterByType DEFLATE text/javascript
56+
AddOutputFilterByType DEFLATE text/plain
57+
AddOutputFilterByType DEFLATE text/xml
58+
</IfModule>
59+
</IfModule>
60+
</VirtualHost>

.docker/build.Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Unpinned version intentional - this image is rarely used
2+
FROM debian:stable-slim
3+
LABEL maintainer="Pere Orga pere@orga.cat"
4+
LABEL description="Debian-based image for building a new release 100% inside Docker (not usually tested)."
5+
6+
WORKDIR /srv/app
7+
8+
COPY apt_dev_deps.txt .
9+
10+
# hadolint ignore=SC2046 # We want word splitting to pass packages as separate arguments
11+
RUN apt-get update \
12+
&& apt-get install --no-install-recommends -y $(cat apt_dev_deps.txt) \
13+
&& apt-get clean \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
RUN npx playwright install --with-deps chromium

.docker/dev.Dockerfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
ARG PHP_IMAGE_TAG=8.5.2-apache-trixie
2+
3+
FROM php:${PHP_IMAGE_TAG}
4+
LABEL maintainer="Pere Orga pere@orga.cat"
5+
LABEL description="Debian-based image with Apache and mod_php. Used for development."
6+
7+
ARG DOCKER_PHP_EXTENSION_INSTALLER_VERSION=2.9.30
8+
ARG profiler
9+
10+
WORKDIR /srv/app
11+
12+
# Install install-php-extensions
13+
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/download/${DOCKER_PHP_EXTENSION_INSTALLER_VERSION}/install-php-extensions /usr/local/bin/
14+
15+
# Remove some Apache default settings provided by Debian
16+
# Enable Apache modules
17+
# Use PHP default development settings
18+
# Install PHP extensions (intl is used for offline reports)
19+
RUN rm -f /etc/apache2/mods-enabled/deflate.conf /etc/apache2/mods-enabled/alias.conf && \
20+
a2enmod headers brotli && \
21+
cat /usr/local/etc/php/php.ini-development > /usr/local/etc/php/php.ini && \
22+
install-php-extensions apcu gd intl pdo_mysql
23+
24+
# Copy configuration files
25+
COPY .docker/apache/vhost.conf /etc/apache2/sites-available/000-default.conf
26+
27+
# Project files are mounted via volume in docker-compose.yml
28+
29+
# SPX profiler
30+
RUN if [ "$profiler" = "spx" ]; then \
31+
install-php-extensions spx && \
32+
{ \
33+
echo "[spx]"; \
34+
echo "spx.http_enabled = 1"; \
35+
echo "spx.http_ip_whitelist = \"*\""; \
36+
echo "spx.http_key = \"dev\""; \
37+
} > /usr/local/etc/php/conf.d/spx.ini; \
38+
fi
39+
40+
# XHProf profiler
41+
RUN if [ "$profiler" = "xhprof" ]; then \
42+
install-php-extensions xhprof && \
43+
sed -i '/<\/VirtualHost>/d' /etc/apache2/sites-available/000-default.conf && \
44+
{ \
45+
echo "Alias /admin/xhprof /usr/local/lib/php/xhprof_html"; \
46+
echo "<Directory /usr/local/lib/php/xhprof_html/>"; \
47+
echo " Options Indexes FollowSymLinks"; \
48+
echo " AllowOverride FileInfo"; \
49+
echo " Require all granted"; \
50+
echo " php_value auto_prepend_file none"; \
51+
echo " php_value memory_limit 1024M"; \
52+
echo "</Directory>"; \
53+
} >> /etc/apache2/sites-available/000-default.conf; \
54+
echo '</VirtualHost>' >> /etc/apache2/sites-available/000-default.conf && \
55+
{ \
56+
echo "[xhprof]"; \
57+
echo "auto_prepend_file = /srv/app/src/xhprof.php"; \
58+
echo "xhprof.collect_additional_info = 1"; \
59+
echo "xhprof.output_dir = /tmp"; \
60+
} > /usr/local/etc/php/conf.d/xhprof.ini; \
61+
fi

.docker/fpm.Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM alpine:3.23
2+
LABEL maintainer="Pere Orga pere@orga.cat"
3+
LABEL description="Alpine-based image with PHP-FPM for improved concurrency."
4+
5+
# Using Alpine's PHP packages instead of official php:fpm-alpine image avoids the need for
6+
# docker-php-ext-install or install-php-extensions, and apk is faster for installing extensions.
7+
ARG PHP_VERSION=85
8+
9+
# ENV from ARGs needed for production deployment (values baked into image at build time)
10+
ARG ARG_MYSQL_DB
11+
ARG ARG_MYSQL_PWD
12+
ARG ARG_MYSQL_USER
13+
ARG ARG_WEB_ADMIN_PWD
14+
ENV MYSQL_DATABASE=${ARG_MYSQL_DB}
15+
ENV MYSQL_PASSWORD=${ARG_MYSQL_PWD}
16+
ENV MYSQL_USER=${ARG_MYSQL_USER}
17+
ENV WEB_ADMIN_PASSWORD=${ARG_WEB_ADMIN_PWD}
18+
19+
WORKDIR /srv/app
20+
21+
RUN apk --no-cache --update add \
22+
php${PHP_VERSION}-fpm \
23+
php${PHP_VERSION}-apcu \
24+
php${PHP_VERSION}-gd \
25+
php${PHP_VERSION}-mbstring \
26+
php${PHP_VERSION}-pdo_mysql \
27+
php${PHP_VERSION}-session && \
28+
ln -s /usr/sbin/php-fpm${PHP_VERSION} /usr/sbin/php-fpm
29+
30+
COPY .docker/php/performance.ini /etc/php${PHP_VERSION}/conf.d/performance.ini
31+
COPY .docker/php/security.ini /etc/php${PHP_VERSION}/conf.d/security.ini
32+
COPY .docker/php/fpm.conf /etc/php${PHP_VERSION}/php-fpm.d/zzz-docker.conf
33+
34+
# Add only the specific files/directories accessed by PHP itself
35+
COPY src ./src
36+
COPY docroot/index.php ./docroot/
37+
# Some error pages are referenced by both PHP and the HTTP server config
38+
COPY docroot/404.html ./docroot/
39+
COPY docroot/500.html ./docroot/
40+
COPY docroot/admin/index.php ./docroot/admin/
41+
# CSS/JS are inlined by PHP
42+
COPY docroot/css ./docroot/css
43+
COPY docroot/js ./docroot/js
44+
# Report data and db date (used by some reports and runtime)
45+
COPY data ./data
46+
47+
EXPOSE 9000
48+
49+
CMD ["php-fpm", "-F"]

.docker/fpm.edge.Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Unpinned version intentional - this image is for testing latest PHP
2+
FROM alpine:edge
3+
LABEL maintainer="Pere Orga pere@orga.cat"
4+
LABEL description="Alpine edge-based image with PHP-FPM, for testing latest PHP."
5+
6+
ARG PHP_VERSION=85
7+
8+
WORKDIR /srv/app
9+
10+
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
11+
apk --no-cache --update add \
12+
php${PHP_VERSION}-fpm \
13+
php${PHP_VERSION}-apcu \
14+
php${PHP_VERSION}-gd \
15+
php${PHP_VERSION}-mbstring \
16+
php${PHP_VERSION}-pdo_mysql \
17+
php${PHP_VERSION}-session && \
18+
ln -s /usr/sbin/php-fpm${PHP_VERSION} /usr/sbin/php-fpm
19+
20+
COPY .docker/php/performance.ini /etc/php${PHP_VERSION}/conf.d/performance.ini
21+
COPY .docker/php/security.ini /etc/php${PHP_VERSION}/conf.d/security.ini
22+
COPY .docker/php/fpm.conf /etc/php${PHP_VERSION}/php-fpm.d/zzz-docker.conf
23+
24+
COPY src ./src
25+
COPY docroot/index.php ./docroot/
26+
COPY docroot/404.html ./docroot/
27+
COPY docroot/500.html ./docroot/
28+
COPY docroot/admin/index.php ./docroot/admin/
29+
COPY docroot/css ./docroot/css
30+
COPY docroot/js ./docroot/js
31+
COPY data ./data
32+
33+
EXPOSE 9000
34+
35+
CMD ["php-fpm", "-F"]

.docker/frankenphp.Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Unpinned version intentional - this image is for testing/reference
2+
FROM dunglas/frankenphp:alpine
3+
LABEL maintainer="Pere Orga pere@orga.cat"
4+
LABEL description="FrankenPHP (Caddy + PHP)."
5+
6+
WORKDIR /srv/app
7+
8+
# Note: mbstring and session are bundled by FrankenPHP by default
9+
RUN install-php-extensions apcu gd pdo_mysql
10+
11+
COPY .docker/php/performance.ini /usr/local/etc/php/php.ini
12+
COPY .docker/php/security.ini /usr/local/etc/php/conf.d/security.ini
13+
COPY .docker/frankenphp/Caddyfile /etc/frankenphp/Caddyfile
14+
15+
# Project files are mounted via volume in docker-compose.frankenphp.yml
16+
17+
EXPOSE 80

.docker/frankenphp/Caddyfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
auto_https off
3+
admin off
4+
frankenphp
5+
}
6+
7+
:80 {
8+
root * /srv/app/docroot
9+
encode zstd gzip
10+
11+
header {
12+
Cross-Origin-Opener-Policy "same-origin"
13+
Strict-Transport-Security "max-age=31536000"
14+
X-Content-Type-Options "nosniff"
15+
-ETag
16+
}
17+
18+
@static path *.avif *.css *.gif *.ico *.jpg *.js *.mp3 *.png *.svg *.webp
19+
header @static Cache-Control "public, max-age=31536000, immutable"
20+
21+
handle_errors 400 401 403 404 500 {
22+
rewrite * /{err.status_code}.html
23+
file_server
24+
}
25+
26+
php_server
27+
}

.docker/mysql/custom.cnf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[mysqld]
2+
binlog_expire_logs_seconds = 0
3+
character_set_server = utf8mb4
4+
collation_server = utf8mb4_uca1400_ai_ci
5+
innodb_buffer_pool_size = 2G
6+
innodb_doublewrite = 0
7+
innodb_flush_log_at_trx_commit = 0
8+
innodb_ft_cache_size = 1G
9+
innodb_ft_enable_stopword = 0
10+
innodb_ft_min_token_size = 1
11+
performance_schema = 0
12+
skip_log_bin

.docker/nginx.Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM alpine:3.23
2+
LABEL maintainer="Pere Orga pere@orga.cat"
3+
LABEL description="Nginx container for serving static files and proxying to PHP-FPM."
4+
5+
# Using Alpine's nginx package allows easy installation of nginx-mod-http-brotli,
6+
# which would require compiling from source with the official nginx:alpine image.
7+
RUN apk add --no-cache --update nginx nginx-mod-http-brotli
8+
9+
COPY .docker/nginx/nginx.conf /etc/nginx/nginx.conf
10+
COPY .docker/nginx/default.conf /etc/nginx/http.d/default.conf
11+
COPY .docker/nginx/security-headers.conf /etc/nginx/security-headers.conf
12+
13+
# Copy static files
14+
COPY docroot /srv/app/docroot
15+
16+
EXPOSE 80
17+
18+
CMD ["nginx", "-g", "daemon off;"]

.docker/nginx/default.conf

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
server {
2+
listen 80;
3+
server_name pccd.dites.cat localhost;
4+
root /srv/app/docroot;
5+
index index.php;
6+
7+
charset utf-8;
8+
9+
# Use relative redirects to preserve the original host/port
10+
absolute_redirect off;
11+
12+
error_page 400 /400.html;
13+
error_page 401 /401.html;
14+
error_page 403 /403.html;
15+
error_page 404 /404.html;
16+
error_page 500 /500.html;
17+
18+
etag off;
19+
20+
include /etc/nginx/security-headers.conf;
21+
22+
gzip on;
23+
gzip_vary on;
24+
gzip_types
25+
application/javascript
26+
application/json
27+
application/xml
28+
image/svg+xml
29+
text/css
30+
text/javascript
31+
text/plain
32+
text/xml;
33+
34+
brotli on;
35+
brotli_types
36+
application/javascript
37+
application/json
38+
application/xml
39+
image/svg+xml
40+
text/css
41+
text/javascript
42+
text/plain
43+
text/xml;
44+
45+
# OG images (dynamic, handled by PHP)
46+
location ~ ^/og/.*\.png$ {
47+
fastcgi_pass php:9000;
48+
include fastcgi_params;
49+
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
50+
}
51+
52+
# Static file caching
53+
location ~* \.(?:avif|css|gif|ico|jpg|js|mp3|png|svg|webp)$ {
54+
add_header Cache-Control "public, max-age=31536000, immutable";
55+
include /etc/nginx/security-headers.conf;
56+
access_log off;
57+
}
58+
59+
# PHP-FPM handling
60+
location ~ \.php$ {
61+
try_files $uri =404;
62+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
63+
fastcgi_pass php:9000;
64+
fastcgi_index index.php;
65+
include fastcgi_params;
66+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
67+
fastcgi_param PATH_INFO $fastcgi_path_info;
68+
}
69+
70+
# Route all non-file requests to index.php
71+
location / {
72+
try_files $uri $uri/ /index.php$is_args$args;
73+
}
74+
}

0 commit comments

Comments
 (0)