2.7 KB74 lines
Blame
1# syntax=docker/dockerfile:1
2# Grove: Mononoke Server Docker Build
3#
4# Build: cd /build/sapling && docker build -f /build/grove/docker/Dockerfile.mononoke -t grove/mononoke .
5# (context must be the sapling/ directory)
6#
7# Requires grove/sapling-deps:latest to be built first (shared C++ deps).
8# Subsequent Rust-only rebuilds take ~5-10 min thanks to --no-deps.
9
10# =============================================================================
11# Stage 1: Build Mononoke (Rust only — C++ deps from shared base image)
12# =============================================================================
13FROM grove/sapling-deps:latest AS builder
14
15# Copy full source tree. Only this layer and below are invalidated when
16# Mononoke Rust source changes — all C++ deps in the base image stay cached.
17COPY . /build
18
19# Build ONLY mononoke (skip deps — they're already in the base image).
20# Cache mounts persist the Cargo registry and the getdeps build dir for
21# mononoke between builds, so incremental Rust compilation works even
22# when the COPY layer above invalidates the Docker layer cache.
23RUN --mount=type=cache,target=/root/.cargo/registry \
24 --mount=type=cache,target=/tmp/fbcode_builder_getdeps-ZbuildZbuildZfbcode_builder-root/build/mononoke \
25 python3 build/fbcode_builder/getdeps.py --allow-system-packages \
26 build --no-deps --build-type MinSizeRel --src-dir=. mononoke \
27 --project-install-prefix mononoke:/
28
29# Collect artifacts with dynamic library fixups
30RUN python3 build/fbcode_builder/getdeps.py --allow-system-packages \
31 fixup-dyn-deps --strip --src-dir=. mononoke \
32 /artifacts --project-install-prefix mononoke:/ \
33 --final-install-prefix /usr/local
34
35# =============================================================================
36# Stage 2: Minimal runtime image
37# =============================================================================
38FROM ubuntu:22.04 AS runtime
39
40RUN apt-get update && apt-get install -y \
41 ca-certificates \
42 git \
43 libssl3 \
44 zlib1g \
45 libzstd1 \
46 liblz4-1 \
47 libsnappy1v5 \
48 libsodium23 \
49 libevent-2.1-7 \
50 libdouble-conversion3 \
51 libgflags2.2 \
52 libgoogle-glog0v5 \
53 libunwind8 \
54 libdwarf1 \
55 && rm -rf /var/lib/apt/lists/*
56
57# Copy built artifacts (fixup-dyn-deps puts binaries in /artifacts/bin/)
58COPY --from=builder /artifacts/bin /usr/local/bin
59
60# Create data directories
61RUN mkdir -p /data/mononoke /config /certs
62
63# Expose ports
64# 8443 = SLAPI (Sapling Remote API / EdenAPI)
65# 8080 = Git HTTP server
66# 8367 = SCS Thrift server
67# 3100 = Grove Bridge (HTTP/JSON API)
68EXPOSE 8443 8080 8367 3100
69
70# Default entrypoint runs the SLAPI server
71ENTRYPOINT ["/usr/local/bin/mononoke"]
72CMD ["--listening-host-port", "0.0.0.0:8443", \
73 "--config-path", "/config"]
74