Docker Setup for CBS Simulator
Quick Start
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f cbs-simulator
# Stop all services
docker-compose down
# Stop and remove volumes (clean data)
docker-compose down -v
Services
PostgreSQL
- Port: 5434 (host) → 5432 (container)
- Database:
cbs_simulator - User:
cbs_simulator - Password:
cbs_simulator - Volume:
postgres_data(persistent)
CBS Simulator
- Port: 8082 (host) → 8080 (container)
- Health Check:
http://localhost:8082/actuator/health - Flyway: Runs automatically on startup
Environment Variables
You can override default values using environment variables:
# Database
export DB_NAME=cbs_simulator
export DB_USERNAME=cbs_simulator
export DB_PASSWORD=cbs_simulator
export DB_PORT=5434
# Server
export SERVER_PORT=8082
# Then start
docker-compose up -d
Data Persistence
- PostgreSQL data is stored in a Docker volume:
postgres_data - Data persists across container restarts
- To reset data:
docker-compose down -v
Flyway Migrations
Flyway runs automatically on application startup:
V0__init_schema.sql- Creates database schemaV1__init_cbs_customers.sql- Inserts 100 customersV2__init_cbs_accounts.sql- Inserts ~277 accounts
Migrations are deterministic and reproducible (seed: 42).
Health Checks
Both services have health checks:
- PostgreSQL: Checks if database is ready
- CBS Simulator: Checks if application is responding
The simulator waits for PostgreSQL to be healthy before starting.
Testing
# Test customer information API
curl http://localhost:8082/api/customers/7854001/infromations
# Test accounts API
curl http://localhost:8082/api/contract/contract/7854001/accounts
# Test health endpoint
curl http://localhost:8082/actuator/health
Troubleshooting
Check logs
docker-compose logs cbs-simulator
docker-compose logs postgres
Check database connection
docker-compose exec postgres psql -U cbs_simulator -d cbs_simulator -c "SELECT COUNT(*) FROM customers;"
Rebuild after code changes
docker-compose build cbs-simulator
docker-compose up -d cbs-simulator