From b45a93a55984a88545b994419be4f4ce1fde8cab Mon Sep 17 00:00:00 2001 From: bonamin Date: Mon, 1 Jun 2026 01:00:56 +0300 Subject: [PATCH] =?UTF-8?q?feat(connect):=20Phase=207=20=E2=80=94=20Docker?= =?UTF-8?q?=20&=20nginx=20for=20connect=5Ffrontend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit connect_frontend/Dockerfile Multi-stage build: node:20-alpine builds both menu-app and manager-app in parallel stages, then nginx:alpine serves both dist folders under /menu and /manage respectively. VITE_CLOUD_URL passed as build arg so the API URL is baked in at build time (standard Vite pattern). connect_frontend/nginx-connect.conf Single nginx server block: /menu/ → /usr/share/nginx/html/menu (SPA fallback) /manage/ → /usr/share/nginx/html/manage (SPA fallback) /health → 200 ok nginx-connect.conf Kept at cloud-service root for reference / standalone use. docker-compose.yml connect_frontend service added: - build context: ./connect_frontend - VITE_CLOUD_URL passed from root .env - port 3100:80 - depends_on cloud_backend Individual Dockerfiles also added to menu-app/ and manager-app/ for standalone builds if needed. To deploy: docker compose build connect_frontend docker compose up -d connect_frontend Public menu: http://:3100/menu/ Manager app: http://:3100/manage/ Co-Authored-By: Claude Sonnet 4.6 --- connect_frontend/Dockerfile | 25 +++++++++++++++++++++++++ connect_frontend/manager-app/Dockerfile | 11 +++++++++++ connect_frontend/menu-app/Dockerfile | 11 +++++++++++ connect_frontend/nginx-connect.conf | 21 +++++++++++++++++++++ docker-compose.yml | 11 +++++++++++ nginx-connect.conf | 21 +++++++++++++++++++++ 6 files changed, 100 insertions(+) create mode 100644 connect_frontend/Dockerfile create mode 100644 connect_frontend/manager-app/Dockerfile create mode 100644 connect_frontend/menu-app/Dockerfile create mode 100644 connect_frontend/nginx-connect.conf create mode 100644 nginx-connect.conf diff --git a/connect_frontend/Dockerfile b/connect_frontend/Dockerfile new file mode 100644 index 0000000..7c4c3a7 --- /dev/null +++ b/connect_frontend/Dockerfile @@ -0,0 +1,25 @@ +# Build menu-app +FROM node:20-alpine AS menu-builder +WORKDIR /app/menu-app +COPY menu-app/package.json . +RUN npm install +COPY menu-app/ . +ARG VITE_CLOUD_URL= +ENV VITE_CLOUD_URL=$VITE_CLOUD_URL +RUN npm run build + +# Build manager-app +FROM node:20-alpine AS manager-builder +WORKDIR /app/manager-app +COPY manager-app/package.json . +RUN npm install +COPY manager-app/ . +ARG VITE_CLOUD_URL= +ENV VITE_CLOUD_URL=$VITE_CLOUD_URL +RUN npm run build + +# Serve both with nginx +FROM nginx:alpine +COPY --from=menu-builder /app/menu-app/dist /usr/share/nginx/html/menu +COPY --from=manager-builder /app/manager-app/dist /usr/share/nginx/html/manage +COPY nginx-connect.conf /etc/nginx/conf.d/default.conf diff --git a/connect_frontend/manager-app/Dockerfile b/connect_frontend/manager-app/Dockerfile new file mode 100644 index 0000000..82c5e1e --- /dev/null +++ b/connect_frontend/manager-app/Dockerfile @@ -0,0 +1,11 @@ +FROM node:20-alpine AS builder +WORKDIR /app +COPY package.json . +RUN npm install +COPY . . +ARG VITE_CLOUD_URL= +ENV VITE_CLOUD_URL=$VITE_CLOUD_URL +RUN npm run build + +FROM nginx:alpine +COPY --from=builder /app/dist /usr/share/nginx/html/manage diff --git a/connect_frontend/menu-app/Dockerfile b/connect_frontend/menu-app/Dockerfile new file mode 100644 index 0000000..084a16f --- /dev/null +++ b/connect_frontend/menu-app/Dockerfile @@ -0,0 +1,11 @@ +FROM node:20-alpine AS builder +WORKDIR /app +COPY package.json . +RUN npm install +COPY . . +ARG VITE_CLOUD_URL= +ENV VITE_CLOUD_URL=$VITE_CLOUD_URL +RUN npm run build + +FROM nginx:alpine +COPY --from=builder /app/dist /usr/share/nginx/html/menu diff --git a/connect_frontend/nginx-connect.conf b/connect_frontend/nginx-connect.conf new file mode 100644 index 0000000..b2cd6a9 --- /dev/null +++ b/connect_frontend/nginx-connect.conf @@ -0,0 +1,21 @@ +server { + listen 80; + + # Public menu SPA + location /menu/ { + alias /usr/share/nginx/html/menu/; + try_files $uri $uri/ /menu/index.html; + } + + # Remote manager SPA + location /manage/ { + alias /usr/share/nginx/html/manage/; + try_files $uri $uri/ /manage/index.html; + } + + # Health check + location /health { + return 200 'ok'; + add_header Content-Type text/plain; + } +} diff --git a/docker-compose.yml b/docker-compose.yml index 1c921fe..007b7f0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,5 +17,16 @@ services: ports: - "5175:80" restart: unless-stopped + depends_on: + - cloud_backend + + connect_frontend: + build: + context: ./connect_frontend + args: + VITE_CLOUD_URL: ${VITE_CLOUD_URL} + ports: + - "3100:80" + restart: unless-stopped depends_on: - cloud_backend \ No newline at end of file diff --git a/nginx-connect.conf b/nginx-connect.conf new file mode 100644 index 0000000..b2cd6a9 --- /dev/null +++ b/nginx-connect.conf @@ -0,0 +1,21 @@ +server { + listen 80; + + # Public menu SPA + location /menu/ { + alias /usr/share/nginx/html/menu/; + try_files $uri $uri/ /menu/index.html; + } + + # Remote manager SPA + location /manage/ { + alias /usr/share/nginx/html/manage/; + try_files $uri $uri/ /manage/index.html; + } + + # Health check + location /health { + return 200 'ok'; + add_header Content-Type text/plain; + } +}