Skip to main content
Docker Compose provides a complete local development environment with all required services and dependencies.

Overview

The compose.yml file defines a multi-service environment that includes:
  • LocalStack: AWS services emulation (S3, SQS, SNS, Firehose)
  • Redis: In-memory data store
  • MongoDB: Document database
  • epr-laps-backend: The main application service

Quick Start

1

Start all services

Build and start all services in detached mode:
docker compose up --build -d
This will:
  • Build the epr-laps-backend image from the local Dockerfile
  • Pull required images (LocalStack, Redis, MongoDB)
  • Create the cdp-tenant network
  • Start all services with health checks
2

Verify services are running

Check the status of all services:
docker compose ps
All services should show a status of “Up” or “Up (healthy)”.
3

View logs

View logs from all services:
docker compose logs -f
Or view logs from a specific service:
docker compose logs -f epr-laps-backend
4

Stop services

Stop all running services:
docker compose down
To remove volumes as well:
docker compose down -v

Service Configuration

LocalStack

Emulates AWS services for local development.
Image
string
default:"localstack/localstack:3.0.2"
Official LocalStack image
Ports
array
  • 4566: LocalStack Gateway (main endpoint)
  • 4510-4559: External services port range
Services
string
Enabled AWS services: s3, sqs, sns, firehose
Environment Variables:
  • DEBUG: Debug mode (default: 1)
  • LS_LOG: LocalStack log level (set to WARN)
  • LOCALSTACK_HOST: Host address (127.0.0.1)
Volumes:
  • ${TMPDIR:-/tmp}/localstack:/var/lib/localstack - LocalStack data
  • ./compose/start-localstack.sh:/etc/localstack/init/ready.d/start-localstack.sh - Initialization script
Health Check:
test: ['CMD', 'curl', 'localhost:4566']
interval: 5s
start_period: 5s
retries: 3
LocalStack requires the compose/aws.env file for AWS credentials configuration.

Redis

In-memory data store for caching and session management.
Image
string
default:"redis:7.2.3-alpine3.18"
Official Redis Alpine image
Port
number
default:"6379"
Standard Redis port
Configuration:
  • Restart policy: always
  • Network: cdp-tenant
  • No authentication (local development only)
This Redis configuration is for local development only. Production deployments should use authentication and encryption.

MongoDB

Document database for application data storage.
Image
string
default:"mongo:6.0.13"
Official MongoDB image
Port
number
default:"27017"
Standard MongoDB port
Volumes:
  • mongodb-data:/data - Named volume for persistent data storage
Configuration:
  • Restart policy: always
  • Network: cdp-tenant
  • No authentication (local development only)
MongoDB data persists across container restarts using the named volume mongodb-data.

EPR LAPS Backend

The main application service.
Build
object
  • context: Current directory (.)
  • target: development stage from Dockerfile
Port
number
default:"3001"
Application port (mapped to 3001:3001)
Service Dependencies:
depends_on:
  localstack:
    condition: service_healthy
  mongodb:
    condition: service_started
The application waits for:
  • LocalStack to be healthy (passes health check)
  • MongoDB to start (doesn’t wait for ready state)
Environment Variables:
  • PORT: 3001
  • NODE_ENV: development
  • LOCALSTACK_ENDPOINT: http://localstack:4566
  • MONGO_URI: mongodb://mongodb:27017/
  • Additional variables from compose/aws.env
Volumes for Hot-Reloading:
volumes:
  - ./src:/home/node/src
  - ./package.json:/home/node/package.json
Source code changes are automatically reflected in the running container without rebuilding.

Network Configuration

All services communicate over the cdp-tenant bridge network:
networks:
  cdp-tenant:
    driver: bridge
    name: cdp-tenant
Services can reference each other by service name (e.g., mongodb, localstack, redis).

Volume Management

The compose file defines a named volume for MongoDB:
volumes:
  mongodb-data:
Volume Operations:
docker volume ls

Required Configuration Files

The docker-compose setup requires the following files:
compose/aws.env
file
AWS credentials and configuration for LocalStack.Required variables:
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_DEFAULT_REGION
compose/start-localstack.sh
file
Initialization script for LocalStack services.Runs when LocalStack reaches the ready state to configure S3 buckets, SQS queues, etc.

Common Operations

Rebuilding Services

Rebuild a specific service after code changes:
docker compose up --build epr-laps-backend

Restarting Services

Restart a specific service:
docker compose restart epr-laps-backend

Scaling Services

The current configuration doesn’t support scaling the main application due to volume mounts and port conflicts.

Accessing Service Shells

Open a shell in a running container:
docker compose exec epr-laps-backend sh

Viewing Service Configuration

Display the resolved compose configuration:
docker compose config

Troubleshooting

LocalStack Not Healthy

If LocalStack fails health checks:
# Check LocalStack logs
docker compose logs localstack

# Verify LocalStack is accessible
curl http://localhost:4566/_localstack/health

MongoDB Connection Issues

Verify MongoDB is accessible:
# Test connection from host
mongosh mongodb://localhost:27017/

# Test from application container
docker compose exec epr-laps-backend sh -c "curl -v telnet://mongodb:27017"

Port Conflicts

If ports are already in use:
# Check what's using the port
lsof -i :3001

# Modify ports in compose.yml
ports:
  - '3002:3001'  # Map to different host port

Volume Permission Issues

If you encounter permission errors with volumes:
# Fix ownership of mounted volumes
sudo chown -R $USER:$USER ./src

Frontend Integration (Optional)

The compose file includes a commented-out frontend service example:
# frontend:
#   image: defradigital/frontend:${FRONTEND_VERSION:-latest}
#   ports:
#     - '3000:3000'
#   depends_on:
#     - localstack
#     - redis
Uncomment and configure this section if you need to run the frontend alongside the backend.

Performance Optimization

Build Cache

Speed up builds by using BuildKit:
DOCKER_BUILDKIT=1 docker compose build

Resource Limits

Add resource constraints to prevent services from consuming too much memory:
epr-laps-backend:
  deploy:
    resources:
      limits:
        memory: 1G
      reservations:
        memory: 512M

Next Steps

Build docs developers (and LLMs) love