-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbackend.Dockerfile
More file actions
43 lines (32 loc) · 1.03 KB
/
Copy pathbackend.Dockerfile
File metadata and controls
43 lines (32 loc) · 1.03 KB
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
# Backend Dockerfile
FROM node:18-alpine AS builder
WORKDIR /app
# Copy package.json files and lockfile
COPY package.json ./
COPY package-lock.json ./
COPY apps/backend/package.json ./apps/backend/
COPY libs/common-types/package.json ./libs/common-types/
COPY libs/utils/package.json ./libs/utils/
# Install dependencies
RUN npm ci
# Copy source code
COPY apps/backend ./apps/backend
COPY libs ./libs
COPY tsconfig.json ./
# Build the libraries first
RUN npm run build --workspace=libs/common-types
RUN npm run build --workspace=libs/utils
# Build the application
RUN npm run build --workspace=apps/backend
RUN ls -la apps/backend/dist/ # Debug: check if build succeeded
# Production stage
FROM node:18-alpine AS production
WORKDIR /app
# Copy built application and dependencies
COPY --from=builder /app/apps/backend/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
COPY --from=builder /app/libs ./libs
EXPOSE 3001
# Run the application
CMD ["node", "dist/apps/backend/src/server.js"]