Skip to content

Commit

Permalink
more WIP
Browse files Browse the repository at this point in the history
Signed-off-by: greg pereira <grpereir@redhat.com>
  • Loading branch information
Gregory-Pereira committed Jun 11, 2024
1 parent 7550808 commit bff6c7e
Show file tree
Hide file tree
Showing 10 changed files with 274 additions and 88 deletions.
6 changes: 5 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# to define environment variables available to docker-compose.yml

# subman creds for RHEL builds
SUBMAN_USER=
SUBMAN_PASS=

IMAGE_REPO=milvusdb
IMAGE_ARCH=amd64
OS_NAME=ubuntu20.04
OS_NAME=rhel9

# for services.builder.image in docker-compose.yml
DATE_VERSION=20240520-d27db99
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/rhel9-milvus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Publish Builder
# 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/builder/cpu/**'
- '.github/workflows/publish-builder.yaml'
- '!**.md'
pull_request:
# file paths to consider in the event. Optional; defaults to all.
paths:
- 'build/docker/builder/cpu/**'
- '.github/workflows/publish-builder.yaml'
- '!**.md'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
publish-builder:
name: ${{ matrix.arch }} ${{ matrix.os }}
runs-on: ubuntu-latest
timeout-minutes: 500
strategy:
fail-fast: false
matrix:
os: [rockylinux8]
arch: [arm64]
env:
OS_NAME: ${{ matrix.os }}
IMAGE_ARCH: ${{ matrix.arch }}
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
if: ${{ ! startsWith(runner.name, 'self') }} # skip this step if it is self-hosted runner
with:
root-reserve-mb: 20480
# overprovision-lvm: 'true'
swap-size-mb: 1024
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
- name: Checkout
uses: actions/checkout@v2
- name: Get version from system time after release step
id: extracter
run: |
echo "::set-output name=version::$(date +%Y%m%d)"
echo "::set-output name=sha_short::$(git rev-parse --short=7 HEAD)"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
milvusdb/milvus-env
tags: |
type=raw,enable=true,value=${{ matrix.os }}-{{date 'YYYYMMDD'}}-{{sha}}
type=raw,enable=true,value=${{ matrix.os }}-latest
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
file: build/docker/builder/cpu/${{ matrix.os }}/Dockerfile
- name: Bump Builder Version
uses: ./.github/actions/bump-builder-version
if: success() && github.event_name == 'push' && github.repository == 'milvus-io/milvus' && matrix.os == 'ubuntu20.04'
with:
tag: "${{ steps.extracter.outputs.version }}-${{ steps.extracter.outputs.sha_short }}"
type: cpu
token: ${{ secrets.ALL_CONTRIBUTORS_TOKEN }}
40 changes: 0 additions & 40 deletions build/docker/builder/cpu/rhel9/Containerfile

This file was deleted.

68 changes: 68 additions & 0 deletions build/docker/builder/cpu/rhel9/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
FROM registry.access.redhat.com/ubi9/ubi:9.4-947.1717074712 as vcpkg-installer
USER 0
RUN dnf install -y wget zip git gcc gcc-c++ cmake dnf-plugins-core ninja-build
RUN dnf install -y perl-IPC-Cmd perl-Digest-SHA perl-FindBin perl-File-Compare perl-File-Copy

ENV VCPKG_FORCE_SYSTEM_BINARIES 1

RUN mkdir /opt/vcpkg && \
wget -qO- vcpkg.tar.gz https://github.com/microsoft/vcpkg/archive/master.tar.gz | tar --strip-components=1 -xz -C /opt/vcpkg && \
rm -rf vcpkg.tar.gz

# empty the vscpkg toolchains linux.cmake file to avoid the error
RUN echo "" > /opt/vcpkg/scripts/toolchains/linux.cmake

# install azure-identity-cpp azure-storage-blobs-cpp gtest via vcpkg
RUN /opt/vcpkg/bootstrap-vcpkg.sh -disableMetrics && \
ln -s /opt/vcpkg/vcpkg /usr/local/bin/vcpkg && \
vcpkg version && \
vcpkg install azure-identity-cpp azure-storage-blobs-cpp gtest

########################################################################################
FROM registry.access.redhat.com/ubi9/ubi:9.4-947.1717074712

ARG TARGETARCH
ARG SUBMAN_USER
ARG SUBMAN_PASS
USER 0

