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