File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Stage 1: Build
2+ FROM node:22-alpine as build
3+
4+ WORKDIR /app
5+
6+ # Copy root package files for workspace support
7+ COPY package.json package-lock.json ./
8+
9+ # Copy the common package and app package.jsons first for layer caching
10+ COPY packages/common/package.json ./packages/common/
11+ COPY apps/web-dashboard/package.json ./apps/web-dashboard/
12+
13+ # Install dependencies
14+ RUN npm ci
15+
16+ # Copy the actual source code
17+ COPY packages/common ./packages/common
18+ COPY apps/web-dashboard ./apps/web-dashboard
19+
20+ # Set working directory to the dashboard app
21+ WORKDIR /app/apps/web-dashboard
22+
23+ # Build the app
24+ # Note: VITE_ variables must be available at build time for Vite
25+ ARG VITE_API_URL=http://localhost:1234
26+ ENV VITE_API_URL=$VITE_API_URL
27+
28+ RUN npm run build
29+
30+ # Stage 2: Serve with Nginx
31+ FROM nginx:alpine
32+
33+ # Copy the built assets from the build stage
34+ COPY --from=build /app/apps/web-dashboard/dist /usr/share/nginx/html
35+
36+ # Add a basic Nginx config to handle SPA routing (redirect all to index.html)
37+ RUN echo 'server { \
38+ listen 80; \
39+ location / { \
40+ root /usr/share/nginx/html; \
41+ index index.html index.htm; \
42+ try_files $uri $uri/ /index.html; \
43+ } \
44+ }' > /etc/nginx/conf.d/default.conf
45+
46+ EXPOSE 80
47+
48+ CMD ["nginx" , "-g" , "daemon off;" ]
Original file line number Diff line number Diff line change @@ -59,6 +59,20 @@ services:
5959 NODE_ENV : production
6060 USER_PORT : 1235
6161
62+ # ── Web Dashboard (Frontend) ──────────────────────────────────────────────────
63+ web-dashboard :
64+ build :
65+ context : .
66+ dockerfile : ./apps/web-dashboard/Dockerfile
67+ args :
68+ - VITE_API_URL=http://localhost:1234
69+ container_name : urbackend_frontend
70+ restart : unless-stopped
71+ ports :
72+ - ' 5173:80'
73+ depends_on :
74+ - dashboard-api
75+
6276volumes :
6377 mongo_data :
6478 redis_data :
You can’t perform that action at this time.
0 commit comments