Skip to content

Commit 5a1f0f6

Browse files
committed
📝 Update Docker configuration for development environment
1 parent f178e58 commit 5a1f0f6

File tree

3 files changed

+44
-15
lines changed

3 files changed

+44
-15
lines changed

docker-compose.override.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
services:
2-
32
# Local services are available on their ports, but also available on:
43
# http://api.localhost.tiangolo.com: backend
54
# http://dashboard.localhost.tiangolo.com: frontend
@@ -94,13 +93,30 @@ services:
9493

9594
frontend:
9695
restart: "no"
96+
# For development -> "5173:5173"
97+
# For production -> "5173:80"
9798
ports:
98-
- "5173:80"
99+
- "5173:5173"
99100
build:
100101
context: ./frontend
102+
# development: use the local Vite server (npm run dev)
103+
# production-nginx: use the Nginx server (npm run build)
104+
target: development
101105
args:
102106
- VITE_API_URL=http://localhost:8000
103107
- NODE_ENV=development
108+
command: npm run dev
109+
develop:
110+
watch:
111+
- path: ./frontend
112+
action: sync
113+
target: /app
114+
ignore:
115+
- ./frontend/node_modules
116+
- node_modules
117+
# volumes:
118+
# - ./frontend:/app
119+
# - /app/node_modules
104120

105121
playwright:
106122
build:

frontend/Dockerfile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Stage 0, "build-stage", based on Node.js, to build and compile the frontend
1+
# Build-stage based on Node.js, to build and compile the frontend
22
FROM node:20 AS build-stage
33

44
WORKDIR /app
@@ -11,13 +11,18 @@ COPY ./ /app/
1111

1212
ARG VITE_API_URL=${VITE_API_URL}
1313

14-
RUN npm run build
14+
# Development Stage: Used for Live Reload (`npm run dev`)
15+
FROM build-stage AS development
16+
# Expose Vite's default port
17+
EXPOSE 5173
18+
CMD ["npm", "run", "dev"]
1519

20+
# Production Stage: Only Used in Production
21+
FROM build-stage AS production-build
22+
RUN npm run build
1623

17-
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
18-
FROM nginx:1
19-
20-
COPY --from=build-stage /app/dist/ /usr/share/nginx/html
21-
24+
# Stage based on Nginx, to have only the compiled app, ready for production with Nginx
25+
FROM nginx:1 as production
26+
COPY --from=production-build /app/dist/ /usr/share/nginx/html
2227
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
23-
COPY ./nginx-backend-not-found.conf /etc/nginx/extra-conf.d/backend-not-found.conf
28+
COPY ./nginx-backend-not-found.conf /etc/nginx/extra-conf.d/backend-not-found.conf

frontend/vite.config.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
import { TanStackRouterVite } from "@tanstack/router-vite-plugin"
2-
import react from "@vitejs/plugin-react-swc"
3-
import { defineConfig } from "vite"
1+
import { TanStackRouterVite } from "@tanstack/router-vite-plugin";
2+
import react from "@vitejs/plugin-react-swc";
3+
import { defineConfig } from "vite";
44

55
// https://vitejs.dev/config/
66
export default defineConfig({
7-
plugins: [react(), TanStackRouterVite()],
8-
})
7+
plugins: [react(), TanStackRouterVite()],
8+
server: {
9+
watch: {
10+
usePolling: true,
11+
},
12+
host: "0.0.0.0", // Allows access from the container
13+
port: 5173, // Matches the mapped port in Docker Compose
14+
strictPort: true,
15+
},
16+
});

0 commit comments

Comments
 (0)