Files
ts6-manager/Dockerfile.frontend
Clusterzx 0aa6ce68db Embeddable server status widgets with 6 themes (Dark, Light, transparent, Neon/Cyberpunk, Military, Minimal).
Supports iframe, SVG and PNG output
  for forums, signatures and external websites.

  - Public endpoints: /widget/:token (iframe), /api/widget/:token/image.svg,
    /api/widget/:token/image.png — no auth required, 45s cache, CORS *
  - Admin CRUD via /api/widgets with token generation/rotation
  - Widget management modal on Dashboard page with embed code tabs
    (iframe snippet, image URLs, BBCode) and live preview
  - Prisma Widget model, shared theme definitions in @ts6/common
  - Server-side SVG generation with @resvg/resvg-js PNG rendering
  - Nginx config: X-Frame-Options override for /widget/ path
2026-02-25 11:40:10 +01:00

61 lines
1.8 KiB
Docker

# syntax=docker/dockerfile:1.4
FROM node:20-slim AS base
RUN corepack enable && corepack prepare pnpm@9 --activate
WORKDIR /app
# Copy everything at once to avoid BuildKit ordering bug on Windows
FROM base AS build
COPY . .
RUN pnpm install --no-frozen-lockfile
RUN pnpm --filter @ts6/common run build
RUN pnpm --filter @ts6/frontend run build
# Production: serve with nginx
FROM nginx:alpine AS production
COPY --from=build /app/packages/frontend/dist /usr/share/nginx/html
# Nginx config for SPA routing + API proxy
RUN printf 'server {\n\
listen 80;\n\
server_name _;\n\
root /usr/share/nginx/html;\n\
index index.html;\n\
\n\
client_max_body_size 150m;\n\
\n\
location /api {\n\
proxy_pass http://backend:3001;\n\
proxy_http_version 1.1;\n\
proxy_set_header Upgrade $http_upgrade;\n\
proxy_set_header Connection "upgrade";\n\
proxy_set_header Host $host;\n\
proxy_set_header X-Real-IP $remote_addr;\n\
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n\
proxy_set_header X-Forwarded-Proto $scheme;\n\
}\n\
\n\
location /ws {\n\
proxy_pass http://backend:3001;\n\
proxy_http_version 1.1;\n\
proxy_set_header Upgrade $http_upgrade;\n\
proxy_set_header Connection "upgrade";\n\
proxy_set_header Host $host;\n\
}\n\
\n\
location /widget/ {\n\
add_header X-Frame-Options "";\n\
add_header Content-Security-Policy "frame-ancestors *";\n\
try_files $uri $uri/ /index.html;\n\
}\n\
\n\
location / {\n\
try_files $uri $uri/ /index.html;\n\
}\n\
\n\
gzip on;\n\
gzip_types text/plain text/css application/json application/javascript text/xml;\n\
}\n' > /etc/nginx/conf.d/default.conf
EXPOSE 80