Skip to content

Commit 0dc1d63

Browse files
committed
export source code
0 parents  commit 0dc1d63

File tree

217 files changed

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

217 files changed

+29628
-0
lines changed

.docker/alpine.dev.Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM alpine:3.22
2+
LABEL maintainer="Pere Orga [email protected]"
3+
LABEL description="Alpine-based image with Apache and mod_php that mimics production."
4+
5+
# Set working directory
6+
WORKDIR /srv/app
7+
8+
ARG PHP_VERSION=84
9+
10+
# Install Apache, Apache modules, PHP and PHP extensions
11+
# hadolint ignore=DL3018
12+
RUN apk --no-cache --update add \
13+
apache2 \
14+
apache2-brotli \
15+
php${PHP_VERSION}-apache2 \
16+
php${PHP_VERSION}-apcu \
17+
php${PHP_VERSION}-gd \
18+
php${PHP_VERSION}-mbstring \
19+
php${PHP_VERSION}-opcache \
20+
php${PHP_VERSION}-pdo_mysql \
21+
php${PHP_VERSION}-session
22+
23+
# Remove Apache DocumentRoot default settings
24+
RUN sed -i '/^DocumentRoot/d' /etc/apache2/httpd.conf \
25+
# Do not expose unnecessary Server information
26+
&& echo 'ServerTokens Prod' >> /etc/apache2/httpd.conf \
27+
# Enable necessary Apache modules
28+
&& sed -i 's/#LoadModule\ deflate_module/LoadModule\ deflate_module/' /etc/apache2/httpd.conf \
29+
&& sed -i 's/#LoadModule\ headers_module/LoadModule\ headers_module/' /etc/apache2/httpd.conf \
30+
&& sed -i 's/#LoadModule\ rewrite_module/LoadModule\ rewrite_module/' /etc/apache2/httpd.conf
31+
32+
# Copy configuration files
33+
COPY .docker/apache/vhost.conf /etc/apache2/conf.d/vhost.conf
34+
COPY .docker/php/performance.ini /etc/php${PHP_VERSION}/conf.d/performance.ini
35+
COPY .docker/php/security.ini /etc/php${PHP_VERSION}/conf.d/security.ini
36+
37+
# Copy project files
38+
COPY docroot ./docroot
39+
COPY scripts ./scripts
40+
COPY src ./src
41+
COPY tmp ./tmp
42+
COPY tests ./tests
43+
44+
# Remove default Apache logs and create symbolic links to stdout and stderr
45+
RUN ln -sf /dev/stdout /var/log/apache2/access.log \
46+
&& ln -sf /dev/stderr /var/log/apache2/error.log
47+
48+
# Start Apache
49+
CMD ["httpd", "-D", "FOREGROUND"]

.docker/alpine.edge.Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM alpine:edge
2+
LABEL maintainer="Pere Orga [email protected]"
3+
LABEL description="Alpine edge-based image, with latest PHP."
4+
5+
# Set working directory
6+
WORKDIR /srv/app
7+
8+
ARG PHP_VERSION=85
9+
10+
# Enable the testing repository
11+
# Install Apache, Apache modules, PHP and PHP extensions
12+
# hadolint ignore=DL3018
13+
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
14+
apk --no-cache --update add \
15+
apache2 \
16+
apache2-brotli \
17+
php${PHP_VERSION}-apache2 \
18+
php${PHP_VERSION}-apcu \
19+
php${PHP_VERSION}-gd \
20+
php${PHP_VERSION}-mbstring \
21+
php${PHP_VERSION}-opcache \
22+
php${PHP_VERSION}-pdo_mysql \
23+
php${PHP_VERSION}-session
24+
25+
# Remove Apache DocumentRoot default settings
26+
RUN sed -i '/^DocumentRoot/d' /etc/apache2/httpd.conf \
27+
# Do not expose unnecessary Server information
28+
&& echo 'ServerTokens Prod' >> /etc/apache2/httpd.conf \
29+
# Enable necessary Apache modules
30+
&& sed -i 's/#LoadModule\ deflate_module/LoadModule\ deflate_module/' /etc/apache2/httpd.conf \
31+
&& sed -i 's/#LoadModule\ headers_module/LoadModule\ headers_module/' /etc/apache2/httpd.conf \
32+
&& sed -i 's/#LoadModule\ rewrite_module/LoadModule\ rewrite_module/' /etc/apache2/httpd.conf
33+
34+
# Copy configuration files
35+
COPY .docker/apache/vhost.conf /etc/apache2/conf.d/vhost.conf
36+
COPY .docker/php/performance.ini /etc/php${PHP_VERSION}/conf.d/performance.ini
37+
COPY .docker/php/security.ini /etc/php${PHP_VERSION}/conf.d/security.ini
38+
39+
# Copy project files
40+
COPY docroot ./docroot
41+
COPY scripts ./scripts
42+
COPY src ./src
43+
COPY tmp ./tmp
44+
COPY tests ./tests
45+
46+
# Remove default Apache logs and create symbolic links to stdout and stderr
47+
RUN ln -sf /dev/stdout /var/log/apache2/access.log \
48+
&& ln -sf /dev/stderr /var/log/apache2/error.log
49+
50+
# Start Apache
51+
CMD ["httpd", "-D", "FOREGROUND"]

