Add Docker development workflow

This commit is contained in:
2026-07-22 22:42:28 +02:00
parent 00cb07f848
commit c991f493da
6 changed files with 127 additions and 5 deletions
+8
View File
@@ -0,0 +1,8 @@
.git
.agents
.codex
.next
data
dist
node_modules
npm-debug.log*
+12
View File
@@ -0,0 +1,12 @@
FROM node:22-bookworm-slim
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
EXPOSE 3000 3001
+31 -3
View File
@@ -155,11 +155,39 @@ Die folgende Liste fasst die zentralen Anforderungen zusammen und zeigt den aktu
## Schneller Entwicklungsstart ## Schneller Entwicklungsstart
### Mit Docker (empfohlen fuer kurze Sessions)
Voraussetzung: Docker Desktop mit aktivem Docker-Compose-Plugin.
1. Sicherstellen, dass keine direkt gestartete API und kein direkt gestartetes Frontend mehr auf Port 3000/3001 laufen.
2. `npm run docker:up`
3. Frontend unter `http://localhost:3001` oeffnen.
Beim Start fuehrt der API-Container ausstehende Drizzle-Migrationen und die Circuit-First-Schemapruefung aus. Die vorhandene SQLite-Datenbank wird ueber `./data:/app/data` eingebunden und bleibt nach `npm run docker:down` erhalten. Quellcodeaenderungen unter `src/` werden von beiden Entwicklungsservern automatisch erkannt.
Weitere Docker-Befehle:
- `npm run docker:down` - Frontend und API stoppen
- `npm run docker:logs` - laufende Containerlogs anzeigen
- `docker compose ps` - Status und Healthchecks anzeigen
- `Invoke-WebRequest http://localhost:3000/health` - API-Healthcheck pruefen
Bewusster Datenbank-Reset unter PowerShell:
1. `npm run docker:down`
2. `npm run db:backup`
3. `Remove-Item -LiteralPath .\data\leistungsbilanz.db`
4. `npm run docker:up`
Der Reset entfernt die aktive lokale Datenbank. Die zuvor erzeugte Sicherung bleibt unter `data/backups/` erhalten.
### Ohne Docker
1. `npm install` 1. `npm install`
2. `npm run db:generate` 2. `npm run db:migrate`
3. `npm run db:migrate` 3. `npm run db:verify:circuit-schema`
4. `npm run dev:api` (API auf Port 3000) 4. `npm run dev:api` (API auf Port 3000)
5. `npm run dev:web` (Frontend auf Port 3001) 5. In einem zweiten Terminal `npm run dev:web` (Frontend auf Port 3001)
## Wichtige Befehle ## Wichtige Befehle
+69
View File
@@ -0,0 +1,69 @@
name: leistungsbilanz
services:
api:
build:
context: .
command:
- sh
- -c
- npm run db:migrate && npm run db:verify:circuit-schema && npm run dev:api
environment:
PORT: "3000"
CHOKIDAR_USEPOLLING: "true"
init: true
ports:
- "3000:3000"
volumes:
- ./src:/app/src
- ./scripts:/app/scripts
- ./data:/app/data
- ./drizzle.config.ts:/app/drizzle.config.ts:ro
- ./tsconfig.json:/app/tsconfig.json:ro
healthcheck:
test:
- CMD
- node
- -e
- fetch('http://localhost:3000/health').then(response=>{if(!response.ok)process.exit(1)}).catch(()=>process.exit(1))
interval: 5s
timeout: 3s
retries: 12
start_period: 20s
web:
build:
context: .
command:
- npm
- run
- dev:web
- --
- --hostname
- 0.0.0.0
environment:
API_INTERNAL_URL: http://api:3000
WATCHPACK_POLLING: "true"
NEXT_TELEMETRY_DISABLED: "1"
init: true
depends_on:
api:
condition: service_healthy
ports:
- "3001:3001"
volumes:
- ./src:/app/src
- ./next.config.mjs:/app/next.config.mjs:ro
- ./next-env.d.ts:/app/next-env.d.ts:ro
- ./tsconfig.json:/app/tsconfig.json:ro
- ./tsconfig.next.json:/app/tsconfig.next.json:ro
healthcheck:
test:
- CMD
- node
- -e
- fetch('http://localhost:3001/').then(response=>{if(!response.ok)process.exit(1)}).catch(()=>process.exit(1))
interval: 5s
timeout: 3s
retries: 12
start_period: 20s
+4 -2
View File
@@ -1,4 +1,6 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const apiInternalUrl = (process.env.API_INTERNAL_URL || "http://localhost:3000").replace(/\/$/, "");
const nextConfig = { const nextConfig = {
typescript: { typescript: {
tsconfigPath: "./tsconfig.next.json", tsconfigPath: "./tsconfig.next.json",
@@ -7,11 +9,11 @@ const nextConfig = {
return [ return [
{ {
source: "/api/:path*", source: "/api/:path*",
destination: "http://localhost:3000/api/:path*", destination: `${apiInternalUrl}/api/:path*`,
}, },
{ {
source: "/health", source: "/health",
destination: "http://localhost:3000/health", destination: `${apiInternalUrl}/health`,
}, },
]; ];
}, },
+3
View File
@@ -7,6 +7,9 @@
"dev": "npm run dev:api", "dev": "npm run dev:api",
"dev:api": "tsx watch src/server/index.ts", "dev:api": "tsx watch src/server/index.ts",
"dev:web": "next dev -p 3001", "dev:web": "next dev -p 3001",
"docker:up": "docker compose up --build",
"docker:down": "docker compose down",
"docker:logs": "docker compose logs --follow",
"build": "npm run build:api", "build": "npm run build:api",
"build:api": "tsc -p tsconfig.json", "build:api": "tsc -p tsconfig.json",
"build:web": "next build", "build:web": "next build",