Skip to content

Conversation

@jianshen92
Copy link
Contributor

@jianshen92 jianshen92 commented Dec 3, 2025

What does this PR address?

Starting point for adding build time only support for BentoML and BentoCloud

Uses docker secret mount https://docs.docker.com/build/building/secrets/ when running bentoml containerize

bentoml containerize

API change

@bentoml.service(
    envs=[
        {"name": "HF_TOKEN"},
        {"name": "DB_HOST", "value": "localhost"},
        {"name": "BUILD", "value": "hello", "stages": "all" | "build" | "runtime"}, # new stage field
    ]
)
class MyService:

Generated RUN commands with secret mount (where BUILD env is set as "build" stage only) :

RUN --mount=type=secret,id=BUILD --mount=type=secret,id=BUILD_TOO  BUILD="$(cat /run/secrets/BUILD)" BUILD_TOO="$(cat /run/secrets/BUILD_TOO)" apt-get update && apt-get install -q -y --no-install-recommends --allow-remove-essential ca-certificates gnupg2 bash build-essential git
RUN --mount=type=secret,id=BUILD --mount=type=secret,id=BUILD_TOO  BUILD="$(cat /run/secrets/BUILD)" BUILD_TOO="$(cat /run/secrets/BUILD_TOO)" command -v uv >/dev/null || pip install uv
RUN --mount=type=secret,id=BUILD --mount=type=secret,id=BUILD_TOO  BUILD="$(cat /run/secrets/BUILD)" BUILD_TOO="$(cat /run/secrets/BUILD_TOO)" UV_PYTHON_INSTALL_DIR=/app/python/ uv venv --python 3.11 /app/.venv && \
    chown -R bentoml:bentoml /app/.venv

Before submitting:

@jianshen92 jianshen92 requested a review from a team as a code owner December 3, 2025 20:35
@jianshen92 jianshen92 requested review from xianml and removed request for a team December 3, 2025 20:35
@jianshen92 jianshen92 requested a review from frostming December 4, 2025 09:21
@jianshen92
Copy link
Contributor Author

Testing for edge cases

@jianshen92 jianshen92 requested a review from frostming December 4, 2025 21:10
@jianshen92 jianshen92 merged commit 4f1b514 into bentoml:main Dec 5, 2025
47 of 51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants