Make docker base separate from milvus image (#20473)

Signed-off-by: Jenny Li <jing.li@zilliz.com>

Signed-off-by: Jenny Li <jing.li@zilliz.com>
This commit is contained in:
Jenny Li 2022-11-15 15:15:07 +08:00 committed by GitHub
parent c848896bc8
commit 091291f99c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 133 additions and 28 deletions

View File

@ -0,0 +1,81 @@
name: Publish Milvus Base Image
# TODO: do not trigger action for some document file update
# This workflow is triggered on pushes or pull request to the repository.
on:
push:
# file paths to consider in the event. Optional; defaults to all.
paths:
- 'build/docker/milvus/ubuntu20.04/Dockerfile.base'
- '.github/workflows/publish-milvus-base.yaml'
pull_request:
# file paths to consider in the event. Optional; defaults to all.
paths:
- 'build/docker/milvus/ubuntu20.04/Dockerfile.base'
- '.github/workflows/publish-milvus-base.yaml'
jobs:
publish-milvus-base:
name: milvus-base-ubuntu20.04
runs-on: ubuntu-latest
env:
OS_NAME: ubuntu20.04
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Generate docker image tag name
id: generate-tag-name
run: |
export tag=$(date +%Y%m%d)-$(git rev-parse --short HEAD)
echo $tag
echo "::set-output name=docker_tag::$tag"
- name: Docker Build
shell: bash
run: |
docker build -f "./build/docker/milvus/${OS_NAME}/Dockerfile.base" -t "milvusdb/milvus-base:${{ steps.generate-tag-name.outputs.docker_tag }}" .
- name: Docker login
if: success() && github.event_name == 'push' && github.repository == 'milvus-io/milvus'
uses: azure/docker-login@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker Push
if: success() && github.event_name == 'push' && github.repository == 'milvus-io/milvus'
continue-on-error: false
shell: bash
run: |
docker push milvusdb/milvus-base:${{ steps.generate-tag-name.outputs.docker_tag }}
- name: Update Milvus Base Image Changes
if: success() && github.event_name == 'push' && github.repository == 'milvus-io/milvus'
continue-on-error: true
shell: bash
run: |
sed -i "s#^MILVUS_BASE_IMAGE_TAG=.*#MILVUS_BASE_IMAGE_TAG=${{ steps.generate-tag-name.outputs.docker_tag }}#g" build/docker/milvus/ubuntu20.04/Dockerfile
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add build/docker/milvus/ubuntu20.04/Dockerfile
git commit -m "Update Milvus base image tag"
- name: Create Pull Request
id: cpr
if: success() && github.event_name == 'push' && github.repository == 'milvus-io/milvus'
continue-on-error: true
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.ALL_CONTRIBUTORS_TOKEN }}
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: true
branch: update_base_${{ github.sha }}
delete-branch: true
title: '[automated] Update Milvus Base image Tag'
body: |
Update Update Milvus Base image Tag
See changes: https://github.com/milvus-io/milvus/commit/${{ github.sha }}
Signed-off-by: ${{ github.actor }} ${{ github.actor }}@users.noreply.github.com
- name: Check outputs
if: success() && github.event_name == 'push' && github.repository == 'milvus-io/milvus' && matrix.os == 'ubuntu20.04'
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"

View File

