-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
35 lines (31 loc) · 965 Bytes
/
Copy pathDockerfile
File metadata and controls
35 lines (31 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Stage 1: Build frontend
FROM node:20-alpine AS frontend
ARG VITE_API_URL=/api
ENV VITE_API_URL=$VITE_API_URL
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
# Stage 2: Build backend
FROM node:20-alpine AS backend
WORKDIR /app/backend
COPY backend/package*.json ./
RUN npm ci
COPY backend/ ./
RUN npm run build
# Stage 3: Production with nginx
FROM nginx:alpine
# Copy frontend build
COPY --from=frontend /app/frontend/dist /usr/share/nginx/html
# Copy nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy backend (we'll run it with node directly)
COPY --from=backend /app/backend/dist /app/backend
WORKDIR /app/backend
# Install production dependencies for running the backend
COPY --from=backend /app/backend/node_modules ./node_modules
COPY --from=backend /app/backend/package*.json ./
# Start both nginx and node in foreground
CMD sh -c "node src/main.js & nginx -g 'daemon off;'"
EXPOSE 80