docker/Dockerfile.mononokeblame
View source
dd34ddd1# syntax=docker/dockerfile:1
3e3af552# Grove: Mononoke Server Docker Build
3e3af553#
1e64dbc4# Build: cd /build/sapling && docker build -f /build/grove/docker/Dockerfile.mononoke -t grove/mononoke .
3e3af555# (context must be the sapling/ directory)
3e3af556#
2d46ffc7# Requires grove/sapling-deps:latest to be built first (shared C++ deps).
2d46ffc8# Subsequent Rust-only rebuilds take ~5-10 min thanks to --no-deps.
3e3af559
3e3af5510# =============================================================================
2d46ffc11# Stage 1: Build Mononoke (Rust only — C++ deps from shared base image)
3e3af5512# =============================================================================
2d46ffc13FROM grove/sapling-deps:latest AS builder
3e3af5514
1e64dbc15# Copy full source tree. Only this layer and below are invalidated when
2d46ffc16# Mononoke Rust source changes — all C++ deps in the base image stay cached.
12ffdd417COPY . /build
12ffdd418
2d46ffc19# Build ONLY mononoke (skip deps — they're already in the base image).
dd34ddd20# Cache mounts persist the Cargo registry and the getdeps build dir for
dd34ddd21# mononoke between builds, so incremental Rust compilation works even
dd34ddd22# when the COPY layer above invalidates the Docker layer cache.
dd34ddd23RUN --mount=type=cache,target=/root/.cargo/registry \
dd34ddd24 --mount=type=cache,target=/tmp/fbcode_builder_getdeps-ZbuildZbuildZfbcode_builder-root/build/mononoke \
dd34ddd25 python3 build/fbcode_builder/getdeps.py --allow-system-packages \
1e64dbc26 build --no-deps --build-type MinSizeRel --src-dir=. mononoke \
3e3af5527 --project-install-prefix mononoke:/
3e3af5528
3e3af5529# Collect artifacts with dynamic library fixups
3e3af5530RUN python3 build/fbcode_builder/getdeps.py --allow-system-packages \
3e3af5531 fixup-dyn-deps --strip --src-dir=. mononoke \
3e3af5532 /artifacts --project-install-prefix mononoke:/ \
3e3af5533 --final-install-prefix /usr/local
3e3af5534
3e3af5535# =============================================================================
2d46ffc36# Stage 2: Minimal runtime image
3e3af5537# =============================================================================
3e3af5538FROM ubuntu:22.04 AS runtime
3e3af5539
3e3af5540RUN apt-get update && apt-get install -y \
3e3af5541 ca-certificates \
79efd4142 git \
3e3af5543 libssl3 \
3e3af5544 zlib1g \
3e3af5545 libzstd1 \
3e3af5546 liblz4-1 \
3e3af5547 libsnappy1v5 \
3e3af5548 libsodium23 \
3e3af5549 libevent-2.1-7 \
3e3af5550 libdouble-conversion3 \
3e3af5551 libgflags2.2 \
3e3af5552 libgoogle-glog0v5 \
3e3af5553 libunwind8 \
3e3af5554 libdwarf1 \
3e3af5555 && rm -rf /var/lib/apt/lists/*
3e3af5556
12ffdd457# Copy built artifacts (fixup-dyn-deps puts binaries in /artifacts/bin/)
12ffdd458COPY --from=builder /artifacts/bin /usr/local/bin
3e3af5559
3e3af5560# Create data directories
3e3af5561RUN mkdir -p /data/mononoke /config /certs
3e3af5562
3e3af5563# Expose ports
3e3af5564# 8443 = SLAPI (Sapling Remote API / EdenAPI)
3e3af5565# 8080 = Git HTTP server
3e3af5566# 8367 = SCS Thrift server
4a006da67# 3100 = Grove Bridge (HTTP/JSON API)
4a006da68EXPOSE 8443 8080 8367 3100
3e3af5569
3e3af5570# Default entrypoint runs the SLAPI server
3e3af5571ENTRYPOINT ["/usr/local/bin/mononoke"]
3e3af5572CMD ["--listening-host-port", "0.0.0.0:8443", \
1e64dbc73 "--config-path", "/config"]