Docker Installation
This guide explains how to install Docker and deploy PCH-SIG with Docker Compose.
Installing Docker
On Ubuntu/Debian
# System update
sudo apt update && sudo apt upgrade -y
# Install dependencies
sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release
# Add Docker GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Add Docker repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Add user to docker group
sudo usermod -aG docker $USER
On Windows with Docker Desktop
- Download Docker Desktop from https://www.docker.com/products/docker-desktop
- Run the installer
- Enable WSL 2 if prompted
- Restart the computer
On Windows with Docker Toolbox (without Hyper-V)
For Windows servers without Hyper-V:
- Install VirtualBox
- Install Docker Toolbox
- Launch Docker Quickstart Terminal
- The Docker VM will be accessible at 192.168.99.100
Verifying the installation
# Docker version
docker --version
# Docker Compose version
docker compose version
# Test Docker
docker run hello-world
Project structure
pch-sig/
├── backend/ # Symfony API
├── frontend/ # React application
├── deploy/
│ ├── docker-compose.yml # Docker configuration
│ ├── docker-compose.toolbox.yml # Docker Toolbox config
│ └── nginx-conf/ # Nginx configuration
├── monitoring/ # Grafana, Prometheus
└── documentation/ # Docusaurus
Deployment with Docker Compose
docker-compose.yml file
The main file defines all services:
version: '3.8'
services:
# PostgreSQL database with PostGIS
postgres:
image: postgis/postgis:15-3.4-alpine
container_name: pch_postgres
environment:
POSTGRES_DB: pch_sig
POSTGRES_USER: pch_admin
POSTGRES_PASSWORD: pch_secure_2025
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
restart: always
# Redis cache
redis:
image: redis:7-alpine
container_name: pch_redis
command: redis-server --requirepass redis_secure_2025
volumes:
- redis_data:/data
ports:
- "6379:6379"
restart: always
# Backend PHP-FPM
backend:
image: webdevops/php:8.3-alpine
container_name: pch_backend
working_dir: /app
volumes:
- ../backend:/app
depends_on:
- postgres
- redis
restart: always
# Nginx Backend Proxy
nginx_backend:
image: nginx:alpine
container_name: pch_nginx_backend
volumes:
- ../backend:/app
- ./nginx-conf/backend.conf:/etc/nginx/conf.d/default.conf
ports:
- "8000:80"
depends_on:
- backend
restart: always
# Frontend Nginx
frontend:
image: nginx:alpine
container_name: pch_frontend
volumes:
- ../frontend/build:/usr/share/nginx/html
- ./nginx-conf/default.conf:/etc/nginx/conf.d/default.conf
ports:
- "80:80"
restart: always
# Mailpit (test SMTP)
mailpit:
image: axllent/mailpit:latest
container_name: pch_mailpit
ports:
- "1025:1025"
- "8025:8025"
restart: always
volumes:
postgres_data:
redis_data:
Starting the containers
Initial startup
cd deploy
# Build and start all services
docker compose up -d
# Check status
docker compose ps
Useful commands
# View logs
docker compose logs -f
# Logs for a specific service
docker compose logs -f backend
# Stop services
docker compose down
# Stop and remove volumes
docker compose down -v
# Restart a service
docker compose restart backend
Initial configuration
Create the database
# Access the backend container
docker exec -it pch_backend bash
# Inside the container, run migrations
php bin/console doctrine:database:create
php bin/console doctrine:migrations:migrate --no-interaction
# Load initial data
php bin/console doctrine:fixtures:load --no-interaction
Generate JWT keys
# Inside the backend container
php bin/console lexik:jwt:generate-keypair
Clear cache
docker exec -it pch_backend php bin/console cache:clear
Frontend Build
Locally
cd frontend
npm install
npm run build
The build is served by Nginx
Files from frontend/build/ are served by the pch_frontend container.
Docker Toolbox (Windows Server)
Specific configuration
For server serveur-production using Docker Toolbox:
# docker-compose.toolbox.yml
version: '3.8'
services:
# Services are the same but accessible
# via the Docker VM IP: 192.168.99.100
Windows Port Proxy
Configure port proxy for network access:
# Frontend (port 3000 -> VM:80)
netsh interface portproxy add v4tov4 listenport=3000 listenaddress=0.0.0.0 connectport=80 connectaddress=192.168.99.100
# Backend (port 8000 -> VM:8000)
netsh interface portproxy add v4tov4 listenport=8000 listenaddress=0.0.0.0 connectport=8000 connectaddress=192.168.99.100
Deployment verification
Test the services
| Service | Test URL | Expected result |
|---|---|---|
| Frontend | http://localhost:3000 | Login page |
| API | http://localhost:8000/api | API documentation |
| Mailpit | http://localhost:8025 | Email interface |
Check containers
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"