# basic deps
RUN dnf install -y libaio libuuid-devel \
perl-IPC-Cmd perl-Digest-SHA \
libtool ninja-build wget \
python3.11 python3.11-pip

RUN alias python3='python3.11'

# taken from .env file
RUN subscription-manager register --username $SUBMAN_USER --password $SUBMAN_PASS

COPY build/docker/builder/cpu/rhel9/install-rpms.sh /root/install-rpms.sh
RUN chmod +x /root/install-rpms.sh
RUN TARGETARCH=$TARGETARCH /root/install-rpms.sh

# Install conan and Go
RUN python3.11 -m pip install conan==1.61.0

COPY build/docker/builder/cpu/rhel9/install-go.sh /root/install-go.sh
RUN chmod +x /root/install-go.sh
RUN TARGETARCH=$TARGETARCH /root/install-go.sh

RUN curl https://sh.rustup.rs -sSf | \
sh -s -- --default-toolchain=1.73 -y

ENV PATH=/root/.cargo/bin:/usr/local/bin:/usr/local/go/bin:$PATH

ENV VCPKG_FORCE_SYSTEM_BINARIES 1

# RUN mkdir /opt/vcpkg && \
# wget -qO- vcpkg.tar.gz https://github.com/microsoft/vcpkg/archive/master.tar.gz | tar --strip-components=1 -xz -C /opt/vcpkg && \
# rm -rf vcpkg.tar.gz
COPY --from=vcpkg-installer/opt/vcpkg COPY --from=vcpkg-installer

COPY --from=vcpkg-installer /root/.cache/vcpkg /root/.cache/vcpkg
COPY --chown=0:0 build/docker/builder/entrypoint.sh /

USER 1001
ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["tail", "-f", "/dev/null"]
39 changes: 0 additions & 39 deletions build/docker/builder/cpu/rhel9/Milvus-ubuntu-to-rhel.md

This file was deleted.

41 changes: 41 additions & 0 deletions build/docker/builder/cpu/rhel9/install-go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#/bin/bash
if [[ -z "$GOROOT" ]]; then
GOROOT=/usr/local/go
fi

mkdir -p $GOROOT

RUN_MODE=""
if [[ -z "$TARGETARCH" ]]; then
TARGETARCH=$(uname -m)
echo "\$TARGETARCH not set - defaulting to host system"
fi

if [[ "$TARGETARCH" == "arm64" ]] || [[ "$TARGETARCH" == "aarch64" ]]; then
RUN_MODE="arm64"
elif [[ "$TARGETARCH" == "amd64" ]] || [[ "$TARGETARCH" == "x86_64" ]]; then
RUN_MODE="amd64"
else
echo "invalid \$TARGETARCH, build failure.
Supported options: ['arm64', 'aarch64', 'amd64', 'x86_64']"
exit 1
fi

export GO111MODULE="on"

if [[ -z "$GOPATH" ]]; then
export GOPATH="/go"
fi

if [[ "$RUN_MODE" == "arm64" ]] || [[ "$RUN_MODE" == "amd64" ]] ; then
wget -qO- "https://go.dev/dl/go1.21.10.linux-$RUN_MODE.tar.gz" | tar --strip-components=1 -xz -C $GOROOT
else
echo "uncaught \$RUN_MODE based on invalid \$TARGETARCH."
exit 1
fi

export PATH="$GOPATH/bin:$GOROOT/bin:$PATH"

mkdir -p "$GOPATH/src" "$GOPATH/bin"
go clean --modcache
chmod -R 777 "$GOPATH" && chmod -R a+w $(go env GOTOOLDIR)
35 changes: 35 additions & 0 deletions build/docker/builder/cpu/rhel9/install-rpms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#/bin/bash
RUN_MODE=""
if [[ -z "$TARGETARCH" ]]; then
TARGETARCH=$(uname -m)
echo "\$TARGETARCH not set - defaulting to host system"
fi

if [[ "$TARGETARCH" == "arm64" ]] || [[ "$TARGETARCH" == "aarch64" ]]; then
RUN_MODE="aarch64"
elif [[ "$TARGETARCH" == "amd64" ]] || [[ "$TARGETARCH" == "x86_64" ]]; then
RUN_MODE="x86_64"
else
echo "invalid \$TARGETARCH, build failure.
Supported options: ['arm64', 'aarch64', 'amd64', 'x86_64']"
exit 1
fi