.docker/apache/vhost.conf

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
<IfModule mod_rewrite.c>
23+
RewriteEngine on
24+
RewriteRule ^/p/(.*)$ /index.php?paremiotipus=$1 [B,L,UnsafeAllow3F]
25+
RewriteRule ^/obra/(.*)$ /index.php?obra=$1 [B,L,UnsafeAllow3F]
26+
RewriteRule "^/credits$" "/index.php?credits" [L]
27+
RewriteRule "^/fonts$" "/index.php?fonts" [L]
28+
RewriteRule "^/instruccions$" "/index.php?instruccions" [L]
29+
RewriteRule "^/llibres$" "/index.php?llibres" [L]
30+
RewriteRule "^/projecte$" "/index.php?projecte" [L]
31+
RewriteRule "^/top100$" "/index.php?top100" [L]
32+
RewriteRule "^/top10000$" "/index.php?top10000" [L]
33+
RewriteRule ^/og/(.*)\.png$ /og.php?paremiotipus=$1 [B,L,UnsafeAllow3F]
34+
</IfModule>
35+
36+
<IfModule mod_headers.c>
37+
Header always set Cross-Origin-Opener-Policy "same-origin"
38+
Header always set Strict-Transport-Security "max-age=31536000"
39+
Header always set X-Content-Type-Options "nosniff"
40+
41+
<FilesMatch "(?i)\.(avif|css|gif|ico|jpg|jpeg|js|mp3|png|svg|webp)$">
42+
Header set Cache-Control "public, max-age=31536000, immutable"
43+
</FilesMatch>
44+
</IfModule>
45+
46+
<IfModule mod_filter.c>
47+
<IfModule mod_brotli.c>
48+
AddOutputFilterByType BROTLI_COMPRESS application/javascript
49+
AddOutputFilterByType BROTLI_COMPRESS application/json
50+
AddOutputFilterByType BROTLI_COMPRESS application/ld+json
51+
AddOutputFilterByType BROTLI_COMPRESS application/manifest+json
52+
AddOutputFilterByType BROTLI_COMPRESS application/xml
53+
AddOutputFilterByType BROTLI_COMPRESS image/svg+xml
54+
AddOutputFilterByType BROTLI_COMPRESS text/css
55+
AddOutputFilterByType BROTLI_COMPRESS text/html
56+
AddOutputFilterByType BROTLI_COMPRESS text/javascript
57+
AddOutputFilterByType BROTLI_COMPRESS text/plain
58+
AddOutputFilterByType BROTLI_COMPRESS text/xml
59+
</IfModule>
60+
61+
<IfModule mod_deflate.c>
62+
AddOutputFilterByType DEFLATE application/javascript
63+
AddOutputFilterByType DEFLATE application/json
64+
AddOutputFilterByType DEFLATE application/ld+json
65+
AddOutputFilterByType DEFLATE application/manifest+json
66+
AddOutputFilterByType DEFLATE application/xml
67+
AddOutputFilterByType DEFLATE image/svg+xml
68+
AddOutputFilterByType DEFLATE text/css
69+
AddOutputFilterByType DEFLATE text/html
70+
AddOutputFilterByType DEFLATE text/javascript
71+
AddOutputFilterByType DEFLATE text/plain
72+
AddOutputFilterByType DEFLATE text/xml
73+
</IfModule>
74+
</IfModule>
75+
</VirtualHost>

