diff --git a/README.md b/README.md index e4231a7..b30165f 100644 --- a/README.md +++ b/README.md @@ -159,16 +159,22 @@ npm run dev:frontend Open `http://localhost:5173`, register a local account, add a repository, and start analysis. -### Optional: local Compose stack +### Optional: local Compose stack (recommended for local dev) -Compose runs the API with PostgreSQL and Redis for local development. It is not production deployment guidance. +Compose runs the full stack — API, PostgreSQL, Redis, and the frontend dev +server — in one command. It is not production deployment guidance. ```bash -npm run docker:config -npm run docker:up +npm run docker:config # validate the compose file +npm run docker:up # build and start api + postgres + redis + frontend ``` -Run the frontend separately with `npm run dev:frontend`. See the [AI provider egress policy](docs/security/AI_PROVIDER_EGRESS.md) before configuring any custom or local provider endpoint. +The frontend dev server is available at `http://localhost:5173` and talks to +the API container over the internal network. Source is mounted, so edits hot +reload. See the [AI provider egress policy](docs/security/AI_PROVIDER_EGRESS.md) +before configuring any custom or local provider endpoint. + +To run the frontend outside Compose instead, use `npm run dev:frontend`. ## Verification diff --git a/apps/frontend/Dockerfile b/apps/frontend/Dockerfile new file mode 100644 index 0000000..d7a4b36 --- /dev/null +++ b/apps/frontend/Dockerfile @@ -0,0 +1,19 @@ +# Development image for the PARTHA frontend. +# Runs the Vite dev server so `docker compose up` brings up the whole stack +# (api + postgres + redis + frontend) in one command. Hot reload works because +# the compose service mounts the source directory. +FROM node:20-alpine + +WORKDIR /app + +# Install dependencies first for better layer caching. +COPY package.json package-lock.json ./ +RUN npm install + +# Vite must bind to 0.0.0.0 inside the container so the published port is +# reachable from the host. The frontend reaches the backend by its compose +# service name (http://api:8000), not localhost. +ENV VITE_API_URL=http://api:8000 +EXPOSE 5173 + +CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0", "--port", "5173"] diff --git a/docker-compose.yml b/docker-compose.yml index 88f9cbd..64cf6fa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -50,6 +50,25 @@ services: - data - egress + frontend: + build: + context: ./apps/frontend + dockerfile: Dockerfile + ports: + - "5173:5173" + environment: + # Reach the backend by its compose service name, not localhost. + VITE_API_URL: http://api:8000 + # Mount source for hot reload; keep the container's node_modules. + volumes: + - ./apps/frontend:/app + - /app/node_modules + depends_on: + api: + condition: service_started + networks: + - data + postgres: image: postgres:16-alpine environment: