Containerfile
⎇
Raw
1ARG RUST_VERSION=1.90
2ARG BUN_VERSION=1.4.0
3ARG TRUNK_VERSION=0.21.14
4ARG ALPINE_VERSION=3.22
5
6# ── build ────────────────────────────────────────────────────────────────────
7FROM rust:${RUST_VERSION}-alpine${ALPINE_VERSION} AS build
8
9# re-declare the build-args: args set before FROM do not carry into stages
10ARG BUN_VERSION
11ARG TRUNK_VERSION
12
13# binaryen so trunk uses the system wasm-opt instead of downloading a glibc binary that cannot run on musl
14RUN apk add --no-cache curl ca-certificates musl-dev binaryen just \
15 && rustup target add wasm32-unknown-unknown
16
17# bun
18COPY --from=oven/bun:${BUN_VERSION}-alpine /usr/local/bin/bun /usr/local/bin/bun
19
20# trunk
21RUN set -eux; \
22 url=https://github.com/trunk-rs/trunk/releases/download/v${TRUNK_VERSION}/trunk-x86_64-unknown-linux-musl.tar.gz; \
23 curl -fsSL -o /tmp/trunk.tar.gz "${url}"; \
24 curl -fsSL "${url}.sha256" | awk '{print $1 " /tmp/trunk.tar.gz"}' | sha256sum -c -; \
25 tar xzf /tmp/trunk.tar.gz -C /usr/local/bin; \
26 rm -f /tmp/trunk.tar.gz
27
28WORKDIR /src
29COPY . /src
30
31# build
32RUN --mount=type=cache,target=/usr/local/cargo/registry \
33 --mount=type=cache,target=/src/target \
34 just build \
35 && cp target/release/filebrowser-ng /src/filebrowser-ng
36
37# ── runtime ──────────────────────────────────────────────────────────────────
38FROM alpine:${ALPINE_VERSION}
39
40# ffmpeg is only for video thumbnails, and it is most of the image: it pulls
41# ~120 MiB of codec libraries against 8 MiB for the rest
42RUN apk add --no-cache ca-certificates ffmpeg \
43 && mkdir -p /data /var/lib/filebrowser /var/cache/filebrowser
44
45COPY --from=build /src/filebrowser-ng /usr/local/bin/filebrowser-ng
46
47EXPOSE 8080
48VOLUME ["/data", "/var/lib/filebrowser"]
49
50HEALTHCHECK --interval=30s --start-period=10s --timeout=5s --retries=3 \
51 CMD wget -qO /dev/null http://127.0.0.1:8080/ || exit 1
52
53ENTRYPOINT ["/usr/local/bin/filebrowser-ng"]
54CMD ["--root", "/data", "--db", "/var/lib/filebrowser/db.sqlite", "--bind", "0.0.0.0"]
55