1
- FROM node:20-alpine AS api_base
2
- WORKDIR /prisma
3
- RUN yarn add prisma
4
-
1
+ FROM node:20-alpine AS base
5
2
WORKDIR /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
9
3
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
12
9
10
+ COPY prisma ./prisma
11
+ RUN yarn prisma generate
13
12
14
- FROM api_base AS builder
15
- RUN yarn install
16
- COPY ./ ./
13
+ COPY . .
17
14
RUN yarn build
18
15
RUN cp ./swagger.yaml ./dist
19
16
17
+ # ---------- Final lightweight image ----------
18
+ FROM node:20-alpine AS production
19
+ RUN apk add --no-cache openssl
20
20
21
-
22
- FROM node:20-alpine
23
- RUN apk add openssl
21
+ # Create a non-root user
24
22
USER node
25
-
26
23
WORKDIR /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 ./
30
24
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 ./
33
29
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
36
34
35
+ # Expose app port
36
+ EXPOSE 8080
37
37
38
+ # Start the app
39
+ CMD ["node" , "index.js" ]
0 commit comments