Add Dockerfile, frontend image, and local compose stack

This commit is contained in:
megaproxy 2026-07-16 23:29:01 +01:00
parent ac72db9925
commit 3e2fbebac7
7 changed files with 199 additions and 1 deletions

6
frontend/.dockerignore Normal file
View file

@ -0,0 +1,6 @@
node_modules
dist
.git
*.md
Dockerfile
.dockerignore

22
frontend/Dockerfile Normal file
View file

@ -0,0 +1,22 @@
# Shattered Void MMO - frontend (Vite/React build served by nginx)
FROM node:20-bookworm-slim AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
# Vite inlines env vars at build time, so the API URL must be known here, not at runtime.
ARG VITE_API_URL=http://localhost:3000
ARG VITE_WS_URL=http://localhost:3000
ENV VITE_API_URL=$VITE_API_URL
ENV VITE_WS_URL=$VITE_WS_URL
RUN npm run build
FROM nginx:1.27-alpine AS runtime
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80

20
frontend/nginx.conf Normal file
View file

@ -0,0 +1,20 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# React Router owns the routing; every unknown path must fall through to the SPA.
location / {
try_files $uri $uri/ /index.html;
}
location /healthz {
access_log off;
return 200 "ok\n";
}
gzip on;
gzip_types text/css application/javascript application/json image/svg+xml;
gzip_min_length 1024;
}