Docker builds, Nginx config, docker-compose, environment management, MongoDB Atlas, and deployment for PIXLAYER
# client/Dockerfile
FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
# server/Dockerfile
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 5000
CMD ["node", "index.js"]
# client/nginx.conf
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# SPA routing — fallback all routes to index.html
location / {
try_files $uri $uri/ /index.html;
}
# API proxy (if running behind single domain)
location /api/ {
proxy_pass http://server:5000;
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;
}
# WASM and model files — cache aggressively
location ~* \.(wasm|onnx)$ {
expires 30d;
add_header Cache-Control "public, immutable";
}
# Static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2)$ {
expires 7d;
add_header Cache-Control "public";
}
# HTTPS redirect (production only)
# Uncomment when SSL is configured:
# if ($scheme != "https") {
# return 301 https://$host$request_uri;
# }
}
# docker-compose.yml (project root)