This repository was archived by the owner on Mar 27, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (49 loc) · 2.34 KB
/
Copy pathDockerfile
File metadata and controls
62 lines (49 loc) · 2.34 KB
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
FROM rust:latest AS builder
# Allow overriding the target architecture
ARG TARGETARCH
# Allow enabling LibreOffice support
ARG WITH_LIBREOFFICE=false
ENV WITH_LIBREOFFICE=${WITH_LIBREOFFICE}
# Compute the RUSTARCH based on the TARGETARCH argument; falling back to `uname`.
RUN case "$TARGETARCH" in \
"amd64") RUSTARCH="x86_64-unknown-linux-musl" ;; \
"arm64"*) RUSTARCH="aarch64-unknown-linux-musl" ;; \
*) echo "Unsupported TARGETARCH: $TARGETARCH"; exit 1 ;; \
esac && \
rustup target add $RUSTARCH && \
echo "RUSTARCH=${RUSTARCH}" >> /etc/environment
# Install necessary packages for building the application
RUN apt update -y
RUN apt install -y musl-tools musl-dev ca-certificates curl gnupg
# Instal Node.js from NodeSource
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_21.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update -y
RUN apt-get install -y nodejs
# Build the Rust application
RUN mkdir -p /usr/src/parcel
WORKDIR /usr/src/parcel
ADD . .
RUN . /etc/environment && cargo build --target "$RUSTARCH" $( [ "$WITH_LIBREOFFICE" = "true" ] && echo "--features libreoffice" ) --release
RUN . /etc/environment && cp "/usr/src/parcel/target/${RUSTARCH}/release/parcel-server" /usr/src/parcel/target/parcel-server
# ------------------------------------------------------------------------------------------------
# Build the final image
FROM alpine:latest
# Allow enabling LibreOffice support
ARG WITH_LIBREOFFICE=false
ENV WITH_LIBREOFFICE=${WITH_LIBREOFFICE}
# Install dependencies, such as file identification and preview generation tools.
RUN apk add --no-cache file imagemagick poppler-utils ffmpeg
# If we're building with LibreOffice support, install it.
RUN echo "WITH_LIBREOFFICE=$WITH_LIBREOFFICE" && if [ "$WITH_LIBREOFFICE" = "true" ]; then \
apk add --no-cache libreoffice; \
fi
# Prepare the working directory
WORKDIR /app
COPY --from=builder /usr/src/parcel/target/parcel-server .
COPY --from=builder /usr/src/parcel/crates/server/static ./static
COPY --from=builder /usr/src/parcel/etc/previewers.json ./etc/previewers.json
# Set the user and run the application
EXPOSE 3000
ENTRYPOINT ["./parcel-server"]