-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (31 loc) · 968 Bytes
/
Copy pathDockerfile
File metadata and controls
44 lines (31 loc) · 968 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
36
37
38
39
40
41
42
43
44
# Stage 1: Build the frontend
FROM node:18 AS frontend-build
WORKDIR /app
COPY apps/client/package*.json ./apps/client/
RUN cd apps/client && npm install
COPY apps/client/ ./apps/client/
RUN cd apps/client && npm run build
# Stage 2: Build the backend
FROM node:18 AS backend-build
WORKDIR /app
COPY apps/api/package*.json ./apps/api/
RUN cd apps/api && npm install
COPY apps/api/ ./apps/api/
RUN cd apps/api && npm run build
# Stage 3: Combine frontend and backend
FROM node:18
WORKDIR /app
# Copy frontend build into the backend build directory
COPY --from=frontend-build /app/apps/client/dist /app/client/dist
# Copy backend build
COPY --from=backend-build /app/apps/api/dist /app/api/dist
# Set environment variables if needed
ENV NODE_ENV=production
# Install production dependencies
WORKDIR /app/api
COPY apps/api/package*.json ./
RUN npm install --only=production
# Expose ports
EXPOSE 3000
# Start the backend service
CMD ["node", "dist/main.js"]