Skip to content

Commit 810d520

Browse files
committed
export source code
0 parents  commit 810d520

File tree

219 files changed

+29260
-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.

219 files changed

+29260
-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_403.html
10+
ErrorDocument 403 /401_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|jpeg|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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# hadolint ignore=DL3007
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+
# hadolint ignore=SC2046
10+
RUN apt-get update \
11+
&& apt-get install --no-install-recommends -y $(cat apt_dev_deps.txt) \
12+
&& apt-get clean \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
RUN npx playwright install --with-deps chromium

.docker/dev.Dockerfile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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.27
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, ommitting APCu to reduce Docker build times
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 gd intl pdo_mysql
23+
#RUN install-php-extensions apcu
24+
25+
# Copy configuration files
26+
COPY .docker/apache/vhost.conf /etc/apache2/sites-available/000-default.conf
27+
28+
# Project files are mounted via volume in docker-compose.yml
29+
# COPY docroot ./docroot
30+
# COPY scripts ./scripts
31+
# COPY src ./src
32+
# COPY tests ./tests
33+
# COPY tmp ./tmp
34+
35+
# SPX profiler
36+
RUN if [ "$profiler" = "spx" ]; then \
37+
install-php-extensions spx && \
38+
{ \
39+
echo "[spx]"; \
40+
echo "spx.http_enabled = 1"; \
41+
echo "spx.http_ip_whitelist = \"*\""; \
42+
echo "spx.http_key = \"dev\""; \
43+
} > /usr/local/etc/php/conf.d/spx.ini; \
44+
fi
45+
46+
# XHProf profiler
47+
RUN if [ "$profiler" = "xhprof" ]; then \
48+
install-php-extensions xhprof && \
49+
sed -i '/<\/VirtualHost>/d' /etc/apache2/sites-available/000-default.conf && \
50+
{ \
51+
echo "Alias /admin/xhprof /usr/local/lib/php/xhprof_html"; \
52+
echo "<Directory /usr/local/lib/php/xhprof_html/>"; \
53+
echo " Options Indexes FollowSymLinks"; \
54+
echo " AllowOverride FileInfo"; \
55+
echo " Require all granted"; \
56+
echo " php_value auto_prepend_file none"; \
57+
echo " php_value memory_limit 1024M"; \
58+
echo "</Directory>"; \
59+
} >> /etc/apache2/sites-available/000-default.conf; \
60+
echo '</VirtualHost>' >> /etc/apache2/sites-available/000-default.conf && \
61+
{ \
62+
echo "[xhprof]"; \
63+
echo "auto_prepend_file = /srv/app/src/xhprof.php"; \
64+
echo "xhprof.collect_additional_info = 1"; \
65+
echo "xhprof.output_dir = /tmp"; \
66+
} > /usr/local/etc/php/conf.d/xhprof.ini; \
67+
fi

.docker/fpm.Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
ARG PHP_VERSION=85
6+
ARG ARG_MYSQL_DB
7+
ARG ARG_MYSQL_PWD
8+
ARG ARG_MYSQL_USER
9+
ARG ARG_WEB_ADMIN_PWD
10+
11+
ENV MYSQL_DATABASE=${ARG_MYSQL_DB}
12+
ENV MYSQL_PASSWORD=${ARG_MYSQL_PWD}
13+
ENV MYSQL_USER=${ARG_MYSQL_USER}
14+
ENV WEB_ADMIN_PASSWORD=${ARG_WEB_ADMIN_PWD}
15+
16+
WORKDIR /srv/app
17+
18+
# hadolint ignore=DL3018
19+
RUN apk --no-cache --update add \
20+
php${PHP_VERSION}-fpm \
21+
php${PHP_VERSION}-apcu \
22+
php${PHP_VERSION}-gd \
23+
php${PHP_VERSION}-mbstring \
24+
php${PHP_VERSION}-pdo_mysql \
25+
php${PHP_VERSION}-session && \
26+
ln -s /usr/sbin/php-fpm${PHP_VERSION} /usr/sbin/php-fpm
27+
28+
COPY .docker/php/performance.ini /etc/php${PHP_VERSION}/conf.d/performance.ini
29+
COPY .docker/php/security.ini /etc/php${PHP_VERSION}/conf.d/security.ini
30+
COPY .docker/php/fpm.conf /etc/php${PHP_VERSION}/php-fpm.d/zzz-docker.conf
31+
32+
COPY docroot ./docroot
33+
COPY scripts ./scripts
34+
COPY src ./src
35+
COPY tests ./tests
36+
COPY tmp ./tmp
37+
38+
EXPOSE 9000
39+
40+
CMD ["php-fpm", "-F"]

.docker/fpm.edge.Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM alpine:edge
2+
LABEL maintainer="Pere Orga pere@orga.cat"
3+
LABEL description="Alpine edge-based image with PHP-FPM, for testing latest PHP."
4+
5+
ARG PHP_VERSION=85
6+
7+
WORKDIR /srv/app
8+
9+
# hadolint ignore=DL3018
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 docroot ./docroot
25+
COPY scripts ./scripts
26+
COPY src ./src
27+
COPY tests ./tests
28+
COPY tmp ./tmp
29+
30+
EXPOSE 9000
31+
32+
CMD ["php-fpm", "-F"]

.docker/frankenphp.Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM dunglas/frankenphp:php8-alpine
2+
LABEL maintainer="Pere Orga pere@orga.cat"
3+
LABEL description="FrankenPHP (Caddy + PHP) image for simplified deployment."
4+
5+
WORKDIR /srv/app
6+
7+
RUN install-php-extensions \
8+
apcu \
9+
gd \
10+
pdo_mysql
11+
12+
COPY .docker/php/performance.ini /usr/local/etc/php/php.ini
13+
COPY .docker/php/security.ini /usr/local/etc/php/conf.d/security.ini
14+
COPY .docker/frankenphp/Caddyfile /etc/frankenphp/Caddyfile
15+
16+
COPY docroot ./docroot
17+
COPY scripts ./scripts
18+
COPY src ./src
19+
COPY tests ./tests
20+
COPY tmp ./tmp
21+
22+
EXPOSE 80

.docker/frankenphp/Caddyfile

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

.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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
# hadolint ignore=DL3018
6+
RUN apk add --no-cache --update nginx nginx-mod-http-brotli
7+
8+
COPY .docker/nginx/nginx.conf /etc/nginx/nginx.conf
9+
COPY .docker/nginx/default.conf /etc/nginx/http.d/default.conf
10+
COPY .docker/nginx/security-headers.conf /etc/nginx/security-headers.conf
11+
12+
# Copy static files
13+
COPY docroot /srv/app/docroot
14+
15+
EXPOSE 80
16+
17+
CMD ["nginx", "-g", "daemon off;"]

.docker/nginx/default.conf

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

0 commit comments

Comments
 (0)