Add Docker infrastructure for dev and prod environments

- Separate PHP Dockerfiles (dev/prod) with extensions and prod opcache/php.ini optimization
- docker-compose-dev: PHP, PostgreSQL, Redis, Messenger, Mailpit, RedisInsight
- docker-compose-prod: 2x PHP replicas, PgSQL master/slave with PgBouncer, 2x Messenger, Redis
- Makefile with build/start/stop/purge commands
- AGENT.md to restrict AI access to the repository

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-03-18 20:12:09 +01:00
parent 9341647acf
commit 653d7b4729
14 changed files with 378 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
CREATE USER replicator WITH REPLICATION ENCRYPTED PASSWORD 'e-ticket';
SELECT pg_create_physical_replication_slot('slave_slot');

12
docker/pgsql/init-slave.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
set -e
until pg_isready -h db-master -U e-ticket; do
echo "Waiting for master..."
sleep 2
done
rm -rf /var/lib/postgresql/data/*
pg_basebackup -h db-master -D /var/lib/postgresql/data -U replicator -Fp -Xs -P -R
echo "hot_standby = on" >> /var/lib/postgresql/data/postgresql.conf

View File

@@ -0,0 +1,19 @@
[databases]
e-ticket = host=db-master port=5432 dbname=e-ticket
e-ticket_readonly = host=db-slave port=5432 dbname=e-ticket
[pgbouncer]
listen_addr = 0.0.0.0
listen_port = 6432
auth_type = md5
auth_file = /etc/pgbouncer/userlist.txt
pool_mode = transaction
max_client_conn = 200
default_pool_size = 20
min_pool_size = 5
reserve_pool_size = 5
reserve_pool_timeout = 3
server_lifetime = 3600
server_idle_timeout = 600
log_connections = 0
log_disconnections = 0

View File

@@ -0,0 +1 @@
"e-ticket" "md5f79275ff8ae69fcb9e6218d88e699961"

28
docker/php/dev/Dockerfile Normal file
View File

@@ -0,0 +1,28 @@
FROM php:8.4-fpm
RUN apt-get update && apt-get install -y \
libpq-dev \
libsqlite3-dev \
libzip-dev \
libxml2-dev \
libicu-dev \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libmagickwand-dev \
unzip \
&& rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install \
pdo_mysql \
pdo_pgsql \
pdo_sqlite \
zip \
xml \
intl \
mbstring \
gd
RUN pecl install redis imagick \
&& docker-php-ext-enable redis imagick

View File

@@ -0,0 +1,32 @@
FROM php:8.4-fpm
RUN apt-get update && apt-get install -y \
libpq-dev \
libsqlite3-dev \
libzip-dev \
libxml2-dev \
libicu-dev \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libmagickwand-dev \
unzip \
&& rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install \
pdo_mysql \
pdo_pgsql \
pdo_sqlite \
zip \
xml \
intl \
mbstring \
gd \
opcache
RUN pecl install redis imagick \
&& docker-php-ext-enable redis imagick
COPY php.ini /usr/local/etc/php/conf.d/app.ini
COPY opcache.ini /usr/local/etc/php/conf.d/opcache.ini

View File

@@ -0,0 +1,9 @@
opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=20000
opcache.validate_timestamps=0
opcache.save_comments=0
opcache.enable_cli=1
opcache.jit=tracing
opcache.jit_buffer_size=128M

21
docker/php/prod/php.ini Normal file
View File

@@ -0,0 +1,21 @@
date.timezone = Europe/Paris
memory_limit = 256M
upload_max_filesize = 100M
post_max_size = 150M
max_execution_time = 30
max_input_time = 30
expose_php = Off
display_errors = Off
display_startup_errors = Off
log_errors = On
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
realpath_cache_size = 4096K
realpath_cache_ttl = 600
session.cookie_secure = On
session.cookie_httponly = On
session.cookie_samesite = Lax
session.use_strict_mode = 1