@ -28,9 +28,20 @@ OS_NAME="${OS_NAME:-ubuntu20.04}"
MILVUS_IMAGE_REPO="${MILVUS_IMAGE_REPO:-milvusdb/milvus}"
MILVUS_IMAGE_TAG="${MILVUS_IMAGE_TAG:-latest}"
pushd "${toplevel}"
MILVUS_BASE_IMAGE_REPO="${MILVUS_BASE_IMAGE_REPO:-milvusdb/milvus-base}"
MILVUS_BASE_IMAGE_TAG="local"
BUILD_ARGS=""
docker build -f "./build/docker/milvus/${OS_NAME}/Dockerfile" -t "${MILVUS_IMAGE_REPO}:${MILVUS_IMAGE_TAG}" .
pushd "${toplevel}"
BUILD_BASE_IMAGE=${BUILD_BASE_IMAGE:-"false"}
# Seperate base dockerfile to ignore install dependencies when build milvus image
if [[ ${OS_NAME} == "ubuntu20.04" && ${BUILD_BASE_IMAGE} == "true" ]]; then
docker build -f "./build/docker/milvus/${OS_NAME}/Dockerfile.base" -t "${MILVUS_BASE_IMAGE_REPO}:${MILVUS_BASE_IMAGE_TAG}" .
BUILD_ARGS="--build-arg MILVUS_BASE_IMAGE_REPO=${MILVUS_BASE_IMAGE_REPO} --build-arg MILVUS_BASE_IMAGE_TAG=${MILVUS_BASE_IMAGE_TAG}"
fi
docker build ${BUILD_ARGS} -f "./build/docker/milvus/${OS_NAME}/Dockerfile" -t "${MILVUS_IMAGE_REPO}:${MILVUS_IMAGE_TAG}" .
image_size=$(docker inspect ${MILVUS_IMAGE_REPO}:${MILVUS_IMAGE_TAG} -f '{{.Size}}'| awk '{ byte =$1 /1024/1024/1024; print byte " GB" }')

View File

@ -8,24 +8,9 @@
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under the License.
FROM milvusdb/openblas:ubuntu20.04-20220914-179ea77 AS openblas
#FROM alpine
FROM ubuntu:focal-20220426
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC
RUN apt-get update && \
apt-get install -y --no-install-recommends curl libtbb-dev gfortran netcat iputils-ping ca-certificates liblapack3 libzstd-dev uuid-dev libaio-dev libboost-program-options-dev libboost-filesystem-dev && \
apt-get remove --purge -y && \
rm -rf /var/lib/apt/lists/*
COPY --from=openblas /usr/local/lib/libopenblasp-r0.3.21.so /usr/lib/
RUN ln -s /usr/lib/libopenblasp-r0.3.21.so /usr/lib/libopenblas.so.3 && \
ln -s /usr/lib/libopenblas.so.3 /usr/lib/libopenblas.so
ARG MILVUS_BASE_IMAGE_REPO="milvusdb/milvus-base"
ARG MILVUS_BASE_IMAGE_TAG="20221114-b1a6660"
FROM ${MILVUS_BASE_IMAGE_REPO}:${MILVUS_BASE_IMAGE_TAG}
COPY ./bin/ /milvus/bin/
@ -35,11 +20,4 @@ COPY ./lib/ /milvus/lib/
ENV PATH=/milvus/bin:$PATH
ENV LD_LIBRARY_PATH=/milvus/lib:$LD_LIBRARY_PATH:/usr/lib
ENV LD_PRELOAD=/milvus/lib/libjemalloc.so
# Add Tini
ADD https://github.com/krallin/tini/releases/download/v0.19.0/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]
WORKDIR /milvus/
ENV LD_PRELOAD=/milvus/lib/libjemalloc.so

View File

@ -0,0 +1,35 @@
# Copyright (C) 2019-2022 Zilliz. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under the License.
FROM milvusdb/openblas:ubuntu20.04-20220914-179ea77 AS openblas
#FROM alpine
FROM ubuntu:focal-20220426
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC
RUN apt-get update && \
apt-get install -y --no-install-recommends curl libtbb-dev gfortran netcat iputils-ping ca-certificates liblapack3 libzstd-dev uuid-dev libaio-dev libboost-program-options-dev libboost-filesystem-dev && \
apt-get remove --purge -y && \
rm -rf /var/lib/apt/lists/*
COPY --from=openblas /usr/local/lib/libopenblasp-r0.3.21.so /usr/lib/
RUN ln -s /usr/lib/libopenblasp-r0.3.21.so /usr/lib/libopenblas.so.3 && \
ln -s /usr/lib/libopenblas.so.3 /usr/lib/libopenblas.so
# Add Tini
ADD https://github.com/krallin/tini/releases/download/v0.19.0/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]
WORKDIR /milvus/