61 lines
2.3 KiB
YAML
61 lines
2.3 KiB
YAML
# docker-compose.dev.yml for development
|
|
# This setup runs two services:
|
|
# 1. The Eleventy dev server for live-reloading site changes.
|
|
# 2. The Express API server for the view counter.
|
|
#
|
|
# To start both, run: docker compose -f docker-compose.dev.yml up
|
|
#
|
|
# Your site will be available at http://localhost:8080.
|
|
# API requests are proxied from /api to the API service, so you don't need to access port 3000 directly.
|
|
services:
|
|
# This service runs the Eleventy development server.
|
|
eleventy:
|
|
build:
|
|
context: .
|
|
target: development # Use the 'development' stage from the Dockerfile
|
|
# Adding `init: true` ensures that the container's main process receives
|
|
# signals correctly (like SIGINT/SIGTERM) when you stop the container.
|
|
# This helps the dev server to shut down gracefully.
|
|
init: true
|
|
container_name: eleventy_dev
|
|
ports:
|
|
- "9229:9229" # Node.js debugger port
|
|
- "8080:8080" # Eleventy dev server port
|
|
volumes:
|
|
# Mount the project directory for live-reloading.
|
|
# The anonymous volume for node_modules prevents the local one from overwriting the container's.
|
|
- .:/app
|
|
- /app/node_modules
|
|
networks:
|
|
# Both services need to be on the same network for the Eleventy dev server
|
|
# to proxy requests to the API container using its service name ('api').
|
|
- dev_network
|
|
# This command runs Eleventy's dev server with file watching.
|
|
command: npm run debug
|
|
|
|
# This service runs your Express API server.
|
|
api:
|
|
build:
|
|
context: .
|
|
target: development # Use the same 'development' stage
|
|
# Adding `init: true` is especially important for debugging. It ensures
|
|
# the Node.js process receives shutdown signals, allowing the debugger
|
|
# to detach cleanly.
|
|
init: true
|
|
container_name: api_dev
|
|
# The API port does not need to be exposed to the host. The 'eleventy'
|
|
# service proxies requests to it over the internal Docker network.
|
|
volumes:
|
|
- .:/app
|
|
- /app/node_modules
|
|
networks:
|
|
- dev_network
|
|
# Use Node's built-in --watch mode instead of nodemon. It can be more
|
|
# stable inside Docker and avoids some of nodemon's complexities. The
|
|
# --inspect flag is attached to the 'eleventy' service for debugging.
|
|
command: node --watch server.js
|
|
|
|
networks:
|
|
dev_network:
|
|
driver: bridge
|