De Express-app serveert nu zelf de gebouwde Vite-frontend op / met een SPA-fallback naar index.html; de aparte nginx-container is vervallen. Bedoeld voor self-hosting op een Raspberry Pi: één image, één origin, geen interne proxy en geen CORS tussen frontend en API. Docker - Nieuwe multi-stage Dockerfile in de root met targets test, development en production; frontend/Dockerfile, frontend/nginx-spa.conf en backend/Dockerfile verwijderd - docker-compose.yml: alleen app + postgres, app publiceert APP_PORT (standaard 3400) naar containerpoort 3001 - docker-compose.dev.yml: dev-container draait API (node --watch) en de Vite dev-server samen via docker/dev-entrypoint.sh, hot reload intact - .dockerignore, .env.example, .gitignore en .gitattributes toegevoegd Backend - express.static + SPA-fallback op STATIC_DIR (default /app/public), met immutable caching voor gehashte assets en no-store voor index.html - Rate limiting alleen nog op /api — statische bestanden liepen anders na 200 requests tegen de limiet aan - Helmet CSP toegespitst op wat de frontend laadt (Google Fonts, inline styles, base64-avatars); upgrade-insecure-requests uit voor intern http - Schema-init verplaatst naar initDb(), niet meer bij import van db.js Tests en CI/CD - backend/test/app.test.js: 11 tests (node --test) voor API-routes, SPA-fallback, cache- en security-headers, zonder database - test.ps1 / test.sh: backend-tests, productiebuild en smoketest op de echte app + postgres stack - azure-pipelines.yml: Test -> Build (incl. smoketest) -> Publish (multi-arch amd64 + arm64, alleen op main/master of een tag) Scripts en documentatie - dev.ps1/dev.sh met targets app en postgres, acties logs en test; dev.ps1 up wist de dev-database niet langer (alleen dev.ps1 down) - release.ps1/release.sh bouwen één image voor amd64 + arm64 en draaien de testsuite vóór het publiceren - README.md en BEHEER.md bijgewerkt voor de nieuwe structuur Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
75 lines
2.2 KiB
YAML
75 lines
2.2 KiB
YAML
##
|
|
## VibeFinance dev-stack — 2 containers, zelfde structuur als productie
|
|
##
|
|
## app API (node --watch) + Vite dev-server met hot reload
|
|
## postgres database
|
|
##
|
|
## docker compose -f docker-compose.dev.yml up --build
|
|
##
|
|
## De browser praat met Vite op poort 80; Vite proxyt /api naar de API in
|
|
## dezelfde container (localhost:3001). De API is ook direct bereikbaar op 3001.
|
|
##
|
|
|
|
services:
|
|
|
|
postgres:
|
|
image: postgres:18-alpine
|
|
container_name: vibefinance-postgres-dev
|
|
environment:
|
|
POSTGRES_DB: ${POSTGRES_DB:-vibefinance}
|
|
POSTGRES_USER: ${POSTGRES_USER:-vibefinance}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-devpassword}
|
|
volumes:
|
|
- postgres_dev_data:/var/lib/postgresql
|
|
networks:
|
|
- dev
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-vibefinance}"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
app:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
target: development
|
|
args:
|
|
VITE_APP_VERSION: ${VITE_APP_VERSION:-dev}
|
|
image: vibefinance/app:${VERSION:-latest-dev}
|
|
container_name: vibefinance-app-dev
|
|
ports:
|
|
- "80:5173" # Vite dev-server (de app in de browser)
|
|
- "3001:3001" # API, handig voor curl/Postman
|
|
volumes:
|
|
- ./backend:/app
|
|
- /app/node_modules
|
|
- ./frontend:/app/frontend
|
|
- /app/frontend/node_modules
|
|
environment:
|
|
NODE_ENV: development
|
|
PORT: 3001
|
|
JWT_SECRET: dev-secret-change-in-production
|
|
JWT_EXPIRES: 7d
|
|
CORS_ORIGIN: http://localhost
|
|
DATABASE_URL: postgresql://${POSTGRES_USER:-vibefinance}:${POSTGRES_PASSWORD:-devpassword}@postgres:5432/${POSTGRES_DB:-vibefinance}
|
|
UPDATE_CHECK_URL: ${UPDATE_CHECK_URL:-https://vibehoogie.duckdns.org/api/v1/repos/vibe/VibeFinance/releases/latest}
|
|
networks:
|
|
- dev
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
# 127.0.0.1 i.p.v. localhost: Vite luistert alleen op IPv4
|
|
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:3001/api/health && wget -qO- http://127.0.0.1:5173/ > /dev/null || exit 1"]
|
|
interval: 15s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 25s
|
|
|
|
volumes:
|
|
postgres_dev_data:
|
|
|
|
networks:
|
|
dev:
|