fix docker setup

This commit is contained in:
2025-12-26 01:01:59 +01:00
parent b6cbb81388
commit d08ec10b40
9 changed files with 84 additions and 60 deletions

View File

@@ -1,5 +1,30 @@
services:
deps:
image: node:20-alpine
working_dir: /app
env_file:
- .env.development
environment:
- NODE_ENV=development
- NPM_CONFIG_FUND=false
- NPM_CONFIG_AUDIT=false
- NPM_CONFIG_UPDATE_NOTIFIER=false
volumes:
- ./:/app
- dev_node_modules:/app/node_modules
- dev_npm_cache:/root/.npm
command:
[
"sh",
"-lc",
"set -e; LOCK_HASH=\"$$(sha1sum package-lock.json | awk '{print $$1}')\"; MARKER=\"node_modules/.gridpilot_lock_hash_dev\"; if [ -f \"$$MARKER\" ] && [ \"$$(cat \"$$MARKER\")\" = \"$$LOCK_HASH\" ]; then echo \"[deps] node_modules up-to-date\"; else echo \"[deps] installing api+website deps (slow first time)\"; npm install --no-package-lock --workspace=./apps/api --workspace=./apps/website --include-workspace-root --no-audit --fund=false --prefer-offline; node -e \"require.resolve('ts-node-dev')\"; node -e \"require.resolve('next')\"; echo \"$$LOCK_HASH\" > \"$$MARKER\"; fi",
]
networks:
- gridpilot-network
restart: "no"
api:
image: gridpilot-api-dev
build:
context: .
dockerfile: apps/api/Dockerfile.dev
@@ -8,21 +33,29 @@ services:
environment:
- NODE_ENV=development
ports:
- "3000:3000"
- "3001:3000"
- "9229:9229"
volumes:
- ./apps/api:/app/apps/api
- ./core:/app/core
- ./adapters:/app/adapters
- ./tsconfig.base.json:/app/tsconfig.base.json:ro
- ./:/app
- dev_node_modules:/app/node_modules
- dev_npm_cache:/root/.npm
command: ["sh", "-lc", "npm run start:dev --workspace=@gridpilot/api"]
depends_on:
deps:
condition: service_completed_successfully
db:
condition: service_healthy
networks:
- gridpilot-network
restart: unless-stopped
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://localhost:3000/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"]
interval: 5s
timeout: 5s
retries: 10
website:
image: gridpilot-website-dev
build:
context: .
dockerfile: apps/website/Dockerfile.dev
@@ -30,14 +63,20 @@ services:
- .env.development
environment:
- NEXT_TELEMETRY_DISABLED=1
- NODE_ENV=development
- API_BASE_URL=http://api:3000
ports:
- "3001:3000"
- "3000:3000"
volumes:
- ./apps/website:/app/apps/website
- ./core:/app/core
- ./adapters:/app/adapters
- ./scripts:/app/scripts
- ./tsconfig.base.json:/app/tsconfig.base.json:ro
- ./:/app
- dev_node_modules:/app/node_modules
- dev_npm_cache:/root/.npm
command: ["sh", "-lc", "npm run dev --workspace=@gridpilot/website"]
depends_on:
deps:
condition: service_completed_successfully
api:
condition: service_healthy
networks:
- gridpilot-network
restart: unless-stopped
@@ -65,3 +104,5 @@ networks:
volumes:
dev_db_data:
dev_node_modules:
dev_npm_cache: