From 86f0fbb51cb3836f9469ea745ea2cfebe4530f62 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Mon, 5 Jan 2026 23:58:48 +0100 Subject: [PATCH] Add a basic dockerfile --- Dockerfile | 16 ++++++++++++++++ nginx.conf | 30 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3a248b8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM node:20-slim as builder +WORKDIR /app + +COPY package*.json ./ +RUN npm install + +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 8080 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..7b58bfb --- /dev/null +++ b/nginx.conf @@ -0,0 +1,30 @@ +server { + listen 8080; + server_name _; + root /usr/share/nginx/html; + index index.html; + + # Gzip compression + gzip on; + gzip_vary on; + gzip_min_length 1024; + gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json application/javascript; + + # Serve static files + location / { + try_files $uri $uri/ /index.html; + } + + # Proxy API requests to backend + location /api/ { + proxy_pass http://backend:3000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_cache_bypass $http_upgrade; + } +}