mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-18 09:23:10 +00:00
Merge pull request #412 from Pennyzct/build_rust_image_on_aarch64
AArch64: Build rust image on aarch64
This commit is contained in:
commit
397ce26948
35
rootfs-builder/debian/Dockerfile-aarch64.in
Normal file
35
rootfs-builder/debian/Dockerfile-aarch64.in
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2020 ARM Limited
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
# NOTE: OS_VERSION is set according to config.sh
|
||||||
|
from docker.io/debian:@OS_VERSION@
|
||||||
|
|
||||||
|
# RUN commands
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
autoconf \
|
||||||
|
automake \
|
||||||
|
binutils \
|
||||||
|
build-essential \
|
||||||
|
chrony \
|
||||||
|
cmake \
|
||||||
|
coreutils \
|
||||||
|
curl \
|
||||||
|
debianutils \
|
||||||
|
debootstrap \
|
||||||
|
g++ \
|
||||||
|
gcc \
|
||||||
|
git \
|
||||||
|
libc-dev \
|
||||||
|
libstdc++-6-dev \
|
||||||
|
m4 \
|
||||||
|
make \
|
||||||
|
sed \
|
||||||
|
systemd \
|
||||||
|
tar \
|
||||||
|
vim
|
||||||
|
# This will install the proper golang to build Kata components
|
||||||
|
@INSTALL_GO@
|
||||||
|
@INSTALL_MUSL@
|
||||||
|
@INSTALL_RUST@
|
@ -17,7 +17,6 @@ GO_AGENT_PKG=${GO_AGENT_PKG:-github.com/kata-containers/agent}
|
|||||||
RUST_AGENT_PKG=${RUST_AGENT_PKG:-github.com/kata-containers/kata-containers}
|
RUST_AGENT_PKG=${RUST_AGENT_PKG:-github.com/kata-containers/kata-containers}
|
||||||
RUST_AGENT=${RUST_AGENT:-no}
|
RUST_AGENT=${RUST_AGENT:-no}
|
||||||
RUST_VERSION="null"
|
RUST_VERSION="null"
|
||||||
RUST_SRC_PATH=${RUST_SRC_PATH:-${HOME}/rust}
|
|
||||||
CMAKE_VERSION=${CMAKE_VERSION:-"null"}
|
CMAKE_VERSION=${CMAKE_VERSION:-"null"}
|
||||||
MUSL_VERSION=${MUSL_VERSION:-"null"}
|
MUSL_VERSION=${MUSL_VERSION:-"null"}
|
||||||
AGENT_BIN=${AGENT_BIN:-kata-agent}
|
AGENT_BIN=${AGENT_BIN:-kata-agent}
|
||||||
@ -107,9 +106,6 @@ RUST_AGENT When set to "yes", build kata-agent from kata-rust-agent ins
|
|||||||
RUST_AGENT_PKG URL of the Git repository hosting the agent package.
|
RUST_AGENT_PKG URL of the Git repository hosting the agent package.
|
||||||
Default value: ${RUST_AGENT_PKG}
|
Default value: ${RUST_AGENT_PKG}
|
||||||
|
|
||||||
RUST_SRC_PATH Path of the source code
|
|
||||||
Default value: ${RUST_SRC_PATH}
|
|
||||||
|
|
||||||
AGENT_VERSION Version of the agent to include in the rootfs.
|
AGENT_VERSION Version of the agent to include in the rootfs.
|
||||||
Default value: ${AGENT_VERSION:-<not set>}
|
Default value: ${AGENT_VERSION:-<not set>}
|
||||||
|
|
||||||
@ -281,7 +277,6 @@ check_env_variables()
|
|||||||
|
|
||||||
if [ -z "${AGENT_SOURCE_BIN}" ]; then
|
if [ -z "${AGENT_SOURCE_BIN}" ]; then
|
||||||
[ "$RUST_AGENT" == "yes" -o "$RUST_AGENT" == "no" ] || die "RUST_AGENT($RUST_AGENT) is invalid (must be yes or no)"
|
[ "$RUST_AGENT" == "yes" -o "$RUST_AGENT" == "no" ] || die "RUST_AGENT($RUST_AGENT) is invalid (must be yes or no)"
|
||||||
mkdir -p ${RUST_SRC_PATH} || :
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -n "${KERNEL_MODULES_DIR}" ] && [ ! -d "${KERNEL_MODULES_DIR}" ] && die "KERNEL_MODULES_DIR defined but is not an existing directory"
|
[ -n "${KERNEL_MODULES_DIR}" ] && [ ! -d "${KERNEL_MODULES_DIR}" ] && die "KERNEL_MODULES_DIR defined but is not an existing directory"
|
||||||
@ -392,7 +387,7 @@ build_rootfs_distro()
|
|||||||
if [ "$RUST_AGENT" == "no" ]; then
|
if [ "$RUST_AGENT" == "no" ]; then
|
||||||
docker_run_args+=" --env GO_AGENT_PKG=${GO_AGENT_PKG}"
|
docker_run_args+=" --env GO_AGENT_PKG=${GO_AGENT_PKG}"
|
||||||
else
|
else
|
||||||
docker_run_args+=" --env RUST_AGENT_PKG=${RUST_AGENT_PKG} -v ${RUST_SRC_PATH}:${RUST_SRC_PATH} --env RUST_SRC_PATH=${RUST_SRC_PATH}"
|
docker_run_args+=" --env RUST_AGENT_PKG=${RUST_AGENT_PKG}"
|
||||||
fi
|
fi
|
||||||
docker_run_args+=" --env RUST_AGENT=${RUST_AGENT} -v ${GOPATH_LOCAL}:${GOPATH_LOCAL} --env GOPATH=${GOPATH_LOCAL}"
|
docker_run_args+=" --env RUST_AGENT=${RUST_AGENT} -v ${GOPATH_LOCAL}:${GOPATH_LOCAL} --env GOPATH=${GOPATH_LOCAL}"
|
||||||
else
|
else
|
||||||
@ -405,9 +400,6 @@ build_rootfs_distro()
|
|||||||
# Relabel volumes so SELinux allows access (see docker-run(1))
|
# Relabel volumes so SELinux allows access (see docker-run(1))
|
||||||
if command -v selinuxenabled > /dev/null && selinuxenabled ; then
|
if command -v selinuxenabled > /dev/null && selinuxenabled ; then
|
||||||
SRC_VOL=("${GOPATH_LOCAL}")
|
SRC_VOL=("${GOPATH_LOCAL}")
|
||||||
if [ "${RUST_AGENT}" == "yes" ]; then
|
|
||||||
SRC_VOL+=("${RUST_SRC_PATH}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
for volume_dir in "${script_dir}" \
|
for volume_dir in "${script_dir}" \
|
||||||
"${ROOTFS_DIR}" \
|
"${ROOTFS_DIR}" \
|
||||||
@ -560,37 +552,31 @@ EOT
|
|||||||
AGENT_DEST="${AGENT_DIR}/${AGENT_BIN}"
|
AGENT_DEST="${AGENT_DIR}/${AGENT_BIN}"
|
||||||
|
|
||||||
if [ -z "${AGENT_SOURCE_BIN}" ] ; then
|
if [ -z "${AGENT_SOURCE_BIN}" ] ; then
|
||||||
|
if [ "$RUST_AGENT" != "yes" ]; then
|
||||||
|
agent_pkg="${GO_AGENT_PKG}"
|
||||||
|
agent_dir="${GOPATH_LOCAL}/src/${GO_AGENT_PKG}"
|
||||||
|
else
|
||||||
|
# The PATH /.cargo/bin is apparently wrong
|
||||||
|
# looks like $HOME is resolved to empty when
|
||||||
|
# container is started
|
||||||
|
source "${HOME}/.cargo/env"
|
||||||
|
agent_pkg="${RUST_AGENT_PKG}"
|
||||||
|
agent_dir="${GOPATH_LOCAL}/src/${RUST_AGENT_PKG}/src/agent"
|
||||||
|
# For now, rust-agent doesn't support seccomp yet.
|
||||||
|
SECCOMP="no"
|
||||||
|
fi
|
||||||
|
|
||||||
info "Pull Agent source code"
|
info "Pull Agent source code"
|
||||||
go get -d "${GO_AGENT_PKG}" || true
|
go get -d "${agent_pkg}" || true
|
||||||
OK "Pull Agent source code"
|
OK "Pull Agent source code"
|
||||||
|
|
||||||
info "Build agent"
|
info "Build agent"
|
||||||
pushd "${GOPATH_LOCAL}/src/${GO_AGENT_PKG}"
|
pushd "${agent_dir}"
|
||||||
[ -n "${AGENT_VERSION}" ] && git checkout "${AGENT_VERSION}" && OK "git checkout successful" || info "checkout failed!"
|
[ -n "${AGENT_VERSION}" ] && git checkout "${AGENT_VERSION}" && OK "git checkout successful" || info "checkout failed!"
|
||||||
make clean
|
make clean
|
||||||
make INIT=${AGENT_INIT}
|
make INIT=${AGENT_INIT}
|
||||||
make install DESTDIR="${ROOTFS_DIR}" INIT=${AGENT_INIT} SECCOMP=${SECCOMP}
|
make install DESTDIR="${ROOTFS_DIR}" INIT=${AGENT_INIT} SECCOMP=${SECCOMP}
|
||||||
popd
|
popd
|
||||||
if [ "$RUST_AGENT" == "yes" ]; then
|
|
||||||
# build rust agent
|
|
||||||
info "Build rust agent"
|
|
||||||
# The PATH /.cargo/bin is apparently wrong
|
|
||||||
# looks like $HOME is resolved to empty when
|
|
||||||
# container is started
|
|
||||||
source "${HOME}/.cargo/env"
|
|
||||||
local -r agent_dir="$(basename ${RUST_AGENT_PKG})/src/agent"
|
|
||||||
pushd "${RUST_SRC_PATH}"
|
|
||||||
if [ ! -d ${RUST_SRC_PATH}/${agent_dir} ]; then
|
|
||||||
git clone https://${RUST_AGENT_PKG}.git
|
|
||||||
fi
|
|
||||||
cd ${agent_dir}
|
|
||||||
# checkout correct version
|
|
||||||
[ -n "${AGENT_VERSION}" ] && git checkout "${AGENT_VERSION}" && OK "git checkout successful"
|
|
||||||
make clean
|
|
||||||
make
|
|
||||||
make install DESTDIR="${ROOTFS_DIR}"
|
|
||||||
popd
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
cp ${AGENT_SOURCE_BIN} ${AGENT_DEST}
|
cp ${AGENT_SOURCE_BIN} ${AGENT_DEST}
|
||||||
OK "cp ${AGENT_SOURCE_BIN} ${AGENT_DEST}"
|
OK "cp ${AGENT_SOURCE_BIN} ${AGENT_DEST}"
|
||||||
|
39
rootfs-builder/ubuntu/Dockerfile-aarch64.in
Normal file
39
rootfs-builder/ubuntu/Dockerfile-aarch64.in
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2020 ARM Limited
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
#ubuntu: docker image to be used to create a rootfs
|
||||||
|
#@OS_VERSION@: Docker image version to build this dockerfile
|
||||||
|
from docker.io/ubuntu:@OS_VERSION@
|
||||||
|
|
||||||
|
# This dockerfile needs to provide all the componets need to build a rootfs
|
||||||
|
# Install any package need to create a rootfs (package manager, extra tools)
|
||||||
|
|
||||||
|
# RUN commands
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
autoconf \
|
||||||
|
automake \
|
||||||
|
binutils \
|
||||||
|
build-essential \
|
||||||
|
chrony \
|
||||||
|
cmake \
|
||||||
|
coreutils \
|
||||||
|
curl \
|
||||||
|
debianutils \
|
||||||
|
debootstrap \
|
||||||
|
g++ \
|
||||||
|
gcc \
|
||||||
|
git \
|
||||||
|
libc6-dev \
|
||||||
|
libstdc++-8-dev \
|
||||||
|
m4 \
|
||||||
|
make \
|
||||||
|
sed \
|
||||||
|
systemd \
|
||||||
|
tar \
|
||||||
|
vim
|
||||||
|
# This will install the proper golang to build Kata components
|
||||||
|
@INSTALL_GO@
|
||||||
|
@INSTALL_MUSL@
|
||||||
|
@INSTALL_RUST@
|
@ -199,7 +199,7 @@ create_summary_file()
|
|||||||
if [ "${RUST_AGENT}" == "no" ]; then
|
if [ "${RUST_AGENT}" == "no" ]; then
|
||||||
agent_version=$("$agent" --version|awk '{print $NF}')
|
agent_version=$("$agent" --version|awk '{print $NF}')
|
||||||
else
|
else
|
||||||
local -r agentdir="${RUST_SRC_PATH}/$(basename ${RUST_AGENT_PKG} .git)/src/agent"
|
local -r agentdir="${GOPATH}/src/${RUST_AGENT_PKG}/src/agent"
|
||||||
agent_version=$(cat ${agentdir}/VERSION)
|
agent_version=$(cat ${agentdir}/VERSION)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -274,7 +274,6 @@ generate_dockerfile()
|
|||||||
curlOptions=("-OL")
|
curlOptions=("-OL")
|
||||||
[ -n "${http_proxy:-}" ] && curlOptions+=("-x ${http_proxy:-}")
|
[ -n "${http_proxy:-}" ] && curlOptions+=("-x ${http_proxy:-}")
|
||||||
|
|
||||||
readonly dockerfile_template="Dockerfile.in"
|
|
||||||
readonly install_go="
|
readonly install_go="
|
||||||
RUN cd /tmp ; curl ${curlOptions[@]} https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${goarch}.tar.gz
|
RUN cd /tmp ; curl ${curlOptions[@]} https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${goarch}.tar.gz
|
||||||
RUN tar -C /usr/ -xzf /tmp/go${GO_VERSION}.linux-${goarch}.tar.gz
|
RUN tar -C /usr/ -xzf /tmp/go${GO_VERSION}.linux-${goarch}.tar.gz
|
||||||
@ -296,9 +295,23 @@ RUN pushd /root; \
|
|||||||
make install > /dev/null 2>\&1; \
|
make install > /dev/null 2>\&1; \
|
||||||
popd
|
popd
|
||||||
"
|
"
|
||||||
local musl_tar="musl-${MUSL_VERSION}.tar.gz"
|
# install musl for compiling rust-agent
|
||||||
local musl_dir="musl-${MUSL_VERSION}"
|
install_musl=
|
||||||
readonly install_musl="
|
if [ "${muslarch}" == "aarch64" ]; then
|
||||||
|
local musl_tar="${muslarch}-linux-musl-native.tgz"
|
||||||
|
local musl_dir="${muslarch}-linux-musl-native"
|
||||||
|
install_musl="
|
||||||
|
RUN cd /tmp; \
|
||||||
|
curl -sLO https://musl.cc/${musl_tar}; tar -zxf ${musl_tar}; \
|
||||||
|
mkdir -p /usr/local/musl/; \
|
||||||
|
cp -r ${musl_dir}/* /usr/local/musl/
|
||||||
|
ENV PATH=\$PATH:/usr/local/musl/bin
|
||||||
|
RUN ln -sf /usr/local/musl/bin/g++ /usr/bin/g++
|
||||||
|
"
|
||||||
|
else
|
||||||
|
local musl_tar="musl-${MUSL_VERSION}.tar.gz"
|
||||||
|
local musl_dir="musl-${MUSL_VERSION}"
|
||||||
|
install_musl="
|
||||||
RUN pushd /root; \
|
RUN pushd /root; \
|
||||||
curl -sLO https://www.musl-libc.org/releases/${musl_tar}; tar -zxf ${musl_tar}; \
|
curl -sLO https://www.musl-libc.org/releases/${musl_tar}; tar -zxf ${musl_tar}; \
|
||||||
cd ${musl_dir}; \
|
cd ${musl_dir}; \
|
||||||
@ -310,6 +323,8 @@ RUN pushd /root; \
|
|||||||
popd
|
popd
|
||||||
ENV PATH=\$PATH:/usr/local/musl/bin
|
ENV PATH=\$PATH:/usr/local/musl/bin
|
||||||
"
|
"
|
||||||
|
fi
|
||||||
|
|
||||||
readonly install_rust="
|
readonly install_rust="
|
||||||
RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSLf --output /tmp/rust-init; \
|
RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSLf --output /tmp/rust-init; \
|
||||||
chmod a+x /tmp/rust-init; \
|
chmod a+x /tmp/rust-init; \
|
||||||
@ -328,7 +343,15 @@ RUN ln -sf /usr/bin/g++ /bin/musl-g++
|
|||||||
# rust agent still need go to build
|
# rust agent still need go to build
|
||||||
# because grpc-sys need go to build
|
# because grpc-sys need go to build
|
||||||
pushd ${dir}
|
pushd ${dir}
|
||||||
[ -f "${dockerfile_template}" ] || die "${dockerfile_template}: file not found"
|
dockerfile_template="Dockerfile.in"
|
||||||
|
dockerfile_arch_template="Dockerfile-${architecture}.in"
|
||||||
|
# if arch-specific docker file exists, swap the univesal one with it.
|
||||||
|
if [ -f "${dockerfile_arch_template}" ]; then
|
||||||
|
dockerfile_template="${dockerfile_arch_template}"
|
||||||
|
else
|
||||||
|
[ -f "${dockerfile_template}" ] || die "${dockerfile_template}: file not found"
|
||||||
|
fi
|
||||||
|
|
||||||
# powerpc have no musl target, don't setup rust enviroment
|
# powerpc have no musl target, don't setup rust enviroment
|
||||||
# since we cannot static link agent. Besides, there is
|
# since we cannot static link agent. Besides, there is
|
||||||
# also long double representation problem when building musl-libc
|
# also long double representation problem when building musl-libc
|
||||||
|
Loading…
Reference in New Issue
Block a user