Update server configuration and Docker setup for improved deployment

This commit is contained in:
MayaTheShy
2026-03-21 17:15:04 -04:00
parent cc64b568a0
commit 2853ca98a0
4 changed files with 58 additions and 9 deletions

View File

@@ -9,7 +9,7 @@
-------------------------------------------------
-- Web server URL (change to your Docker host IP/hostname)
local SERVER_URL = "http://localhost:4200"
local SERVER_URL = "http://localhost"
local POLL_INTERVAL = 0.5 -- seconds between command polls
local STATE_INTERVAL = 1 -- seconds between state forwards

View File

@@ -1,5 +1,5 @@
# Production build with simple HTTP server
FROM node:18-alpine
# Stage 1: Build the React app
FROM node:18-alpine AS build
WORKDIR /app
@@ -11,8 +11,12 @@ COPY . .
RUN npm run build
RUN npm install -g serve
# Stage 2: Serve with nginx
FROM nginx:alpine
EXPOSE 3000
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
CMD ["serve", "-s", "dist", "-l", "3000"]
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

47
web/client/nginx.conf Normal file
View File

@@ -0,0 +1,47 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Serve static files, fallback to index.html for SPA routing
location / {
try_files $uri $uri/ /index.html;
}
# Proxy API requests to backend server
location /api/ {
proxy_pass http://server:3001/api/;
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 WebSocket for browser clients
location /ws {
proxy_pass http://server:3001/ws;
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_read_timeout 86400s;
proxy_send_timeout 86400s;
}
# Proxy WebSocket for bridge clients
location /ws/bridge {
proxy_pass http://server:3001/ws/bridge;
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_read_timeout 86400s;
proxy_send_timeout 86400s;
}
}

View File

@@ -3,8 +3,6 @@ version: '3.8'
services:
server:
build: ./server
ports:
- "4200:3001"
networks:
- inventory-network
restart: unless-stopped
@@ -18,7 +16,7 @@ services:
client:
build: ./client
ports:
- "4444:3000"
- "80:80"
networks:
- inventory-network
depends_on: