1- FROM node:20-alpine AS api_base
2- WORKDIR /prisma
3- RUN yarn add prisma
4-
1+ FROM node:20-alpine AS base
52WORKDIR /app
6- COPY ./package.json ./yarn.lock ./
7- # Copy the rest of the application code to the container
8- RUN yarn install --frozen-lockfile --production
93
10- COPY ./prisma ./prisma
11- RUN /prisma/node_modules/.bin/prisma generate
4+ # Minimal dependencies to fix the Prisma OpenSSL warning
5+ RUN apk add --no-cache openssl openssl-dev
6+
7+ COPY package.json yarn.lock ./
8+ RUN yarn install --frozen-lockfile
129
10+ COPY prisma ./prisma
11+ RUN yarn prisma generate
1312
14- FROM api_base AS builder
15- RUN yarn install
16- COPY ./ ./
13+ COPY . .
1714RUN yarn build
1815RUN cp ./swagger.yaml ./dist
1916
17+ # ---------- Final lightweight image ----------
18+ FROM node:20-alpine AS production
19+ RUN apk add --no-cache openssl
2020
21-
22- FROM node:20-alpine
23- RUN apk add openssl
21+ # Create a non-root user
2422USER node
25-
2623WORKDIR /api
27- COPY --from=api_base --chown=node:node /app/node_modules node_modules
28- COPY --from=builder --chown=node:node /app/prisma prisma
29- COPY --from=builder --chown=node:node /app/dist ./
3024
31- # Expose the port the app runs on (if applicable)
32- EXPOSE 8080
25+ # Copy only what's needed for production runtime
26+ COPY --from=base --chown=node:node /app/node_modules ./node_modules
27+ COPY --from=base --chown=node:node /app/prisma ./prisma
28+ COPY --from=base --chown=node:node /app/dist ./
3329
34- # Command to run the application
35- CMD ["node" , "/api/index.js" ]
30+ # Set environment variables
31+ ENV NODE_ENV=production
32+ ENV ENABLE_TRACING=false
33+ ENV RUST_LOG=info
3634
35+ # Expose app port
36+ EXPOSE 8080
3737
38+ # Start the app
39+ CMD ["node" , "index.js" ]
0 commit comments