forked from Shelf-nu/shelf.nu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.image
83 lines (68 loc) · 2.33 KB
/
Dockerfile.image
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Base Node image
FROM node:20-bookworm-slim AS base
# Set for base and all layer that inherit from it
ENV PORT="8080"
ENV NODE_ENV="production"
ARG DEBIAN_FRONTEND="noninteractive"
WORKDIR /src
# Install dependencies for Puppeteer and Google Chrome & Prisma
RUN apt-get update && \
apt-get install -y \
ca-certificates \
fonts-liberation \
libappindicator3-1 \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libcups2 \
libdbus-1-3 \
libdrm2 \
libgbm1 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libx11-xcb1 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
wget \
xdg-utils \
libgbm-dev \
gconf-service \
libxss1 \
libxtst6 \
lsb-release \
unzip \
xvfb \
openssl || { cat /var/log/apt/*log; exit 1; } && \
rm -rf /var/lib/apt/lists/*
# Add Google Chrome repository and install Chrome
RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg \
&& sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrome-linux-keyring.gpg] https://dl-ssl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-khmeros fonts-kacst fonts-freefont-ttf libxss1 dbus dbus-x11 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
ENV CHROME_EXECUTABLE_PATH="/usr/bin/google-chrome-stable"
# Install all node_modules, including dev dependencies
FROM base AS deps
ADD package.json .
RUN npm install --include=dev
# Build the app and setup production node_modules
FROM base AS build
COPY --from=deps /src/node_modules /src/node_modules
ADD . .
RUN npx prisma generate
RUN npm run build
RUN npm prune --omit=dev
# Finally, build the production image with minimal footprint
FROM base AS release
COPY --from=build /src/node_modules /src/node_modules
COPY --from=build /src/app/database /src/app/database
COPY --from=build /src/build /src/build
COPY --from=build /src/package.json /src/package.json
COPY --from=build /src/docker-entrypoint.sh /src/docker-entrypoint.sh
RUN chmod +x /src/docker-entrypoint.sh
ENTRYPOINT [ "/src/docker-entrypoint.sh" ]