Skip to content

Commit a5d6017

Browse files
committed
fixed:prisma generate error
1 parent bb17c6c commit a5d6017

File tree

2 files changed

+838
-1806
lines changed

2 files changed

+838
-1806
lines changed

Dockerfile

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,52 @@
1-
# ========================================
2-
# Stage 1: Build Stage
3-
# ========================================
4-
# Use official Node.js LTS image (alpine for small size)
1+
#stage 1
52
FROM node:20-alpine AS builder
63

74
# Set working directory inside container
85
WORKDIR /app
9-
# Explanation: All commands will run inside /app. Keeps container filesystem organized.
106

11-
# Install pnpm globally for package management
127
RUN npm install -g pnpm
13-
# Explanation: pnpm is faster and deterministic for managing Node dependencies.
148

15-
# Copy package files first (for caching)
9+
# Copy package files
1610
COPY package.json pnpm-lock.yaml ./
17-
# Explanation: By copying only package files, Docker caches npm install layer.
18-
# If dependencies don't change, this layer is reused → faster builds.
19-
2011
# Install all dependencies including devDependencies
2112
ENV NODE_ENV=development
2213
RUN pnpm install --frozen-lockfile
23-
# Explanation: DevDependencies include TypeScript, Husky, etc., needed to build the app.
2414

25-
# Copy the rest of the source code
2615
COPY . .
27-
# Explanation: Copying after dependencies allows Docker to use cached layers for faster rebuilds.
2816

17+
# Generate Prisma client
18+
RUN npx prisma generate
2919
# Compile TypeScript into JavaScript
30-
3120
RUN pnpm run build
32-
# Explanation: `pnpm dlx tsc` ensures TypeScript compiler runs even if local bin links are missing.
3321

34-
# ========================================
35-
# Stage 2: Production Stage
36-
# ========================================
22+
# stage 2
3723
FROM node:20-alpine
3824

3925
# Set working directory
4026
WORKDIR /app
4127

4228
# Install pnpm in runtime container
4329
RUN npm install -g pnpm
44-
# Explanation: Needed to install production dependencies.
4530

4631
# Copy package files for production dependency install
4732
COPY package.json pnpm-lock.yaml ./
4833

4934
# Install only production dependencies
5035
ENV NODE_ENV=production
5136
RUN pnpm install --prod --frozen-lockfile
52-
# Explanation: Production image only needs runtime dependencies → smaller, faster, more secure.
5337

5438
# Disable Husky and other prepare scripts
5539
ENV HUSKY=0
5640
ENV SKIP_PREPARE=true
57-
# Explanation: Prevents hooks and scripts from running in production.
5841

5942
# Copy compiled JavaScript from builder stage
6043
COPY --from=builder /app/dist ./dist
61-
# Explanation: Only compiled JS is needed in production. DevDependencies are not copied → smaller image.
6244

63-
# Optional: non-root user for security
45+
# non-root user for security
46+
# Avoids running Node as root → improves security.
6447
RUN addgroup roshan && adduser -S -G roshan roshan
6548
USER roshan
66-
# Explanation: Avoids running Node as root → improves security.
67-
6849
# Expose port your API runs on
6950
EXPOSE 3000
70-
# Explanation: Tells Docker which port the container listens on.
71-
7251
# Start the application
7352
CMD ["node", "dist/server.js"]
74-
# Explanation: Runs compiled JavaScript for production.

0 commit comments

Comments
 (0)