1- # Build stage
2- FROM node:18-slim AS build
1+ FROM node:18-slim AS base
32WORKDIR /app
4- RUN apt-get update && apt-get install -y --no-install-recommends \
5- g++ make python3 wget gnupg dirmngr unzip \
6- && rm -rf /var/lib/apt/lists/*
7-
8- RUN npm --no-update-notifier --no-fund --global install pnpm
9-
10- COPY . .
11- RUN pnpm install && pnpm build
3+ RUN apt update && apt install -y \
4+ g++ make python3 wget gnupg dirmngr unzip
125
136# Server stage
14- FROM node:18-slim AS server
15- WORKDIR /app
7+ FROM base AS server
168COPY ./server/ .
179RUN yarn config set registry https://registry.npmjs.org/ && \
1810 yarn config set network-timeout 1200000 && \
1911 yarn install --frozen-lockfile && \
2012 yarn build
2113
14+ # Build stage
15+ FROM base AS build
16+ RUN npm --no-update-notifier --no-fund --global install pnpm
17+ COPY . .
18+ RUN pnpm install && pnpm build
19+
2220# Final stage
2321FROM node:18-slim
2422WORKDIR /app
2523
24+ # Set environment variables
2625ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
2726ENV NODE_ENV=production
28-
29- RUN apt-get update && apt-get install -y --no-install-recommends \
30- wget gnupg dirmngr curl ca-certificates git git-lfs openssh-client \
31- jq cmake sqlite3 openssl psmisc python3 g++ make \
32- && rm -rf /var/lib/apt/lists/*
33-
34- # Install Chrome based on architecture
35- RUN ARCH=$(dpkg --print-architecture) && \
27+ # Install dependencies
28+ RUN apt update && apt install -y wget gnupg dirmngr unzip
29+ # Install dependencies and google chrome based on architecture
30+ RUN apt update && apt install -y wget gnupg dirmngr curl && \
31+ ARCH=$(dpkg --print-architecture) && \
3632 if [ "$ARCH" = "amd64" ]; then \
37- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
38- echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list && \
39- apt-get update && apt-get install -y google-chrome-stable --no-install-recommends; \
33+ wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
34+ sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
35+ apt-get update && \
36+ apt-get install google-chrome-stable -y --no-install-recommends; \
4037 elif [ "$ARCH" = "arm64" ]; then \
4138 wget -q -O chromium-linux-arm64.zip 'https://playwright.azureedge.net/builds/chromium/1088/chromium-linux-arm64.zip' && \
4239 unzip chromium-linux-arm64.zip && \
@@ -46,9 +43,15 @@ RUN ARCH=$(dpkg --print-architecture) && \
4643 else \
4744 echo "Unsupported architecture: $ARCH" && exit 1; \
4845 fi && \
49- rm -rf /var/lib/apt/lists/*
46+ rm -rf /var/lib/apt/lists/* \
47+ && apt-get clean && rm -rf /var/lib/{apt,dpkg,cache,log}/
48+
49+ # Install other dependencies
50+ RUN apt update && apt install -y --no-install-recommends \
51+ ca-certificates git git-lfs openssh-client curl jq cmake sqlite3 openssl psmisc python3 g++ make && \
52+ apt-get clean autoclean && apt-get autoremove --yes && rm -rf /var/lib/{apt,dpkg,cache,log}/
5053
51- # Copy build artifacts
54+ # Copying build artifacts
5255COPY --from=server /app/dist/ .
5356COPY --from=server /app/prisma/ ./prisma
5457COPY --from=server /app/package.json .
@@ -62,4 +65,5 @@ RUN yarn config set registry https://registry.npmjs.org/ && \
6265 yarn config set network-timeout 1200000 && \
6366 yarn install --production --frozen-lockfile
6467
68+ # Start the application
6569CMD ["yarn" , "start" ]
0 commit comments