Skip to content

Commit d84548a

Browse files
authored
Merge pull request #273 from n4ze3m/next
Next
2 parents 881e1c8 + 6a1eff6 commit d84548a

File tree

1 file changed

+54
-53
lines changed

1 file changed

+54
-53
lines changed

Dockerfile

+54-53
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,68 @@
1-
FROM node:18-slim as server
2-
1+
FROM node:18-slim AS base
32
WORKDIR /app
3+
RUN apt update && apt install -y \
4+
g++ make python3 wget gnupg dirmngr unzip
45

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
88
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
913

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
2016
RUN npm --no-update-notifier --no-fund --global install pnpm
21-
2217
COPY . .
23-
RUN pnpm install
24-
25-
RUN pnpm build
18+
RUN pnpm install && pnpm build
2619

20+
# Final stage
2721
FROM node:18-slim
28-
2922
WORKDIR /app
3023

24+
# Set environment variables
3125
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-
6526
ENV NODE_ENV=production
6627

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
6768
CMD ["yarn", "start"]

0 commit comments

Comments
 (0)