Slackbot
04/14/2023, 3:41 AMJiang
04/14/2023, 4:07 AMGhawady Ehmaid
04/14/2023, 4:15 AMbentoml containerize in order to use that to deploy a custom container. yatai-image-builder would require Kubernetes environment based on my understandingJiang
04/14/2023, 4:19 AMJiang
04/14/2023, 4:19 AMAaron Pham
04/14/2023, 5:13 AMAaron Pham
04/14/2023, 5:14 AMGhawady Ehmaid
04/14/2023, 6:34 AMJiang
04/14/2023, 6:50 AMJiang
04/14/2023, 6:52 AMJiang
04/14/2023, 6:52 AMJiang
04/14/2023, 6:55 AMGhawady Ehmaid
04/14/2023, 7:14 AMJiang
04/14/2023, 7:22 AMxxx_bentomlJiang
04/14/2023, 7:23 AMJiang
04/14/2023, 7:25 AMJiang
04/14/2023, 9:36 AMGhawady Ehmaid
04/14/2023, 9:42 AMGhawady Ehmaid
04/14/2023, 9:45 AMThat image should be maintained by your team right?Yes
bentoml containerize requires docker as a dependencyI understand that, but still didn't find a proper way of how to build an image with docker, so far my attempt to modify the docker file to have all dependencies just fail with errors
Jiang
04/14/2023, 10:10 AMJiang
04/14/2023, 10:11 AMJiang
04/14/2023, 10:12 AMJiang
04/14/2023, 10:16 AMbentoml containerize is independent to your project's dependencies, thus this image builder image is reusable and do not need those project dependencies.Ghawady Ehmaid
04/14/2023, 10:17 AMJiang
04/14/2023, 10:19 AMgetting errors when trying to install pipAny details? It might due to Google is using distroless in their cloud builder
Ghawady Ehmaid
04/14/2023, 10:25 AM# Create image that is used to run bentoml build
FROM <http://gcr.io/cloud-builders/docker|gcr.io/cloud-builders/docker>
ARG HOME=/home
RUN apt-get update
RUN apt-get install -y python3-dev
RUN apt-get install -y python3
RUN apt-get install -y wget git
RUN python3 --version
RUN apt-get install -y python3-pip
RUN apt-get clean
RUN pip install bentoml
# Set home directory
WORKDIR ${HOME}
But getting an error at python3-pip on executing docker buildJiang
04/14/2023, 10:29 AMJiang
04/14/2023, 10:30 AMGhawady Ehmaid
04/14/2023, 10:31 AMJiang
04/14/2023, 10:31 AMJiang
04/14/2023, 10:32 AMGhawady Ehmaid
04/14/2023, 10:58 AMdocker build command runs... In the meantime I am googling to know how to modify the source list in the apt configuration, if you have an easily shareable example that would handyJiang
04/14/2023, 11:07 AM#0 1.772 Get:1 <http://archive.ubuntu.com/ubuntu> focal/main amd64 liblocale-gettext-perl amd64 1.07-4 [17.1 kB]
#0 2.556 Get:2 <http://archive.ubuntu.com/ubuntu> focal-updates/main amd64 binutils-common amd64 2.34-6ubuntu1.4 [207 kB]
#0 4.122 Get:3 <http://archive.ubuntu.com/ubuntu> focal-updates/main amd64 libbinutils amd64 2.34-6ubuntu1.4 [474 kB]
An answer from chatgpt:
FROM <http://gcr.io/cloud-builders/docker|gcr.io/cloud-builders/docker>
RUN sed -i 's/http:/https:/g' /etc/apt/sources.listGhawady Ehmaid
04/14/2023, 11:09 AMJim Rohrer
04/14/2023, 2:46 PMPrivileged mode if you're going to do Docker-in-Docker (as in, building a Docker image inside CodeBuild's Docker container). That way it has access to the Docker runtime inside the build container.Ghawady Ehmaid
04/16/2023, 5:57 AMDockerfile
# Create image that is used to run bentoml containerize
FROM docker:20.10.24 as static-docker-source
FROM python:3.9
COPY --from=static-docker-source /usr/local/bin/docker /usr/local/bin/docker
ARG HOME=/home
RUN sed -i 's/http:/https:/g' /etc/apt/sources.list
RUN pip install bentoml
# Set home directory
WORKDIR ${HOME}
2- run docker build -t <http://gcr.io/project-id/bentoml_builder|gcr.io/project-id/bentoml_builder> -f bentobuilder.Dockerfile . & docker push <http://gcr.io/autograb-dev/bentoml_builder|gcr.io/autograb-dev/bentoml_builder> to build the image and push it to google container registry
3- Create following cloudbuild.yaml
steps:
# Build bentoml
- name: '<http://gcr.io/project-id/poc_bentoml:latest|gcr.io/project-id/poc_bentoml:latest>'
script: |
python import_model.py --mlflow_run_id=${_MLFLOW_RUN_ID} --mlflow_model_uri=${_MLFLOW_MODEL_URI}
echo running bentoml build
bentoml build
bentoml list
env:
- 'MLFLOW_TRACKING_URI=${_MLFLOW_TRACKING_URI}'
- '_MLFLOW_RUN_ID=${_MLFLOW_RUN_ID}'
- '_MLFLOW_MODEL_URI=${_MLFLOW_MODEL_URI}'
# Containerize bentoml
- name: '<http://gcr.io/project-id/bentoml_builder|gcr.io/project-id/bentoml_builder>'
script: |
echo running bentoml containerize ${_BENTO_SERVICE} -t <http://gcr.io/$PROJECT_ID/${_BENTO_SERVICE}|gcr.io/$PROJECT_ID/${_BENTO_SERVICE}>
bentoml containerize ${_BENTO_SERVICE} -t <http://gcr.io/$PROJECT_ID/${_BENTO_SERVICE}|gcr.io/$PROJECT_ID/${_BENTO_SERVICE}>
env:
- 'PROJECT_ID=$PROJECT_ID'
- '_BENTO_SERVICE=${_BENTO_SERVICE}'
# Push image to container registry
- name: '<http://gcr.io/cloud-builders/docker|gcr.io/cloud-builders/docker>'
args: ['push', '<http://gcr.io/$PROJECT_ID/${_BENTO_SERVICE}|gcr.io/$PROJECT_ID/${_BENTO_SERVICE}>']
substitutions: # default values
_BENTO_SERVICE: "poc_service:latest"
_MLFLOW_TRACKING_URI: "xxx"
_MLFLOW_RUN_ID: "xxx"
_MLFLOW_MODEL_URI: "xxx"
images:
- <http://gcr.io/$PROJECT_ID/${_BENTO_SERVICE}|gcr.io/$PROJECT_ID/${_BENTO_SERVICE}>
options:
dynamic_substitutions: true
logging: CLOUD_LOGGING_ONLY
4- Now it is possible to trigger the build by running gcloud beta builds submit --project=project-id --config=cloudbuild.yaml --substitutions=_MLFLOW_TRACKING_URI="xxx",_BENTO_SERVICE="xxx",_MLFLOW_RUN_ID="xxx",_MLFLOW_MODEL_URI="xxx"
Note: The first step in the cloudbuild script is using an imaged built to conclude the required files to run bentoml build command such as bentofile.yaml, service.py, and other code required to create the bento service. Second and third steps would be common for any bento deployment.
It would be great if there is a better way to do step 1 without having to bake a new image with the source code for every service.