Skip to content

Commit ed850a1

Browse files
committed
feat: added docker for web as well
1 parent 65a4674 commit ed850a1

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

apps/web-dashboard/Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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;"]

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
6276
volumes:
6377
mongo_data:
6478
redis_data:

0 commit comments

Comments
 (0)