1+ # Stage 1: Build the application
2+ FROM node:18-alpine as build
3+ # Install OpenSSL
4+ RUN apk add --no-cache openssl
5+ RUN npm install -g pnpm
6+ # Set the working directory
7+ WORKDIR /app
8+
9+ # Copy package.json and package-lock.json
10+ COPY package.json ./
11+ COPY pnpm-workspace.yaml ./
12+ #COPY package-lock.json ./
13+
14+ ENV PUPPETEER_SKIP_DOWNLOAD=true
15+
16+ # Install dependencies while ignoring scripts (including Puppeteer's installation)
17+ RUN pnpm i --ignore-scripts
18+
19+ # Copy the rest of the application code
20+ COPY . .
21+ # RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
22+ RUN cd libs/prisma-service && npx prisma generate
23+
24+ # Build the x509 service
25+ RUN npm run build x509
26+
27+
28+ # Stage 2: Create the final image
29+ FROM node:18-alpine
30+ # Install OpenSSL
31+ RUN apk add --no-cache openssl
32+ # RUN npm install -g pnpm
33+ # Set the working directory
34+ WORKDIR /app
35+
36+ # Copy the compiled code from the build stage
37+ COPY --from=build /app/dist/apps/x509/ ./dist/apps/x509/
38+
39+ # Copy the libs folder from the build stage
40+ COPY --from=build /app/libs/ ./libs/
41+ #COPY --from=build /app/package.json ./
42+ COPY --from=build /app/node_modules ./node_modules
43+
44+ # Set the command to run the microservice
45+ CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && cd ../.. && node dist/apps/x509/main.js"]
0 commit comments