From 7bb6807d37467799e587134f1c7df0cd546e37ee Mon Sep 17 00:00:00 2001 From: DanielS Date: Mon, 22 Jun 2026 22:30:55 +0200 Subject: [PATCH] Fix global error page, update CI workflow, add Dockerfile --- .gitea/workflows/staging.yaml | 22 +++++++++++++++++- Dockerfile | 42 +++++++++++++++++++++++++++++++++++ shop/app/_global-error.tsx | 27 ++++++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 shop/app/_global-error.tsx diff --git a/.gitea/workflows/staging.yaml b/.gitea/workflows/staging.yaml index 43d5ddb..7478057 100644 --- a/.gitea/workflows/staging.yaml +++ b/.gitea/workflows/staging.yaml @@ -19,5 +19,25 @@ jobs: - name: Staging-Build generieren env: - NODE_ENV: development + NODE_ENV: production run: npm run build + + - name: Docker login to Gitea registry + run: echo ${{ secrets.GITEA_TOKEN }} | docker login gitea.hephex.de -u ${{ secrets.GITEA_USER }} --password-stdin + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + - name: Build Docker image + run: docker build -t gitea.hephex.de/daniel/webshop:staging . + working-directory: .. + - name: Push Docker image + run: docker push gitea.hephex.de/daniel/webshop:staging + working-directory: .. + - name: Deploy to Proxmox LXC via SSH + uses: appleboy/ssh-action@v0.1.5 + with: + host: 192.168.1.51 + username: ${{ secrets.PROXMOX_USER }} + key: ${{ secrets.PROXMOX_SSH_KEY }} + script: | + cd /path/to/deployment + docker compose pull webshop && docker compose up -d webshop diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2b6299d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +# Use a multi‑stage build for a Next.js app + +# ---------- Builder stage ---------- +FROM node:20-alpine AS builder + +# Set working directory +WORKDIR /app + +# Install dependencies (use package lock when present) +COPY shop/package*.json ./ +RUN npm ci --omit=dev + +# Copy the source code +COPY shop/ . + +# Build the production output +RUN npm run build + +# ---------- Runtime stage ---------- +FROM node:20-alpine AS runner + +WORKDIR /app + +# Copy only the built assets and runtime dependencies from the builder +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/public ./public +COPY --from=builder /app/package*.json ./ +COPY --from=builder /app/next.config.mjs ./ +COPY --from=builder /app/next-env.d.ts ./ +COPY --from=builder /app/tsconfig.json ./ + +# Install production dependencies (already installed in builder, but ensure they are present) +RUN npm ci --omit=dev + +# Environment variables +ENV NODE_ENV=production +ENV PORT=3000 + +EXPOSE 3000 + +# Start the Next.js server +CMD ["npm", "run", "start"] diff --git a/shop/app/_global-error.tsx b/shop/app/_global-error.tsx new file mode 100644 index 0000000..8ba5089 --- /dev/null +++ b/shop/app/_global-error.tsx @@ -0,0 +1,27 @@ +'use client' + +import { useEffect } from 'react' + +export default function GlobalError({ error, reset }: { error: Error; reset: () => void }) { + // Ensure the page does not depend on any context or Supabase client. + useEffect(() => { + console.error('Global error caught:', error) + }, [error]) + + return ( +
+
+

Ein unerwarteter Fehler ist aufgetreten

+

+ Bitte versuchen Sie die Seite zu aktualisieren oder kontaktieren Sie den Support. +

+ +
+
+ ) +}