-
Notifications
You must be signed in to change notification settings - Fork 9
Docker Deployment
This document covers the containerized deployment architecture of the Effective Office system using Docker and Docker Compose. It explains the multi-environment setup, container orchestration, and deployment automation processes.
For information about application configuration and environment variables, see [Configuration Management](Configuration Management). For overall system architecture context, see [System Architecture](System Architecture).
The Effective Office system uses Docker Compose to orchestrate multiple services across development and production environments. The deployment strategy separates application logic, database services, and reverse proxy functionality into distinct containers.
The main application runs as a Spring Boot service in a Docker container built from a custom Dockerfile. The container exposes port 8080 and includes comprehensive health monitoring.
| Configuration | Development | Production |
|---|---|---|
| Container Name | effective-office-app-dev |
effective-office-app-prod |
| Port Exposure | 8080 | 8080 |
| Health Check | /api/actuator/health |
/api/actuator/health |
| Restart Policy | unless-stopped |
unless-stopped |
The application container configuration includes:
# From deploy/dev/docker-compose.yml
app:
build:
context: .
dockerfile: Dockerfile
container_name: effective-office-app-dev
expose:
- "8080"
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:8080/api/actuator/health" ]
interval: 30s
timeout: 10s
retries: 5
start_period: 40s
PostgreSQL 15 Alpine provides the persistence layer with environment-specific port mappings and data volumes.
| Configuration | Development | Production |
|---|---|---|
| Container Name | effective-office-db-dev |
effective-office-db-prod |
| Image | postgres:15-alpine |
postgres:15-alpine |
| Port Mapping | 5433:5432 |
5432:5432 |
| Volume | postgres-data-dev |
postgres-data-prod |
Database health checks ensure service availability:
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
interval: 10s
timeout: 5s
retries: 5
The deployment uses two network configurations to isolate environments and enable external access:
Network configuration from Docker Compose:
networks:
effective-office-network-dev:
driver: bridge
caddy:
external: true
The build system provides automated deployment tasks that handle JAR compilation, file transfer, and remote deployment coordination.
Development deployment:
./gradlew deployDev -PremoteUser=user -PremoteHost=hostname -PremotePath=/path/to/deploy
Production deployment:
./gradlew deployProd -PremoteUser=user -PremoteHost=hostname -PremotePath=/path/to/deploy
The deployment process executes these steps:
-
JAR Build:
bootJartask createsapp-{version}-boot.jar -
Local Preparation: Copy JAR to
deploy/{env}/directory - Remote Cleanup: SSH command removes old deployment files
-
File Transfer:
rsyncsynchronizes local deploy directory to remote server - Container Restart: Docker Compose manages service updates
Caddy serves as the reverse proxy, handling SSL termination and load balancing. The application containers expose port 8080 internally and rely on Caddy labels for external routing.
labels:
caddy: ${LABEL}
caddy.reverse_proxy: "{{upstreams 8080}}"
The LABEL environment variable specifies the domain name for external access, while the reverse proxy directive routes traffic to port 8080 on the application container.
The deployment system uses .env files to manage environment-specific configuration:
| Variable | Purpose | Example |
|---|---|---|
POSTGRES_DB |
Database name | effective_office |
POSTGRES_USER |
Database username | office_user |
POSTGRES_PASSWORD |
Database password | secure_password |
SPRING_DATASOURCE_URL |
Database connection URL | jdbc:postgresql://db:5432/effective_office |
MIGRATIONS_ENABLE |
Enable Flyway migrations | true |
LOG_LEVEL |
Application log level | DEBUG |
LABEL |
Caddy routing domain | dev.effective-office.com |
- Development: deploy/dev/.env.example
- Production: deploy/prod/.env.example
The deployment implements comprehensive health checking to ensure service reliability:
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:8080/api/actuator/health" ]
interval: 30s
timeout: 10s
retries: 5
start_period: 40s
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
interval: 10s
timeout: 5s
retries: 5
The application container includes dependency management:
depends_on:
db:
condition: service_healthy
This ensures the database is ready before the application starts, preventing connection failures during container startup.
Persistent data storage is handled through named Docker volumes:
- Volume Name:
effective-office-dev-db-data - Mount Point:
/var/lib/postgresql/data - Container:
effective-office-db-dev
- Volume Name:
effective-office-prod-db-data - Mount Point:
/var/lib/postgresql/data - Container:
effective-office-db-prod
The volume configuration ensures database data persistence across container restarts and updates:
volumes:
postgres-data-dev:
name: effective-office-dev-db-data