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 connection service
25+ RUN pnpm run build ecosystem
26+
27+ # Stage 2: Create the final image
28+ FROM node:18-alpine
29+ # Install OpenSSL
30+ RUN apk add --no-cache openssl
31+ # RUN npm install -g pnpm
32+ # Set the working directory
33+ WORKDIR /app
34+
35+ # Copy the compiled code from the build stage
36+ COPY --from=build /app/dist/apps/ecosystem/ ./dist/apps/ecosystem/
37+
38+ # Copy the libs folder from the build stage
39+ COPY --from=build /app/libs/ ./libs/
40+ #COPY --from=build /app/package.json ./
41+ COPY --from=build /app/node_modules ./node_modules
42+
43+ # Set the command to run the microservice
44+ CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && cd ../.. && node dist/apps/ecosystem/main.js"]
0 commit comments