Skip to content

feature: How to change APT source when building BentoML container image? Slow build due to using deb.debian.org #5374

@darlingbud

Description

@darlingbud

Feature request

When I use the bentoml containerize command to build a Docker image, the build process is very slow due to network issues. The log shows that it's spending a lot of time on:

=> [base-container  6/12] RUN apt-get update && apt-get install -q -y --no-install-recommends --allow-  237.7s

This seems to be caused by the default use of http://deb.debian.org/debian as the APT package source, which is very slow in China.

I have successfully solved the pip source issue before by configuring a domestic mirror (e.g., Tsinghua or Aliyun), but now I'm facing similar performance issues with the Debian APT sources during the BentoML container build.

I tried to customize the Dockerfile template using:

docker:
  dockerfile_template: "./Dockerfile_template.j2"

And added the following lines in the Dockerfile template to replace the APT sources with Aliyun's mirror:

# Replace APT sources with Aliyun mirror
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
    apt-get update && \
    apt-get upgrade -y

However, this causes an error during the build step under the stage:

FROM none AS base-container

Is there any way to configure the APT source used during the BentoML container build process?

Motivation

No response

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions