1
- FROM node:18-slim as server
2
-
1
+ FROM node:18-slim AS base
3
2
WORKDIR /app
3
+ RUN apt update && apt install -y \
4
+ g++ make python3 wget gnupg dirmngr unzip
4
5
5
- RUN apt update && apt -y install g++ make python3
6
- # RUN npm install -g node-gyp
7
-
6
+ # Server stage
7
+ FROM base AS server
8
8
COPY ./server/ .
9
+ RUN yarn config set registry https://registry.npmjs.org/ && \
10
+ yarn config set network-timeout 1200000 && \
11
+ yarn install --frozen-lockfile && \
12
+ yarn build
9
13
10
- RUN yarn config set registry https://registry.npmjs.org/
11
- RUN yarn config set network-timeout 1200000
12
- RUN yarn install --frozen-lockfile
13
-
14
- RUN yarn build
15
-
16
- FROM node:18-slim as build
17
- WORKDIR /app
18
-
19
- RUN apt update
14
+ # Build stage
15
+ FROM base AS build
20
16
RUN npm --no-update-notifier --no-fund --global install pnpm
21
-
22
17
COPY . .
23
- RUN pnpm install
24
-
25
- RUN pnpm build
18
+ RUN pnpm install && pnpm build
26
19
20
+ # Final stage
27
21
FROM node:18-slim
28
-
29
22
WORKDIR /app
30
23
24
+ # Set environment variables
31
25
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
32
-
33
- RUN apt-get update && apt-get install gnupg wget -y && \
34
- wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
35
- sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
36
- apt-get update && \
37
- apt-get install google-chrome-stable -y --no-install-recommends && \
38
- rm -rf /var/lib/apt/lists/*
39
-
40
- RUN yarn config set registry https://registry.npmjs.org/
41
- RUN yarn config set network-timeout 1200000
42
-
43
- RUN apt update && apt -y install --no-install-recommends ca-certificates git git-lfs openssh-client curl jq cmake sqlite3 openssl psmisc python3
44
-
45
-
46
- RUN apt -y install g++ make
47
-
48
- RUN apt-get clean autoclean && apt-get autoremove --yes && rm -rf /var/lib/{apt,dpkg,cache,log}/
49
-
50
- RUN npm --no-update-notifier --no-fund --global install pnpm
51
- # Copy API
52
- COPY --from=server /app/dist/ .
53
- COPY --from=server /app/prisma/ ./prisma
54
- COPY --from=server /app/package.json .
55
- # Copy UI
56
- COPY --from=build /app/app/ui/dist/ ./public
57
- # Copy widgets
58
- COPY --from=build /app/app/widget/dist/assets/ ./public/assets
59
- COPY --from=build /app/app/widget/dist/index.html ./public/bot.html
60
- # Copy script
61
- COPY --from=build /app/app/script/dist/chat.min.js ./public/chat.min.js
62
-
63
- RUN yarn install --production --frozen-lockfile
64
-
65
26
ENV NODE_ENV=production
66
27
28
+ # Install dependencies and google chrome based on architecture
29
+ RUN apt update && apt install -y wget gnupg dirmngr curl && \
30
+ ARCH=$(dpkg --print-architecture) && \
31
+ if [ "$ARCH" = "amd64" ]; then \
32
+ wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
33
+ sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
34
+ apt-get update && \
35
+ apt-get install google-chrome-stable -y --no-install-recommends; \
36
+ elif [ "$ARCH" = "arm64" ]; then \
37
+ wget -q -O chromium-linux-arm64.zip 'https://playwright.azureedge.net/builds/chromium/1088/chromium-linux-arm64.zip' && \
38
+ unzip chromium-linux-arm64.zip && \
39
+ mv chrome-linux /usr/bin/chromium-browser && \
40
+ ln -s /usr/bin/chromium-browser /usr/bin/google-chrome && \
41
+ rm chromium-linux-arm64.zip; \
42
+ else \
43
+ echo "Unsupported architecture: $ARCH" && exit 1; \
44
+ fi && \
45
+ rm -rf /var/lib/apt/lists/* \
46
+ && apt-get clean && rm -rf /var/lib/{apt,dpkg,cache,log}/
47
+
48
+ # Install other dependencies
49
+ RUN apt update && apt install -y --no-install-recommends \
50
+ ca-certificates git git-lfs openssh-client curl jq cmake sqlite3 openssl psmisc python3 g++ make && \
51
+ apt-get clean autoclean && apt-get autoremove --yes && rm -rf /var/lib/{apt,dpkg,cache,log}/
52
+
53
+ # Copying build artifacts
54
+ COPY --from=server /app/dist/ .
55
+ COPY --from=server /app/prisma/ ./prisma
56
+ COPY --from=server /app/package.json .
57
+ COPY --from=build /app/app/ui/dist/ ./public
58
+ COPY --from=build /app/app/widget/dist/assets/ ./public/assets
59
+ COPY --from=build /app/app/widget/dist/index.html ./public/bot.html
60
+ COPY --from=build /app/app/script/dist/chat.min.js ./public/chat.min.js
61
+
62
+ # Install production dependencies
63
+ RUN yarn config set registry https://registry.npmjs.org/ && \
64
+ yarn config set network-timeout 1200000 && \
65
+ yarn install --production --frozen-lockfile
66
+
67
+ # Start the application
67
68
CMD ["yarn" , "start" ]
0 commit comments