Docker Overrides
For local development, Docker Compose runs infrastructure services (Kong gateway, PostgreSQL, Redis, monitoring tools). Your backend services (auth-service, bff-service, etc.) run natively via npm for faster iteration.
Use docker-compose.user.yml to add extra infrastructure or override Docker settings without modifying framework-managed files.
If your docker-compose.user.yml references ${VARIABLE_NAME} placeholders, run npx tsdevstack generate-secrets first to populate the .env file that Docker Compose reads from.
How it works
The framework's docker-compose.yml includes your user file automatically:
This means docker compose up automatically merges your customizations. Services you define are added; settings you specify for existing services override the defaults.
Adding extra services
Create docker-compose.user.yml in your project root to add services the framework does not provide.
Email testing with Mailhog
Capture outgoing emails during development:
Access the web UI at http://localhost:8025 to view captured emails.
Configure your services to use it:
Search with Elasticsearch
Add a local Elasticsearch instance:
Cache with Memcached
Add a Memcached instance for specialized caching needs beyond what Redis provides:
For inter-service messaging, use the built-in Async Messaging feature (Redis Streams) instead of adding a separate message broker. For background jobs, use the built-in BullMQ integration.
Mounting volumes
Persistent data volumes
Keep data across container restarts:
Overriding defaults
Override settings for infrastructure services defined in docker-compose.yml:
Increase resource limits
Give a service more memory:
Change port mappings
Expose a service on a different port:
Add environment variables
Inject additional environment variables into Docker services:
Note: Backend services (auth-service, bff-service, etc.) run natively via npm, not in Docker. To configure environment variables for backend services, use .secrets.user.json instead.
Referencing secrets
Use ${VARIABLE_NAME} syntax to reference values from your .env file:
Add the secret to your secrets file:
The framework generates .env from your secrets, making variables available to Docker Compose.
Networking
Connecting to framework services
Use the tsdevstack-network to communicate with framework-managed services:
Services on this network can reach each other by service name:
auth-db,offers-db- PostgreSQL databasesredis- Redis cachegateway- Kong gateway
Note: Backend services run on the host, not in Docker. To reach them from Docker containers, use host.docker.internal (e.g., host.docker.internal:3001 for auth-service).
Adding a separate network
For services that should not access the main network:
Complete example
A realistic docker-compose.user.yml combining several patterns:
To configure backend services to use these infrastructure services, add to .secrets.user.json:
Cloud deployment considerations
docker-compose.user.yml is for local development only. For cloud environments, you need to:
-
Provision managed services - Use cloud-native equivalents (Elastic Cloud, Amazon SES, etc.)
-
Configure connection strings - Add URLs via cloud secrets:
- Update service code - Ensure your code uses the same environment variable names locally and in production
The framework does not deploy custom Docker services to the cloud. You are responsible for provisioning and connecting to managed alternatives.
Troubleshooting
Service cannot connect to framework services
Ensure your service is on tsdevstack-network:
Environment variable not available
Check that:
- The variable exists in
.secrets.user.json - You ran
npx tsdevstack generate-secretsto update.env - You restarted the containers
Volume mount not updating
On macOS, try adding :delegated to the volume mount. On all platforms, ensure the path is correct and the file exists.
Port conflict
Another service is using the port. Either stop the conflicting service or change the port mapping in your override: