diff --git a/backend/Dockerfile b/backend/Dockerfile index 476e231..bc33c9f 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -28,5 +28,6 @@ EXPOSE 8080 HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \ CMD wget -q -O /dev/null "http://localhost:${PORT}/health" || exit 1 -# Use at most 75% of the container memory for the heap (the free tiers are small). -ENTRYPOINT ["java", "-XX:MaxRAMPercentage=75", "-jar", "app.jar"] +# Tuned for small containers (the free tiers have ~512 MB): the serial GC uses less memory, +# and the heap is capped at 60% so there is room for metaspace and thread stacks. +ENTRYPOINT ["java", "-XX:MaxRAMPercentage=60", "-XX:+UseSerialGC", "-jar", "app.jar"] diff --git a/backend/src/main/resources/application-prod.properties b/backend/src/main/resources/application-prod.properties index 10206db..a722862 100644 --- a/backend/src/main/resources/application-prod.properties +++ b/backend/src/main/resources/application-prod.properties @@ -1,2 +1,8 @@ # Production profile: activate with SPRING_PROFILES_ACTIVE=prod spring.jpa.show-sql=false + +# Small connection pool: free PostgreSQL plans (Neon) allow only a few connections. +spring.datasource.hikari.maximum-pool-size=5 +spring.datasource.hikari.minimum-idle=1 +# The database may be waking up from sleep on the first request, so wait longer for a connection. +spring.datasource.hikari.connection-timeout=30000 diff --git a/frontend/vercel.json b/frontend/vercel.json new file mode 100644 index 0000000..00c7c37 --- /dev/null +++ b/frontend/vercel.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://openapi.vercel.sh/vercel.json", + "buildCommand": "npm run build", + "outputDirectory": "dist/frontend/browser", + "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }], + "headers": [ + { + "source": "/(.*)", + "headers": [ + { "key": "X-Content-Type-Options", "value": "nosniff" }, + { "key": "X-Frame-Options", "value": "DENY" }, + { "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" } + ] + } + ] +} diff --git a/render.yaml b/render.yaml new file mode 100644 index 0000000..01832d1 --- /dev/null +++ b/render.yaml @@ -0,0 +1,28 @@ +# Render Blueprint: describes the backend web service. +# Variables marked `sync: false` are asked for in the Render dashboard (they are never stored in Git). +services: + - type: web + name: worklog-api + runtime: docker + region: frankfurt + plan: free + dockerfilePath: ./backend/Dockerfile + dockerContext: ./backend + healthCheckPath: /health + autoDeploy: true + envVars: + - key: SPRING_PROFILES_ACTIVE + value: prod + # Day boundaries ("today") are computed in this time zone. + - key: APP_TIMEZONE + value: Europe/Berlin + # Neon connection, JDBC format: jdbc:postgresql:///?sslmode=require + - key: DB_URL + sync: false + - key: DB_USER + sync: false + - key: DB_PASSWORD + sync: false + # Allowed frontend origin(s), comma separated. Example: https://worklog.vercel.app + - key: CORS_ORIGINS + sync: false