From ee7b6fd1fb939e5b38b37fa605c6bf8a4f7e24a8 Mon Sep 17 00:00:00 2001 From: Andreas Knuth Date: Wed, 30 Jul 2025 17:30:39 -0500 Subject: [PATCH] prod preparation --- app/docker-compose.prod.yml | 43 +++++++++++++++++++++++++++++++++++++ caddy/Caddyfile | 29 +++++++++++++++++++------ 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/app/docker-compose.prod.yml b/app/docker-compose.prod.yml index e69de29..6deb750 100644 --- a/app/docker-compose.prod.yml +++ b/app/docker-compose.prod.yml @@ -0,0 +1,43 @@ +services: + app: + image: node:22-alpine + container_name: bizmatch-app-prod # Neu: Unterscheide Namen + working_dir: /app + volumes: + - ~/git/bizmatch-project-prod/bizmatch-server:/app # Verwende Prod-Checkout + ports: + - "3001:3000" # Neu: Host-Port 3001, Container-Port bleibt 3000 + environment: + - NODE_ENV=development # Neu: Production-Modus (für Nest.js-Config) + - DB_HOST=postgres-prod # Neu: Passe an neuen Service-Namen + - DB_PORT=5432 + - DB_NAME=${POSTGRES_DB_PROD} # Neu: Separate DB-Name aus Env-File + - DB_USER=${POSTGRES_USER_PROD} + - DB_PASSWORD=${POSTGRES_PASSWORD_PROD} + env_file: + - ~/git/docker-prod/app/.env.prod # Neu: Separate Env-File für Prod + command: sh -c "npm install && npm run build && node dist/src/main.js" # Entferne --omit=dev für Prod + restart: unless-stopped + depends_on: + - postgres-prod + networks: + - bizmatch-prod # Neu: Separates Network für Isolation + + postgres-prod: # Neu: Umbenannt für Unterscheidung + container_name: bizmatchdb-prod + image: postgres:latest + restart: always + volumes: + - ${PWD}/bizmatchdb-data-prod:/var/lib/postgresql/data # Neu: Separates Daten-Volume + environment: + POSTGRES_DB: ${POSTGRES_DB_PROD} + POSTGRES_USER: ${POSTGRES_USER_PROD} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD_PROD} + ports: + - "5433:5432" # Neu: Host-Port 5433, Container-Port bleibt 5432 + networks: + - bizmatch-prod + +networks: + bizmatch-prod: + external: true # Neu: Erstelle es mit `docker network create bizmatch-prod` \ No newline at end of file diff --git a/caddy/Caddyfile b/caddy/Caddyfile index 81ef9ef..8677e02 100644 --- a/caddy/Caddyfile +++ b/caddy/Caddyfile @@ -4,11 +4,21 @@ acme_ca https://acme-v02.api.letsencrypt.org/directory debug } -bizmatch.net { - -} -www.bizmatch.net { - +# Prod: Neue Domains +bizmatch.net, www.bizmatch.net { + handle /pictures/* { + root * /home/aknuth/git/bizmatch-project-prod/bizmatch-server # Prod-Ordner + file_server + } + handle { + root * /srv/prod # Neuer Prod-Dist-Ordner + try_files {path} {path}/ /index.html + file_server + } + log { + output file /var/log/caddy/access.prod.log { ... } # Separate Logs + } + encode gzip } bayarea-cc.com { # TLS-Direktive entfernen, falls Cloudflare die Verbindung terminiert @@ -77,7 +87,14 @@ api-dev.bizmatch.net { header_up CF-IPCountry {http.request.header.CF-IPCountry} } } - +api.bizmatch.net { + reverse_proxy host.docker.internal:3001 { # Neu: Proxy auf Prod-Port 3001 + header_up X-Real-IP {http.request.header.CF-Connecting-IP} + header_up X-Forwarded-For {http.request.header.CF-Connecting-IP} + header_up X-Forwarded-Proto {http.request.header.X-Forwarded-Proto} + header_up CF-IPCountry {http.request.header.CF-IPCountry} + } +} mailsync.bizmatch.net { reverse_proxy host.docker.internal:5000 { header_up X-Real-IP {http.request.header.CF-Connecting-IP}