This commit is contained in:
2026-05-25 09:54:41 +07:00
parent a033562c4c
commit 14d3a3152a
12 changed files with 212 additions and 3 deletions

11
web-client/.dockerignore Normal file
View File

@@ -0,0 +1,11 @@
node_modules
dist
.env
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
.DS_Store
Dockerfile
.dockerignore

View File

@@ -1,4 +1,10 @@
# Leave empty in local dev to use Vite proxy: /api -> PACKAGE_PROXY_TARGET.
WEB_CLIENT_IMAGE_REPOSITORY=toiiiiday/robot-installer-web-client
WEB_CLIENT_CONTAINER_NAME=robot-installer-web-client
WEB_CLIENT_PORT=8080
IMAGE_TAG=1.0.1
DOCKER_NETWORK=robot-installer-net
PACKAGE_PROXY_TARGET=http://robot-installer-web-server:3000
VITE_PACKAGE_BASE_URL=
VITE_AGENT_BASE_URL=http://127.0.0.1:5010
PACKAGE_PROXY_TARGET=http://localhost:3000

27
web-client/Dockerfile Normal file
View File

@@ -0,0 +1,27 @@
FROM node:22-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
ARG VITE_PACKAGE_BASE_URL=
ARG VITE_AGENT_BASE_URL=http://127.0.0.1:5010
RUN VITE_PACKAGE_BASE_URL="${VITE_PACKAGE_BASE_URL}" \
VITE_AGENT_BASE_URL="${VITE_AGENT_BASE_URL}" \
npm run build
FROM nginx:1.27-alpine AS runtime
ENV PACKAGE_PROXY_TARGET=http://web-server:3000
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf.template /etc/nginx/templates/default.conf.template
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -qO- http://127.0.0.1/ >/dev/null || exit 1

View File

@@ -0,0 +1,21 @@
services:
web-client:
image: ${WEB_CLIENT_IMAGE_REPOSITORY:-robot-installer-web-client}:${IMAGE_TAG:-local}
build:
context: .
args:
VITE_PACKAGE_BASE_URL: ${VITE_PACKAGE_BASE_URL:-}
VITE_AGENT_BASE_URL: ${VITE_AGENT_BASE_URL:-http://127.0.0.1:5010}
container_name: ${WEB_CLIENT_CONTAINER_NAME:-robot-installer-web-client}
environment:
PACKAGE_PROXY_TARGET: ${PACKAGE_PROXY_TARGET:-http://robot-installer-web-server:3000}
ports:
- "${WEB_CLIENT_PORT:-8080}:80"
networks:
- robot-installer
restart: unless-stopped
networks:
robot-installer:
name: ${DOCKER_NETWORK:-robot-installer-net}
external: true

View File

@@ -0,0 +1,58 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
client_max_body_size 1024m;
location = /api {
proxy_pass ${PACKAGE_PROXY_TARGET};
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ^~ /api/ {
proxy_pass ${PACKAGE_PROXY_TARGET};
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location = /install-agent.sh {
proxy_pass ${PACKAGE_PROXY_TARGET};
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ^~ /uploads/ {
proxy_pass ${PACKAGE_PROXY_TARGET};
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ^~ /packages/ {
proxy_pass ${PACKAGE_PROXY_TARGET};
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
try_files $uri $uri/ /index.html;
}
}