-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
88 lines (72 loc) · 3.5 KB
/
Copy pathDockerfile
File metadata and controls
88 lines (72 loc) · 3.5 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
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
# syntax=docker/dockerfile:1.7
ARG CROSS_IMAGE=repo.indexarr.net/indexarr/rustnzb-ci-cross@sha256:89f1f570acb0f8e6514ffcca39bd9f26305263d95274e4c170eedf867d113ad9
ARG UNRAR_VERSION=7.2.3
ARG UNRAR_SHA256=3995af0aa32b1505a566da053725551a1f0698dc42b2fdf7ba7d65db0d004e33
FROM alpine:3.23 AS unrar-builder
ARG UNRAR_VERSION
ARG UNRAR_SHA256
RUN apk add --no-cache build-base curl \
&& curl -fsSLo /tmp/unrar.tar.gz \
"https://www.rarlab.com/rar/unrarsrc-${UNRAR_VERSION}.tar.gz" \
&& echo "${UNRAR_SHA256} /tmp/unrar.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/unrar.tar.gz -C /tmp \
&& make -C /tmp/unrar -j"$(getconf _NPROCESSORS_ONLN)" \
&& install -Dm755 /tmp/unrar/unrar /out/unrar
FROM --platform=$BUILDPLATFORM ${CROSS_IMAGE} AS builder
ARG TARGETPLATFORM
ARG RUSTNZB_BUILD_REF=local
ARG RELEASE_OPTIMIZED=false
WORKDIR /build
# Install and build the frontend only from its declared source and lockfile.
# Host node_modules, Angular output, and stale dist trees are excluded by
# .dockerignore and therefore cannot affect the runtime image.
COPY apps/rustnzb/frontend/package.json apps/rustnzb/frontend/package-lock.json apps/rustnzb/frontend/
RUN --mount=type=cache,target=/root/.npm,sharing=locked \
npm --prefix apps/rustnzb/frontend ci --no-audit --no-fund
COPY apps/rustnzb/frontend apps/rustnzb/frontend
RUN npm --prefix apps/rustnzb/frontend run build -- --configuration=production \
&& test -s apps/rustnzb/frontend/dist/frontend/browser/index.html
# Cargo manifests and sources are copied only after the frontend dependency
# layer so ordinary application edits do not invalidate npm downloads.
COPY Cargo.toml Cargo.lock ./
COPY apps apps
COPY crates crates
# The build uses only public crates.io dependencies for the rustnzb binary.
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
--mount=type=cache,target=/usr/local/cargo/git,sharing=locked \
--mount=type=cache,target=/build/target,sharing=locked \
set -eu; \
case "$TARGETPLATFORM" in \
linux/amd64) rust_target=x86_64-unknown-linux-musl ;; \
linux/arm64) rust_target=aarch64-unknown-linux-musl ;; \
*) printf 'unsupported target platform: %s\n' "$TARGETPLATFORM" >&2; exit 1 ;; \
esac; \
if [ "$RELEASE_OPTIMIZED" = true ]; then \
export CARGO_PROFILE_RELEASE_LTO=thin \
CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 \
CARGO_PROFILE_RELEASE_STRIP=symbols; \
fi; \
CARGO_TARGET_DIR=/build/target \
RUSTNZB_BUILD_REF="$RUSTNZB_BUILD_REF" \
cargo zigbuild --release --locked -p rustnzb \
--features webdav,vendored-openssl --target "$rust_target"; \
mkdir -p /out; \
cp "/build/target/$rust_target/release/rustnzb" /out/rustnzb
FROM lscr.io/linuxserver/baseimage-alpine:3.23@sha256:46d690858431e262d574274bb2863e1fbaf8de61c6f7677150dd79c2cc65cdcf AS runtime
ARG RUSTNZB_BUILD_REF
RUN apk add --no-cache \
7zip \
ca-certificates \
curl \
libgcc \
libstdc++
COPY --from=builder /out/rustnzb /usr/local/bin/rustnzb
COPY --from=unrar-builder /out/unrar /usr/local/bin/unrar
COPY apps/rustnzb/root/ /
LABEL org.opencontainers.image.title="rustnzb" \
org.opencontainers.image.source="https://github.com/TheDancingDeveloper-org/rustnzb" \
org.opencontainers.image.revision="$RUSTNZB_BUILD_REF"
EXPOSE 9090
VOLUME ["/config", "/data", "/downloads"]
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD curl -fsS http://127.0.0.1:9090/api/health || exit 1