Created
May 20, 2025 23:16
-
-
Save geekygeeky/1deb81461cd97b6b3a76701a6082291c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Stage 1: Build Stage (Compile TypeScript to JavaScript) | |
| FROM node:18 AS builder | |
| WORKDIR /app | |
| # Copy package files and install ALL dependencies (including devDependencies for TS compilation) | |
| COPY package*.json ./ | |
| # Use npm ci for deterministic installs if you have package-lock.json | |
| RUN npm ci | |
| # Or: RUN yarn install --frozen-lockfile | |
| # Copy the rest of your application source code | |
| COPY . . | |
| # COPY ./prisma prisma | |
| # Compile TypeScript to JavaScript (adjust command if your build script is different) | |
| RUN npm run build | |
| RUN npx prisma generate | |
| # Or: RUN yarn build | |
| # Or: RUN npx tsc | |
| # Prune development dependencies after building | |
| RUN npm prune --production | |
| # Or: RUN yarn install --production --ignore-scripts --prefer-offlines | |
| # Stage 2: Production Stage (Run the compiled JavaScript) | |
| FROM node:18-alpine AS runner | |
| WORKDIR /app | |
| # Copy essential files from the builder stage | |
| COPY --from=builder /app/package*.json ./ | |
| COPY --from=builder /app/node_modules ./node_modules | |
| COPY --from=builder /app/dist ./dist | |
| # COPY --from=builder /app/generated ./generated | |
| EXPOSE 3000 | |
| CMD ["node", "dist/app.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment