-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (52 loc) · 1.83 KB
/
Dockerfile
File metadata and controls
69 lines (52 loc) · 1.83 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Stage 1: Build the application
FROM node:24-alpine AS builder
WORKDIR /app
# Install pnpm globally
RUN npm install -g pnpm
# Copy package manifests and lockfile
COPY package.json pnpm-lock.yaml ./
# Install dependencies
RUN pnpm install --unsafe-perm \
&& echo '--- DEBUG: pnpm version ---' \
&& pnpm --version \
&& echo '--- DEBUG: node version ---' \
&& node --version \
&& echo '--- DEBUG: npx version ---' \
&& npx --version \
&& echo '--- DEBUG: prisma version (if installed) ---' \
&& npx prisma --version || true \
&& echo '--- DEBUG: node_modules/.bin contents ---' \
&& ls -l node_modules/.bin || true
# Copy prisma directory separately
COPY prisma ./prisma
# Copy the rest of your application code
COPY . .
# Debug before running prisma generate
RUN echo '--- DEBUG: Running npx prisma generate ---' \
&& npx prisma generate
# Build the application
RUN pnpm build
# Stage 2: Production Image
FROM node:24-alpine
WORKDIR /app
# Install pnpm in the final production image as well
RUN npm install -g pnpm
# Set environment variables for better console output
ENV FORCE_COLOR=1
ENV NODE_ENV=production
# Copy only the necessary production artifacts from the 'builder' stage
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/google-services.json ./google-services.json
COPY docker-entrypoint.sh .
# Ensure the entrypoint is executable
RUN chmod +x docker-entrypoint.sh
# Expose the NestJS port
EXPOSE 4000
# Run migrations then start
ENTRYPOINT ["./docker-entrypoint.sh"]
# The default command for the entrypoint script: run production build
CMD ["pnpm", "start:prod"]