.docker/debian.dev.Dockerfile

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
ARG PHP_IMAGE_TAG=8.4.13-apache-trixie
2+
3+
FROM php:${PHP_IMAGE_TAG}
4+
LABEL maintainer="Pere Orga [email protected]"
5+
LABEL description="Debian-based image with Apache and mod_php. Used for development."
6+
7+
ARG profiler
8+
9+
# Set working directory
10+
WORKDIR /srv/app
11+
12+
# Install install-php-extensions
13+
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/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 OPcache/APCu to reduce Docker build times
19+
RUN rm -f /etc/apache2/mods-enabled/deflate.conf /etc/apache2/mods-enabled/alias.conf && \
20+
a2enmod rewrite headers brotli && \
21+
cat /usr/local/etc/php/php.ini-development > /usr/local/etc/php/php.ini && \
22+
chmod +x /usr/local/bin/install-php-extensions && \
23+
install-php-extensions gd intl pdo_mysql
24+
#RUN install-php-extensions apcu opcache
25+
26+
# Copy configuration files
27+
COPY .docker/apache/vhost.conf /etc/apache2/sites-available/000-default.conf
28+
29+
# Project files are mounted via volume in docker-compose.yml
30+
# COPY docroot ./docroot
31+
# COPY scripts ./scripts
32+
# COPY src ./src
33+
# COPY tmp ./tmp
34+
# COPY tests ./tests
35+
36+
# SPX profiler
37+
RUN if [ "$profiler" = "spx" ]; then \
38+
install-php-extensions spx && \
39+
{ \
40+
echo "[spx]"; \
41+
echo "spx.http_enabled = 1"; \
42+
echo "spx.http_ip_whitelist = \"*\""; \
43+
echo "spx.http_key = \"dev\""; \
44+
} > /usr/local/etc/php/conf.d/spx.ini; \
45+
fi
46+
47+
# XHProf profiler
48+
RUN if [ "$profiler" = "xhprof" ]; then \
49+
install-php-extensions xhprof && \
50+
sed -i '/<\/VirtualHost>/d' /etc/apache2/sites-available/000-default.conf && \
51+
{ \
52+
echo "Alias /admin/xhprof /usr/local/lib/php/xhprof_html"; \
53+
echo "<Directory /usr/local/lib/php/xhprof_html/>"; \
54+
echo " Options Indexes FollowSymLinks"; \
55+
echo " AllowOverride FileInfo"; \
56+
echo " Require all granted"; \
57+
echo " php_value auto_prepend_file none"; \
58+
echo " php_value memory_limit 1024M"; \
59+
echo "</Directory>"; \
60+
} >> /etc/apache2/sites-available/000-default.conf; \
61+
echo '</VirtualHost>' >> /etc/apache2/sites-available/000-default.conf && \
62+
{ \
63+
echo "[xhprof]"; \
64+
echo "auto_prepend_file = /srv/app/src/xhprof.php"; \
65+
echo "xhprof.collect_additional_info = 1"; \
66+
echo "xhprof.output_dir = /tmp"; \
67+
} > /usr/local/etc/php/conf.d/xhprof.ini; \
68+
fi

.docker/debian.local.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+
4+
LABEL maintainer="Pere Orga [email protected]"
5+
LABEL description="Debian-based image for building a new release 100% inside Docker (not usually tested)."
6+
7+
WORKDIR /srv/app
8+
9+
COPY apt_packages.txt .
10+
RUN apt-get update \
11+
&& xargs apt-get install --no-install-recommends -y < apt_packages.txt \
12+
&& apt-get clean \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
RUN npx playwright install --with-deps chromium

.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/php/performance.ini

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[php]
2+
output_buffering = 16384
3+
realpath_cache_ttl = 2629743
4+
5+
[apcu]
6+
apc.entries_hint = 128000
7+
apc.shm_size = "64M"
8+
9+
[opcache]
10+
opcache.file_update_protection = 0
11+
opcache.memory_consumption = 32
12+
opcache.save_comments = 0
13+
opcache.validate_timestamps = 0

.docker/php/security.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[php]
2+
expose_php = Off

