From 4b730b10760830848d77c453ac1c0545d43ce34f Mon Sep 17 00:00:00 2001 From: "Christoph K." Date: Sun, 5 Apr 2026 20:29:17 +0200 Subject: [PATCH] Add root docker-compose and webapp Dockerfile/nginx for full-stack deployment Co-Authored-By: Claude Sonnet 4.6 --- docker-compose.yml | 47 ++++++++++++++++++++++++++++++++++++++++++++++ webapp/Dockerfile | 11 +++++++++++ webapp/nginx.conf | 28 +++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 docker-compose.yml create mode 100644 webapp/Dockerfile create mode 100644 webapp/nginx.conf diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2123158 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,47 @@ +services: + postgres: + image: postgres:16-alpine + environment: + POSTGRES_USER: ralph + POSTGRES_PASSWORD: ralph + POSTGRES_DB: ralph + volumes: + - pgdata:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U ralph"] + interval: 5s + timeout: 5s + retries: 5 + + migrate: + build: ./backend + command: ["/migrate"] + environment: + DATABASE_URL: postgres://ralph:ralph@postgres:5432/ralph?sslmode=disable + depends_on: + postgres: + condition: service_healthy + restart: on-failure + + api: + build: ./backend + ports: + - "8080:8080" + environment: + DATABASE_URL: postgres://ralph:ralph@postgres:5432/ralph?sslmode=disable + LISTEN_ADDR: :8080 + depends_on: + migrate: + condition: service_completed_successfully + restart: unless-stopped + + webapp: + build: ./webapp + ports: + - "9050:80" + depends_on: + - api + restart: unless-stopped + +volumes: + pgdata: diff --git a/webapp/Dockerfile b/webapp/Dockerfile new file mode 100644 index 0000000..7e83a2c --- /dev/null +++ b/webapp/Dockerfile @@ -0,0 +1,11 @@ +FROM node:22-alpine AS builder +WORKDIR /app +COPY package.json package-lock.json* ./ +RUN npm ci +COPY . . +RUN npm run build + +FROM nginx:alpine +COPY --from=builder /app/dist /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 diff --git a/webapp/nginx.conf b/webapp/nginx.conf new file mode 100644 index 0000000..a9d5af1 --- /dev/null +++ b/webapp/nginx.conf @@ -0,0 +1,28 @@ +server { + listen 80; + + # API und Auth-Endpunkte zum Backend proxieren + location /v1/ { + proxy_pass http://api:8080; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + location /login { + proxy_pass http://api:8080; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + location /logout { + proxy_pass http://api:8080; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + # SPA: alle anderen Routen auf index.html + location / { + root /usr/share/nginx/html; + try_files $uri $uri/ /index.html; + } +}