From ed9bc848745d7057beb8094f61b39fc0b5f20a04 Mon Sep 17 00:00:00 2001 From: MarcWieland Date: Mon, 27 Jul 2026 00:02:22 +0200 Subject: [PATCH] Added Dockerization --- .dockerignore | 6 ++++++ Dockerfile | 25 +++++++++++++++++++++++++ docker-compose.yml | 15 +++++++++++++++ nginx.conf | 22 ++++++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d07217e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +node_modules +dist +.git +.gitignore +README.md +*.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5ca07a6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# Stage 1: Build React App with Node +FROM node:20-alpine AS build + +WORKDIR /app + +# Install dependencies +COPY package.json package-lock.json* ./ +RUN npm install + +# Copy source code and build +COPY . . +RUN npm run build + +# Stage 2: Serve with Nginx +FROM nginx:alpine + +# Copy custom Nginx configuration +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Copy build artifacts to Nginx html directory +COPY --from=build /app/dist /usr/share/nginx/html + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..15b5d9c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +version: '3.8' + +services: + handwerksfreund-web: + build: + context: . + dockerfile: Dockerfile + image: handwerksfreund-web:latest + container_name: handwerksfreund-web + restart: always + ports: + - "${WEB_PORT:-8085}:80" + environment: + - VITE_SUPABASE_URL=https://supabase.marc-wieland.de + - VITE_SUPABASE_ANON_KEY=sb_publishable__i6IYRo2bficTh7WsIMgqB_q6fjZpST diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..488675e --- /dev/null +++ b/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + # Cache static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { + root /usr/share/nginx/html; + expires 30d; + add_header Cache-Control "public, no-transform"; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +}