From 4caf19fcc01a1471f2965decb0f1ae29f167bba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E9=A3=8E?= Date: Wed, 25 Mar 2026 09:42:57 +0800 Subject: [PATCH] fix: use docker compose watch under dev --- .env | 7 +++++++ compose.override.yml | 22 ++++++++++++++++++++++ frontend/Dockerfile | 19 +++++++++++++++---- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/.env b/.env index e00d1dd..3b1e7dd 100644 --- a/.env +++ b/.env @@ -43,3 +43,10 @@ SENTRY_DSN= # Configure these with your own Docker registry images DOCKER_IMAGE_BACKEND=backend DOCKER_IMAGE_FRONTEND=frontend + +# MQTT Config +MQTT_HOST=101.35.119.226 +MQTT_PORT=1883 +MQTT_USERNAME=weefnn +MQTT_PASSWORD=123456 +MQTT_CLIENT_ID=spatialhub-local-dev-weifeng diff --git a/compose.override.yml b/compose.override.yml index 2fc7718..37a52fb 100644 --- a/compose.override.yml +++ b/compose.override.yml @@ -114,9 +114,31 @@ services: build: context: . dockerfile: frontend/Dockerfile + target: dev-stage args: - VITE_API_URL=http://localhost:8000 - NODE_ENV=development + environment: + - VITE_API_URL=http://localhost:8000 + - CHOKIDAR_USEPOLLING=true + - CHOKIDAR_INTERVAL=150 + develop: + watch: + - path: ./frontend + action: sync + target: /app/frontend + ignore: + - node_modules/ + - dist/ + - blob-report/ + - test-results/ + - package.json + - path: ./frontend/package.json + action: rebuild + - path: ./package.json + action: rebuild + - path: ./bun.lock + action: rebuild playwright: build: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index e9bae40..903ffe7 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,10 +1,9 @@ -# Stage 0, "build-stage", based on Bun, to build and compile the frontend -FROM oven/bun:1 AS build-stage +# Shared Bun stage for frontend dependencies and sources +FROM oven/bun:1 AS bun-base WORKDIR /app COPY package.json bun.lock /app/ - COPY frontend/package.json /app/frontend/ WORKDIR /app/frontend @@ -14,10 +13,22 @@ RUN bun install COPY ./frontend /app/frontend ARG VITE_API_URL + +# Development stage for docker compose watch + Vite HMR +FROM bun-base AS dev-stage + +EXPOSE 80 + +CMD ["bun", "run", "dev", "--host", "0.0.0.0", "--port", "80"] + + +# Build stage for production assets +FROM bun-base AS build-stage + RUN bun run build -# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx +# Production stage serving compiled assets with Nginx FROM nginx:1 COPY --from=build-stage /app/frontend/dist/ /usr/share/nginx/html