Add hot-reload dev environment via docker-compose.dev.yml
- web/Dockerfile: add `development` stage that installs deps and runs
`vite dev --host 0.0.0.0`; source is mounted at runtime so edits
reflect immediately without rebuilding the image
- web/vite.config.ts: read proxy target from API_URL env var
(falls back to localhost:8000 for outside-compose usage)
- docker-compose.dev.yml: lightweight compose for development
- api uses existing `development` target (uvicorn --reload)
- web uses new `development` target with ./web mounted as volume
and an anonymous volume to preserve container node_modules
- worker and nc-watcher omitted (not needed for UI work)
- separate pg_data_dev volume keeps dev DB isolated from prod
Usage:
podman-compose -f docker-compose.dev.yml up --build
Frontend hot-reloads at http://localhost:3000
API auto-reloads at http://localhost:8000
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,17 +1,68 @@
|
|||||||
services:
|
services:
|
||||||
|
db:
|
||||||
|
image: postgres:16-alpine
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: ${POSTGRES_DB:-rehearsalhub}
|
||||||
|
POSTGRES_USER: ${POSTGRES_USER:-rh_user}
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-default_secure_password}
|
||||||
|
volumes:
|
||||||
|
- pg_data_dev:/var/lib/postgresql/data
|
||||||
|
networks:
|
||||||
|
- rh_net
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-rh_user} -d ${POSTGRES_DB:-rehearsalhub} || exit 1"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 20
|
||||||
|
start_period: 20s
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:7-alpine
|
||||||
|
networks:
|
||||||
|
- rh_net
|
||||||
|
|
||||||
api:
|
api:
|
||||||
build:
|
build:
|
||||||
context: ./api
|
context: ./api
|
||||||
target: development
|
target: development
|
||||||
volumes:
|
volumes:
|
||||||
- ./api/src:/app/src
|
- ./api/src:/app/src
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-rh_user}:${POSTGRES_PASSWORD:-default_secure_password}@db:5432/${POSTGRES_DB:-rehearsalhub}
|
||||||
|
NEXTCLOUD_URL: ${NEXTCLOUD_URL:-https://cloud.example.com}
|
||||||
|
NEXTCLOUD_USER: ${NEXTCLOUD_USER:-rh_service}
|
||||||
|
NEXTCLOUD_PASS: ${NEXTCLOUD_PASS:-default_password}
|
||||||
|
REDIS_URL: redis://redis:6379/0
|
||||||
|
SECRET_KEY: ${SECRET_KEY:-replace_me_with_32_byte_hex_default}
|
||||||
|
INTERNAL_SECRET: ${INTERNAL_SECRET:-replace_me_with_32_byte_hex_default}
|
||||||
|
DOMAIN: ${DOMAIN:-localhost}
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
|
networks:
|
||||||
|
- rh_net
|
||||||
|
depends_on:
|
||||||
|
db:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
audio-worker:
|
web:
|
||||||
|
build:
|
||||||
|
context: ./web
|
||||||
|
target: development
|
||||||
volumes:
|
volumes:
|
||||||
- ./worker/src:/app/src
|
- ./web:/app
|
||||||
|
- /app/node_modules
|
||||||
|
environment:
|
||||||
|
API_URL: http://api:8000
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
networks:
|
||||||
|
- rh_net
|
||||||
|
depends_on:
|
||||||
|
- api
|
||||||
|
|
||||||
|
networks:
|
||||||
|
rh_net:
|
||||||
|
driver: bridge
|
||||||
|
|
||||||
nc-watcher:
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./watcher/src:/app/src
|
pg_data_dev:
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
FROM node:20-alpine AS development
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install --legacy-peer-deps
|
||||||
|
# Source is mounted as a volume at runtime — node_modules stays in the image
|
||||||
|
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
|
||||||
|
|
||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
import react from "@vitejs/plugin-react";
|
import react from "@vitejs/plugin-react";
|
||||||
|
|
||||||
|
const apiBase = process.env.API_URL ?? "http://localhost:8000";
|
||||||
|
const wsBase = apiBase.replace(/^http/, "ws");
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
server: {
|
server: {
|
||||||
port: 3000,
|
port: 3000,
|
||||||
proxy: {
|
proxy: {
|
||||||
"/api": { target: "http://localhost:8000", changeOrigin: true },
|
"/api": { target: apiBase, changeOrigin: true },
|
||||||
"/ws": { target: "ws://localhost:8000", ws: true },
|
"/ws": { target: wsBase, ws: true },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
test: {
|
test: {
|
||||||
|
|||||||
Reference in New Issue
Block a user