fabrica

hanna/fabrica

2318 bytes
Raw
1# This Source Code Form is subject to the terms of the Mozilla Public
2# License, v. 2.0. If a copy of the MPL was not distributed with this
3# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4#
5# Multi-stage, no Nix. The `vendored` feature statically links libgit2, so the
6# runtime image needs no system libgit2. The Nix build (flake.nix) is the
7# alternative; `packages.container` produces an equivalent image natively.
8
9# ---- Builder ----
10FROM rustlang/rust:nightly-slim AS builder
11
12# pkg-config + libssl-dev for native-tls (mail); cmake + a C/C++ toolchain for
13# aws-lc-sys (SSH and the S3 client's aws-lc-rs TLS, which builds C++ sources);
14# git for build scripts.
15RUN apt-get update && apt-get install -y --no-install-recommends \
16 pkg-config libssl-dev cmake g++ git ca-certificates \
17 && rm -rf /var/lib/apt/lists/*
18
19WORKDIR /build
20
21# Cache the dependency layer: build a stub crate graph first, then the real source.
22COPY Cargo.toml Cargo.lock rust-toolchain.toml ./
23COPY crates ./crates
24COPY src ./src
25COPY migrations ./migrations
26COPY assets ./assets
27
28RUN cargo build --release --features vendored \
29 && /build/target/release/fabrica --version
30
31# ---- Runtime ----
32FROM debian:stable-slim
33
34# git is mandatory for pack transport; tini for signal handling; libssl3 for
35# native-tls. Verify git is present at build time so a missing plumbing binary is
36# a build failure, not a runtime surprise.
37RUN apt-get update && apt-get install -y --no-install-recommends \
38 git ca-certificates tini libssl3 \
39 && rm -rf /var/lib/apt/lists/* \
40 && git --version
41
42RUN useradd --uid 10001 --system --home-dir /var/lib/fabrica --shell /usr/sbin/nologin fabrica \
43 && install -d -o fabrica -g fabrica -m 0750 /var/lib/fabrica
44
45COPY --from=builder /build/target/release/fabrica /usr/local/bin/fabrica
46RUN fabrica --version && git --version
47
48USER fabrica
49# The data directory is created and owned by the fabrica user above so first-run
50# generation (signing secret, SQLite database, repos) can write to it. A bind
51# mount overrides this ownership — chown it to uid 10001 on the host.
52VOLUME /var/lib/fabrica
53EXPOSE 8080 2222
54
55HEALTHCHECK --interval=30s --timeout=5s --start-period=10s \
56 CMD ["fabrica", "doctor", "--quiet"]
57
58ENTRYPOINT ["/usr/bin/tini", "--", "fabrica"]
59CMD ["serve"]