forked from stumpapp/stump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
122 lines (93 loc) · 3.61 KB
/
Dockerfile
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# ------------------------------------------------------------------------------
# Frontend Build Stage
# ------------------------------------------------------------------------------
FROM node:20.0.0-alpine3.16 AS frontend
ARG TARGETARCH
WORKDIR /app
COPY . .
# https://github.com/nodejs/docker-node/issues/1335
RUN yarn config set network-timeout 300000 && \
yarn install --frozen-lockfile && \
yarn web build && \
mv ./apps/web/dist/ ./build && \
if [ ! -d "./build" ] || [ ! "$(ls -A ./build)" ]; then exit 1; fi
# ------------------------------------------------------------------------------
# Cargo Build Stage
# ------------------------------------------------------------------------------
FROM rust:1.79.0-slim-buster AS builder
ARG GIT_REV
ENV GIT_REV=${GIT_REV}
ARG TAGS
ENV TAGS=${TAGS}
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
git \
libssl-dev \
pkg-config \
meson \
ninja-build \
nasm \
libsqlite3-dev;
#Building dav1d for AVIF Support
RUN git clone https://github.com/stumpapp/dav1d.git
WORKDIR /dav1d
RUN mkdir build
WORKDIR /dav1d/build
RUN meson setup ../; \
ninja; \
ninja install; \
ln -s /usr/local/lib/x86_64-linux-gnu/libdav1d.so.7.0.0 /usr/local/lib/libdav1d.so.7; \
ln -s /usr/local/lib/x86_64-linux-gnu/libdav1d.so.7.0.0 /usr/local/lib/libdav1d.so.7.0; \
ln -s /usr/local/lib/x86_64-linux-gnu/libdav1d.so.7.0.0 /usr/local/lib/libdav1d.so.7.0.0; \
echo "/usr/local/lib" >> /etc/ld.so.conf.d/mylibs.conf \
&& ldconfig
#Cargo build for stump
WORKDIR /app
COPY . .
RUN cargo codegen
RUN ./scripts/release/utils.sh -w
RUN set -ex
RUN ./scripts/release/utils.sh -p
RUN cargo build --package stump_server --bin stump_server --release
RUN cp ./target/release/stump_server ./stump_server
# ------------------------------------------------------------------------------
# PDFium Stage
# ------------------------------------------------------------------------------
FROM debian:buster-slim AS pdfium
ARG TARGETARCH
RUN apt-get update && apt-get install -y curl tar; \
# Download and extract PDFium
set -ex; \
mkdir -p pdfium; \
if [ "$TARGETARCH" = "amd64" ]; then \
# NOTE: This was previously -x86, need to test more on amd64-compatible systems to ensure I have the right one
curl -sLo pdfium.tgz https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/6406/pdfium-linux-x64.tgz; \
elif [ "$TARGETARCH" = "arm64" ]; then \
curl -sLo pdfium.tgz https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/6406/pdfium-linux-arm64.tgz; \
fi; \
tar -xzvf pdfium.tgz -C ./pdfium; \
rm pdfium.tgz
# ------------------------------------------------------------------------------
# Final Stage
# ------------------------------------------------------------------------------
FROM debian:buster-slim
RUN apt-get update && apt-get install -y locales-all && rm -rf /var/lib/apt/lists/*; \
mkdir -p config && mkdir -p data && mkdir -p app
COPY --from=builder /app/stump_server /app/stump
COPY --from=pdfium /pdfium /opt/pdfium
COPY --from=frontend /app/build /app/client
COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh; \
ln -s /opt/pdfium/lib/libpdfium.so /lib/libpdfium.so; \
if [ ! -d "/app/client" ] || [ ! "$(ls -A /app/client)" ]; then exit 1; fi
# Default Stump environment variables
ENV STUMP_CONFIG_DIR=/config \
STUMP_CLIENT_DIR=/app/client \
STUMP_PROFILE=release \
STUMP_PORT=10801 \
STUMP_IN_DOCKER=true \
PDFIUM_PATH=/lib/libpdfium.so \
API_VERSION=v1
WORKDIR /app
ENTRYPOINT ["/entrypoint.sh"]