Update server configuration and Docker setup for improved deployment
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
47
web/client/nginx.conf
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user