fix: improve image build
This commit is contained in:
@@ -1,29 +1,60 @@
|
||||
# docker-compose.yml for production
|
||||
# This setup builds and runs the optimized production image.
|
||||
# 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 update, run: docker compose build
|
||||
# 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:
|
||||
app:
|
||||
# This service runs the Eleventy development server.
|
||||
eleventy:
|
||||
build:
|
||||
context: .
|
||||
target: production # Use the 'production' stage from the Dockerfile
|
||||
platform: linux/arm64
|
||||
container_name: eleventy_prod
|
||||
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:
|
||||
# Persist the view count data in a named volume.
|
||||
- data:/app/_data
|
||||
restart: unless-stopped
|
||||
labels:
|
||||
diun.enable: true
|
||||
homepage.group: Tools
|
||||
homepage.name: 11ty Website
|
||||
homepage.icon: https://jesus.twk95.com/android-chrome-192x192.png
|
||||
homepage.href: ${APP_URL}
|
||||
# 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:
|
||||
- proxy
|
||||
volumes:
|
||||
data: null
|
||||
# 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 has been moved to the eleventy service.
|
||||
command: node --watch src/server.js
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
external: true
|
||||
dev_network:
|
||||
driver: bridge
|
||||
|
Reference in New Issue
Block a user