Initialisation de la stack Docker.
This commit is contained in:
@@ -0,0 +1,34 @@
|
|||||||
|
# À définir pour éviter les problèmes sur les multi-projets Docker
|
||||||
|
COMPOSE_PROJECT_NAME=""
|
||||||
|
|
||||||
|
COMPOSE_FILE=docker-compose.yml
|
||||||
|
|
||||||
|
# Pour utiliser Let's Encrypt :
|
||||||
|
# COMPOSE_FILE=docker-compose.yml:docker-compose.lets-encrypt.yml
|
||||||
|
|
||||||
|
# Préfixe pour les noms des conteneurs et des labels dans les fichiers docker-compose
|
||||||
|
CONTAINER_PREFIX=""
|
||||||
|
|
||||||
|
# URL principale du projet
|
||||||
|
PROJECT_URL=""
|
||||||
|
|
||||||
|
# Traefik
|
||||||
|
TRAEFIK_IMAGE=traefik:v3.6
|
||||||
|
# URL d'accès au dashboard de Traefik
|
||||||
|
TRAEFIK_URL=""
|
||||||
|
# Basic Auth pour le Dashboard
|
||||||
|
TRAEFIK_HTPASSWD=""
|
||||||
|
# Email pour Let's Encrypt
|
||||||
|
LETSENCRYPT_EMAIL=""
|
||||||
|
|
||||||
|
# Base de données
|
||||||
|
DATABASE_IMAGE="mariadb:12"
|
||||||
|
DATABASE_ROOT_PASSWORD=""
|
||||||
|
|
||||||
|
# Apache et PHP
|
||||||
|
APACHE_PHP_VERSION="php:8.5-apache"
|
||||||
|
APACHE_ADMIN_EMAIL=""
|
||||||
|
|
||||||
|
# PHPMyAdmin
|
||||||
|
PHPMYADMIN_IMAGE="phpmyadmin:5.2-apache"
|
||||||
|
PHPMYADMIN_URL=""
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
.env
|
||||||
|
host/apache/logs/*.log
|
||||||
|
host/certs/*.crt
|
||||||
|
host/certs/*.key
|
||||||
|
host/database/data/*
|
||||||
|
!host/database/data/.gitkeep
|
||||||
|
host/database/backups/*
|
||||||
|
!host/database/backups/.gitkeep
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
services:
|
||||||
|
|
||||||
|
traefik:
|
||||||
|
command:
|
||||||
|
- "--certificatesresolvers.letsencrypt.acme.email=${LETSENCRYPT_EMAIL}"
|
||||||
|
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
|
||||||
|
- "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
|
||||||
|
volumes:
|
||||||
|
- ./certs/letsencrypt:/letsencrypt
|
||||||
|
|
||||||
|
apache-php:
|
||||||
|
labels:
|
||||||
|
- "traefik.http.routers.${CONTAINER_PREFIX}.tls.certresolver=letsencrypt"
|
||||||
|
|
||||||
|
phpmyadmin:
|
||||||
|
labels:
|
||||||
|
- "traefik.http.routers.${CONTAINER_PREFIX}_pma.tls.certresolver=letsencrypt"
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
networks:
|
||||||
|
frontend:
|
||||||
|
external: true
|
||||||
|
name: frontend
|
||||||
|
backend:
|
||||||
|
|
||||||
|
services:
|
||||||
|
|
||||||
|
# Configuration de Traefik
|
||||||
|
traefik:
|
||||||
|
image: ${TRAEFIK_IMAGE}
|
||||||
|
container_name: traefik
|
||||||
|
command:
|
||||||
|
- "--api.dashboard=true"
|
||||||
|
- "--api.insecure=false"
|
||||||
|
#
|
||||||
|
- "--providers.docker=true"
|
||||||
|
- "--providers.docker.exposedbydefault=false"
|
||||||
|
- "--providers.docker.network=frontend"
|
||||||
|
- "--providers.file.filename=./tls.yaml"
|
||||||
|
#
|
||||||
|
- "--entrypoints.web.address=:80"
|
||||||
|
- "--entrypoints.web.http.redirections.entrypoint.to=websecure"
|
||||||
|
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
|
||||||
|
- "--entrypoints.web.http.redirections.entrypoint.permanent=true"
|
||||||
|
- "--entrypoints.websecure.address=:443"
|
||||||
|
- "--entrypoints.websecure.http.tls=true"
|
||||||
|
#
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
#
|
||||||
|
- "traefik.http.routers.${CONTAINER_PREFIX}_dashboard.rule=Host(`${TRAEFIK_URL}`)"
|
||||||
|
- "traefik.http.routers.${CONTAINER_PREFIX}_dashboard.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.${CONTAINER_PREFIX}_dashboard.service=api@internal"
|
||||||
|
- "traefik.http.routers.${CONTAINER_PREFIX}_dashboard.tls=true"
|
||||||
|
- "traefik.http.middlewares.${CONTAINER_PREFIX}_dashboard-auth.basicauth.users=${TRAEFIK_HTPASSWD}"
|
||||||
|
- "traefik.http.routers.${CONTAINER_PREFIX}_dashboard.middlewares=${CONTAINER_PREFIX}_dashboard-auth@docker"
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
|
- "8080:8080"
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- ./certs:/certs:ro
|
||||||
|
networks:
|
||||||
|
- frontend
|
||||||
|
- backend
|
||||||
|
|
||||||
|
# Configuration de la base de données avec MariaDB
|
||||||
|
database:
|
||||||
|
restart: unless-stopped
|
||||||
|
container_name: ${CONTAINER_PREFIX}_database
|
||||||
|
image: ${DATABASE_IMAGE}
|
||||||
|
volumes:
|
||||||
|
# Données
|
||||||
|
- ./host/database/data:/var/lib/mysql
|
||||||
|
- ./host/database/sql:/sql
|
||||||
|
- ./host/database/backups:/backups
|
||||||
|
# Configuration
|
||||||
|
- ./host/database/conf/my.cnf:/etc/mysql/mariadb.conf.d/my.cnf
|
||||||
|
environment:
|
||||||
|
MARIADB_ROOT_PASSWORD: ${DATABASE_ROOT_PASSWORD}
|
||||||
|
networks:
|
||||||
|
- backend
|
||||||
|
|
||||||
|
# Configuration d'Apache et de PHP
|
||||||
|
apache-php:
|
||||||
|
restart: unless-stopped
|
||||||
|
container_name: ${CONTAINER_PREFIX}_apache_php
|
||||||
|
image: ${APACHE_PHP_VERSION}
|
||||||
|
environment:
|
||||||
|
- APACHE_ADMIN_EMAIL=${APACHE_ADMIN_EMAIL}
|
||||||
|
volumes:
|
||||||
|
- ./www:/var/www/html
|
||||||
|
- ./host/apache/logs:/var/log/apache2
|
||||||
|
- ./host/apache/conf/vhost.conf:/etc/apache2/sites-available/000-default.conf
|
||||||
|
- ./host/apache/conf/apache2.conf:/etc/apache2/conf-enabled/docker.conf
|
||||||
|
depends_on:
|
||||||
|
- database
|
||||||
|
labels:
|
||||||
|
- traefik.enable=true
|
||||||
|
- traefik.docker.network=frontend
|
||||||
|
- traefik.http.routers.${CONTAINER_PREFIX}_apache.rule=Host(`${PROJECT_URL}`)
|
||||||
|
- traefik.http.routers.${CONTAINER_PREFIX}_apache.entrypoints=web
|
||||||
|
- traefik.http.routers.${CONTAINER_PREFIX}_apache.entrypoints=websecure
|
||||||
|
- traefik.http.routers.${CONTAINER_PREFIX}_apache.tls=true
|
||||||
|
networks:
|
||||||
|
- frontend
|
||||||
|
- backend
|
||||||
|
|
||||||
|
# Configuration de PHPMyAdmin
|
||||||
|
phpmyadmin:
|
||||||
|
restart: unless-stopped
|
||||||
|
container_name: ${CONTAINER_PREFIX}
|
||||||
|
image: ${PHPMYADMIN_IMAGE}
|
||||||
|
depends_on:
|
||||||
|
- database
|
||||||
|
labels:
|
||||||
|
- traefik.enable=true
|
||||||
|
- traefik.docker.network=frontend
|
||||||
|
- traefik.http.routers.${CONTAINER_PREFIX}_pma.rule=Host(`${PHPMYADMIN_URL}`)
|
||||||
|
- traefik.http.routers.${CONTAINER_PREFIX}_pma.entrypoints=web
|
||||||
|
- traefik.http.routers.${CONTAINER_PREFIX}_pma.entrypoints=websecure
|
||||||
|
- traefik.http.routers.${CONTAINER_PREFIX}_pma.tls=true
|
||||||
|
environment:
|
||||||
|
- PMA_HOST=database
|
||||||
|
networks:
|
||||||
|
- frontend
|
||||||
|
- backend
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ServerName localhost
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<VirtualHost *:80>
|
||||||
|
ServerAdmin ${APACHE_ADMIN_EMAIL}
|
||||||
|
|
||||||
|
<Directory /var/www/html>
|
||||||
|
Options -Indexes +FollowSymLinks
|
||||||
|
AllowOverride All
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||||
|
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
[mysqld]
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
tls:
|
||||||
|
certificates:
|
||||||
|
- certFile: /certs/localhost.crt
|
||||||
|
- keyFile: /certs/localhost.key
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<?php phpinfo(); ?>
|
||||||
Reference in New Issue
Block a user