1
- # Build stage
2
- FROM node:18-slim AS build
1
+ FROM node:18-slim AS base
3
2
WORKDIR /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
12
5
13
6
# Server stage
14
- FROM node:18-slim AS server
15
- WORKDIR /app
7
+ FROM base AS server
16
8
COPY ./server/ .
17
9
RUN yarn config set registry https://registry.npmjs.org/ && \
18
10
yarn config set network-timeout 1200000 && \
19
11
yarn install --frozen-lockfile && \
20
12
yarn build
21
13
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
+
22
20
# Final stage
23
21
FROM node:18-slim
24
22
WORKDIR /app
25
23
24
+ # Set environment variables
26
25
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
27
26
ENV 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) && \
36
32
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; \
40
37
elif [ "$ARCH" = "arm64" ]; then \
41
38
wget -q -O chromium-linux-arm64.zip 'https://playwright.azureedge.net/builds/chromium/1088/chromium-linux-arm64.zip' && \
42
39
unzip chromium-linux-arm64.zip && \
@@ -46,9 +43,15 @@ RUN ARCH=$(dpkg --print-architecture) && \
46
43
else \
47
44
echo "Unsupported architecture: $ARCH" && exit 1; \
48
45
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}/
50
53
51
- # Copy build artifacts
54
+ # Copying build artifacts
52
55
COPY --from=server /app/dist/ .
53
56
COPY --from=server /app/prisma/ ./prisma
54
57
COPY --from=server /app/package.json .
@@ -62,4 +65,5 @@ RUN yarn config set registry https://registry.npmjs.org/ && \
62
65
yarn config set network-timeout 1200000 && \
63
66
yarn install --production --frozen-lockfile
64
67
68
+ # Start the application
65
69
CMD ["yarn" , "start" ]
0 commit comments