Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition cloud-hypervisor to use toolchain build #184

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 11 additions & 58 deletions platform/Dockerfiles/cloud-hypervisor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,70 +1,23 @@
ARG TOOLCHAIN_REVISION=undefined
FROM artificialwisdomai/toolchain:${TOOLCHAIN_REVISION} AS build_cloud_hypervisor

# syntax=docker/dockerfile:1
FROM docker.io/library/debian:12 AS build_cloud_hypervisor
LABEL "com.computelify.vendor"="Computelify, Inc."
LABEL "cloud.artificialwisdom.vendor"="The Artificial Wisdom Cloud"
LABEL "version"="v1.80.0"
LABEL "version"="v40.0"
LABEL "description"="debian/cloud-hypervisor"

ENV DEBIAN_FRONTEND noninteractive
ENV RUST_VERSION 1.80.0
ENV RUST_ARCH x86_64
ENV CLOUD_HYPERVISOR_VERSION 40.0

ENV PATH "$PATH:/root/.cargo/bin/"


###
#
# global build dependencies

RUN apt update
RUN apt --yes install curl
RUN apt --yes install git
RUN apt --yes install build-essential
RUN apt --yes install pkg-config
RUN apt --yes install musl-tools


###
#
# Runtime dependencies for cargo-deb

RUN apt --yes install dpkg
RUN apt --yes install dpkg-dev
RUN apt --yes install liblzma-dev
ENV CLOUD_HYPERVISOR_VERSION="40.0"

WORKDIR /workspace
RUN git clone --depth 1 --branch v${CLOUD_HYPERVISOR_VERSION} https://github.com/cloud-hypervisor/cloud-hypervisor build

###
#
# Install rustup-init, which then installs the host toolchain, target toolchain, and cargo commands

WORKDIR /workspace/install
RUN curl --location --remote-name https://static.rust-lang.org/rustup/dist/${RUST_ARCH}-unknown-linux-gnu/rustup-init
RUN chmod +x rustup-init
RUN ./rustup-init -y --profile=minimal --default-host=${RUST_ARCH}-unknown-linux-gnu --default-toolchain=${RUST_VERSION}-${RUST_ARCH}-unknown-linux-gnu --target=${RUST_ARCH}-unknown-linux-musl
# 1-liner to list project features: cargo metadata --format-version=1 --no-deps | jq '.packages[].features | keys'
RUN cargo install cargo-deb --locked


###
#
# Prepare and build cloud-hypervisor

WORKDIR /workspace/build
RUN git clone --depth 1 --branch v${CLOUD_HYPERVISOR_VERSION} https://github.com/cloud-hypervisor/cloud-hypervisor cloud-hypervisor-v${CLOUD_HYPERVISOR_VERSION}

WORKDIR /workspace/build/cloud-hypervisor-v${CLOUD_HYPERVISOR_VERSION}
WORKDIR /workspace/build/
RUN cargo deb --profile release --target=${RUST_ARCH}-unknown-linux-musl --separate-debug-symbols --compress-debug-symbols


###
#
# Output the build by placing in ${PWD}/target

WORKDIR /workspace/target
RUN cp --archive --recursive /workspace/build/cloud-hypervisor-v${CLOUD_HYPERVISOR_VERSION}/target/${RUST_ARCH}-unknown-linux-musl/release/cloud-hypervisor /workspace/target/cloud-hypervisor_v${CLOUD_HYPERVISOR_VERSION}
RUN cp --archive --recursive /workspace/build/cloud-hypervisor-v${CLOUD_HYPERVISOR_VERSION}/target/${RUST_ARCH}-unknown-linux-musl/release/ch-remote /workspace/target/ch-remote_v${CLOUD_HYPERVISOR_VERSION}
RUN cp --archive --recursive /workspace/build/cloud-hypervisor-v${CLOUD_HYPERVISOR_VERSION}/target/${RUST_ARCH}-unknown-linux-musl/debian/cloud-hypervisor_${CLOUD_HYPERVISOR_VERSION}.0-1_amd64.deb /workspace/target
RUN cp --archive --recursive /workspace/build/target/${RUST_ARCH}-unknown-linux-musl/release/cloud-hypervisor /workspace/target/cloud-hypervisor_v${CLOUD_HYPERVISOR_VERSION}
RUN cp --archive --recursive /workspace/build/target/${RUST_ARCH}-unknown-linux-musl/release/ch-remote /workspace/target/ch-remote_v${CLOUD_HYPERVISOR_VERSION}
RUN cp --archive --recursive /workspace/build/target/${RUST_ARCH}-unknown-linux-musl/debian/cloud-hypervisor_${CLOUD_HYPERVISOR_VERSION}.0-1_amd64.deb /workspace/target

FROM scratch
COPY --from=build_cloud_hypervisor /workspace/target /
7 changes: 4 additions & 3 deletions platform/Dockerfiles/cloud-hypervisor/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CLOUD_HYPERVISOR_VERSION=40.0
TOOLCHAIN_REVISION=20240812
date=$(date '+%Y%m%d%H%M%S')

docker buildx build --tag artificialwisdomai/cloud-hypervisor:v${CLOUD_HYPERVISOR_VERSION} --output type=docker --progress plain .
docker buildx build --tag artificialwisdomai/cloud-hypervisor:v${CLOUD_HYPERVISOR_VERSION}-${date} --output type=docker --progress plain .
docker buildx build --tag artificialwisdomai/cloud-hypervisor:v${CLOUD_HYPERVISOR_VERSION}-${date} --output type=local,dest="${PWD}/target" --progress plain .
docker buildx build --build-arg TOOLCHAIN_REVISION=${TOOLCHAIN_REVISION} --tag artificialwisdomai/cloud-hypervisor:v${CLOUD_HYPERVISOR_VERSION} --output type=docker --progress plain .
docker buildx build --build-arg TOOLCHAIN_REVISION=${TOOLCHAIN_REVISION} --tag artificialwisdomai/cloud-hypervisor:v${CLOUD_HYPERVISOR_VERSION}-${date} --output type=docker --progress plain .
docker buildx build --build-arg TOOLCHAIN_REVISION=${TOOLCHAIN_REVISION} --tag artificialwisdomai/cloud-hypervisor:v${CLOUD_HYPERVISOR_VERSION}-${date} --output type=local,dest="${PWD}/target" --progress plain .
Loading