.docker/sql.prod.Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM mariadb:11.8.3-noble
2+
LABEL maintainer="Pere Orga [email protected]"
3+
LABEL description="MariaDB image used in production."
4+
5+
ARG ARG_MYSQL_ROOT_PWD
6+
ARG ARG_MYSQL_DB
7+
ARG ARG_MYSQL_PWD
8+
ARG ARG_MYSQL_USER
9+
10+
ENV MYSQL_ROOT_PASSWORD=${ARG_MYSQL_ROOT_PWD}
11+
ENV MYSQL_DATABASE=${ARG_MYSQL_DB}
12+
ENV MYSQL_PASSWORD=${ARG_MYSQL_PWD}
13+
ENV MYSQL_USER=${ARG_MYSQL_USER}
14+
15+
COPY ./.docker/mysql /etc/mysql/conf.d
16+
17+
# Set the DB to be read-only (production only)
18+
RUN echo "read_only = 1" >> /etc/mysql/conf.d/custom.cnf && \
19+
chmod 0444 /etc/mysql/conf.d/*
20+
21+
COPY ./install/db /docker-entrypoint-initdb.d

.docker/web-alpine.prod.Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
FROM alpine:3.22
2+
LABEL maintainer="Pere Orga [email protected]"
3+
LABEL description="Alpine-based image with Apache and mod_php. Used in production."
4+
5+
ARG ARG_MYSQL_DB
6+
ARG ARG_MYSQL_PWD
7+
ARG ARG_MYSQL_USER
8+
ARG ARG_WEB_ADMIN_PWD
9+
10+
ENV MYSQL_DATABASE=${ARG_MYSQL_DB}
11+
ENV MYSQL_PASSWORD=${ARG_MYSQL_PWD}
12+
ENV MYSQL_USER=${ARG_MYSQL_USER}
13+
ENV WEB_ADMIN_PASSWORD=${ARG_WEB_ADMIN_PWD}
14+
15+
# Set working directory
16+
WORKDIR /srv/app
17+
18+
ARG PHP_VERSION=84
19+
20+
# Install Apache, Apache modules, PHP and PHP extensions
21+
# hadolint ignore=DL3018
22+
RUN apk --no-cache --update add \
23+
apache2 \
24+
apache2-brotli \
25+
php${PHP_VERSION}-apache2 \
26+
php${PHP_VERSION}-apcu \
27+
php${PHP_VERSION}-gd \
28+
php${PHP_VERSION}-mbstring \
29+
php${PHP_VERSION}-opcache \
30+
php${PHP_VERSION}-pdo_mysql \
31+
php${PHP_VERSION}-session
32+
33+
# Remove Apache DocumentRoot default settings
34+
RUN sed -i '/^DocumentRoot/d' /etc/apache2/httpd.conf \
35+
# Do not expose unnecessary Server information
36+
&& echo 'ServerTokens Prod' >> /etc/apache2/httpd.conf \
37+
# Enable necessary Apache modules
38+
&& sed -i 's/#LoadModule\ deflate_module/LoadModule\ deflate_module/' /etc/apache2/httpd.conf \
39+
&& sed -i 's/#LoadModule\ headers_module/LoadModule\ headers_module/' /etc/apache2/httpd.conf \
40+
&& sed -i 's/#LoadModule\ rewrite_module/LoadModule\ rewrite_module/' /etc/apache2/httpd.conf
41+
42+
# Copy configuration files
43+
COPY .docker/apache/vhost.conf /etc/apache2/conf.d/vhost.conf
44+
COPY .docker/php/performance.ini /etc/php${PHP_VERSION}/conf.d/performance.ini
45+
COPY .docker/php/security.ini /etc/php${PHP_VERSION}/conf.d/security.ini
46+
47+
# Copy project files
48+
COPY docroot ./docroot
49+
COPY scripts ./scripts
50+
COPY src ./src
51+
COPY tmp ./tmp
52+
COPY tests ./tests
53+
54+
# Remove default Apache logs and create symbolic links to stdout and stderr
55+
RUN ln -sf /dev/stdout /var/log/apache2/access.log \
56+
&& ln -sf /dev/stderr /var/log/apache2/error.log
57+
58+
# Start Apache
59+
CMD ["httpd", "-D", "FOREGROUND"]

0 commit comments

Comments
 (0)