if [[ "$RUN_MODE" == "aarch64" ]]; then
dnf install -y \
https://www.rpmfind.net/linux/centos-stream/9-stream/AppStream/aarch64/os/Packages/perl-Unicode-EastAsianWidth-12.0-7.el9.noarch.rpm \
https://www.rpmfind.net/linux/centos-stream/9-stream/AppStream/aarch64/os/Packages/perl-Text-Unidecode-1.30-16.el9.noarch.rpm \
https://www.rpmfind.net/linux/centos-stream/9-stream/AppStream/aarch64/os/Packages/perl-libintl-perl-1.32-4.el9.aarch64.rpm \
https://www.rpmfind.net/linux/centos-stream/9-stream/CRB/aarch64/os/Packages/texinfo-6.7-15.el9.aarch64.rpm
dnf install -y --enablerepo=codeready-builder-for-rhel-9-aarch64-rpms openblas-devel
elif [[ "$RUN_MODE" == "x86_64" ]]; then
dnf install -y \
https://www.rpmfind.net/linux/centos-stream/9-stream/AppStream/x86_64/os/Packages/perl-Unicode-EastAsianWidth-12.0-7.el9.noarch.rpm \
https://www.rpmfind.net/linux/centos-stream/9-stream/AppStream/x86_64/os/Packages/perl-Text-Unidecode-1.30-16.el9.noarch.rpm \
https://www.rpmfind.net/linux/centos-stream/9-stream/AppStream/x86_64/os/Packages/perl-libintl-perl-1.32-4.el9.x86_64.rpm \
https://www.rpmfind.net/linux/centos-stream/9-stream/CRB/x86_64/os/Packages/texinfo-6.7-15.el9.x86_64.rpm
dnf install -y --enablerepo=codeready-builder-for-rhel-9-x86_64-rpms openblas-devel
else
echo "uncaught runmode based on invalid \$TARGETARCH."
exit 1
fi
16 changes: 8 additions & 8 deletions build/docker/milvus/rhel9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ FROM registry.access.redhat.com/ubi9/ubi:9.4-947.1717074712

ARG TARGETARCH

# assumes repo of codeready-builder-for-rhel-9-<arch>
RUN dnf install -y wget libgomp libaio libatomic

# RUN subscription-manager register --auto-attach
# install openblas-devel
RUN dnf copr enable @copr/PyPI epel-9
RUN
RUN dnf -y install dnf-plugins-core && \
# Could not find a version of openblas-devel on RHEL
dnf -y install openblas
COPY build/docker/milvus/rhel9/install-openblas.sh /home/install-openblas.sh
RUN chmod +x /home/install-openblas.sh
RUN TARGETARCH=$TARGETARCH /home/install-openblas.sh

# Remove cache for image sizing
RUN rm -rf /var/cache/dnf/*

COPY ./bin/ /milvus/bin/

COPY ./configs/ /milvus/configs/
COPY ./configs/ /milvus/configs/

COPY ./lib/ /milvus/lib/

Expand Down
22 changes: 22 additions & 0 deletions build/docker/milvus/rhel9/install-openblas.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
RUN_MODE=""
if [[ -z "$TARGETARCH" ]]; then
TARGETARCH=$(uname -m)
echo "\$TARGETARCH not set - defaulting to host system"
fi

if [[ "$TARGETARCH" == "arm64" ]] || [[ "$TARGETARCH" == "aarch64" ]]; then
RUN_MODE="aarch64"
elif [[ "$TARGETARCH" == "amd64" ]] || [[ "$TARGETARCH" == "x86_64" ]]; then
RUN_MODE="x86_64"
else
echo "invalid \$TARGETARCH, build failure.
Supported options: ['arm64', 'aarch64', 'amd64', 'x86_64']"
exit 1
fi

if [[ "$RUN_MODE" == "aarch64" ]] || [[ "$RUN_MODE" == "x86_64" ]]; then
dnf install -y --enablerepo=codeready-builder-for-rhel-9-$RUN_MODE-rpms openblas-devel
else
echo "uncaught runmode based on invalid \$TARGETARCH."
exit 1
fi
Loading

0 comments on commit bff6c7e

Please sign in to comment.