From f4ea6a494bc6cf9a3eba86625a69defd54b5b486 Mon Sep 17 00:00:00 2001 From: Aqil Aziz Date: Sat, 23 May 2026 15:55:52 +0700 Subject: [PATCH] fix(docker): lower default build memory (#2420) --- Dockerfile | 15 +++++++++++---- gitbooks/features/cloud-deploy.md | 4 ++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 526f02c8c..209d696c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,13 @@ # ========================================================================== FROM rust:1.93-bookworm AS builder -ENV DEBIAN_FRONTEND=noninteractive +# Docker builds often run on small VPS/CI builders. The crate's `ci` profile +# keeps peak rustc memory lower than `release`; override with +# `--build-arg CARGO_PROFILE=release` when maximum runtime optimization matters. +ARG CARGO_PROFILE=ci +ARG CARGO_BUILD_JOBS=1 +ENV DEBIAN_FRONTEND=noninteractive \ + CARGO_BUILD_JOBS=${CARGO_BUILD_JOBS} # System dependencies required for compilation. # @@ -43,14 +49,15 @@ COPY Cargo.toml Cargo.lock rust-toolchain.toml ./ RUN mkdir -p src && \ echo 'fn main() {}' > src/main.rs && \ echo 'pub fn run_core_from_args(_: &[String]) -> anyhow::Result<()> { Ok(()) }' > src/lib.rs && \ - cargo build --release --bin openhuman-core 2>/dev/null || true && \ + cargo build --profile "${CARGO_PROFILE}" --bin openhuman-core 2>/dev/null || true && \ rm -rf src # Copy actual source and build COPY src/ src/ # Touch main.rs to force rebuild of our code (not deps) RUN touch src/main.rs src/lib.rs && \ - cargo build --release --bin openhuman-core + cargo build --profile "${CARGO_PROFILE}" --bin openhuman-core && \ + cp "target/${CARGO_PROFILE}/openhuman-core" /tmp/openhuman-core # ========================================================================== # Stage 2: Minimal runtime image @@ -84,7 +91,7 @@ RUN mkdir -p /home/openhuman/.openhuman \ && chown -R openhuman:openhuman /home/openhuman # Copy the built binary -COPY --from=builder /build/target/release/openhuman-core /usr/local/bin/openhuman-core +COPY --from=builder /tmp/openhuman-core /usr/local/bin/openhuman-core # Copy the entrypoint script that chowns the workspace volume before dropping # privileges. The script is a separate file so the E2E entrypoint diff --git a/gitbooks/features/cloud-deploy.md b/gitbooks/features/cloud-deploy.md index bcd14447d..b9c227f46 100644 --- a/gitbooks/features/cloud-deploy.md +++ b/gitbooks/features/cloud-deploy.md @@ -649,6 +649,10 @@ To run the same check locally: ```bash docker build -t openhuman-core:smoke . +# Optional: tune build profile and Cargo parallelism. +# Keep CARGO_BUILD_JOBS=1 on constrained builders; raise it on larger machines. +docker build --build-arg CARGO_PROFILE=release --build-arg CARGO_BUILD_JOBS=4 -t openhuman-core:release . + # Token-set path (App Platform): docker run -d --name oh-smoke -p 7788:7788 \ -e OPENHUMAN_CORE_TOKEN=smoke-test-token \