feat: add docker-compose.dev.yml for local development

- docker-compose.dev.yml: backend on 8000, frontend (Vite) on 5173
- Backend mounts source files + uvicorn --reload for hot reload
- Frontend uses node:20-alpine, mounts ./frontend, runs npm run dev --host
- vite.config.ts: proxy target reads from API_TARGET env var
  (defaults to localhost:8000 for plain npm run dev,
   set to http://backend:8000 by docker-compose.dev.yml)

Usage: docker compose -f docker-compose.dev.yml up

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-27 16:08:53 +01:00
parent 6d168652d4
commit 06e6ae700f
2 changed files with 47 additions and 8 deletions

View File

@@ -1,20 +1,18 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// When running inside Docker the backend is reachable via its service name.
// Outside Docker (plain `npm run dev`) it falls back to localhost.
const apiTarget = process.env.API_TARGET ?? 'http://localhost:8000'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
server: {
port: 5173,
proxy: {
'/api': {
target: 'http://localhost:8000',
changeOrigin: true,
},
'/health': {
target: 'http://localhost:8000',
changeOrigin: true,
}
'/api': { target: apiTarget, changeOrigin: true },
'/health': { target: apiTarget, changeOrigin: true },
}
}
})