mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-10 12:22:36 +00:00
Merge pull request #4595 from amshinde/fix-clh-tarball-build
Fix clh tarball build
This commit is contained in:
commit
46fd7ce025
@ -23,8 +23,13 @@ RUN apt-get update && \
|
|||||||
ARG IMG_USER=kata-builder
|
ARG IMG_USER=kata-builder
|
||||||
ARG UID=1000
|
ARG UID=1000
|
||||||
ARG GID=1000
|
ARG GID=1000
|
||||||
|
# gid of the docker group on the host, required for running docker in docker builds.
|
||||||
|
ARG HOST_DOCKER_GID
|
||||||
|
|
||||||
RUN if [ ${IMG_USER} != "root" ]; then groupadd --gid=${GID} ${IMG_USER};fi
|
RUN if [ ${IMG_USER} != "root" ]; then groupadd --gid=${GID} ${IMG_USER};fi
|
||||||
RUN if [ ${IMG_USER} != "root" ]; then adduser ${IMG_USER} --uid=${UID} --gid=${GID};fi
|
RUN if [ ${IMG_USER} != "root" ]; then adduser ${IMG_USER} --uid=${UID} --gid=${GID};fi
|
||||||
|
RUN if [ ${IMG_USER} != "root" ] && [ ! -z ${HOST_DOCKER_GID} ]; then groupadd --gid=${HOST_DOCKER_GID} docker_on_host;fi
|
||||||
|
RUN if [ ${IMG_USER} != "root" ] && [ ! -z ${HOST_DOCKER_GID} ]; then usermod -a -G docker_on_host ${IMG_USER};fi
|
||||||
RUN sh -c "echo '${IMG_USER} ALL=NOPASSWD: ALL' >> /etc/sudoers"
|
RUN sh -c "echo '${IMG_USER} ALL=NOPASSWD: ALL' >> /etc/sudoers"
|
||||||
|
|
||||||
#FIXME: gcc is required as agent is build out of a container build.
|
#FIXME: gcc is required as agent is build out of a container build.
|
||||||
@ -40,4 +45,4 @@ RUN apt-get update && \
|
|||||||
apt-get clean && rm -rf /var/lib/apt/lists
|
apt-get clean && rm -rf /var/lib/apt/lists
|
||||||
|
|
||||||
ENV USER ${IMG_USER}
|
ENV USER ${IMG_USER}
|
||||||
USER ${UID}:${GID}
|
USER ${IMG_USER}
|
||||||
|
@ -20,17 +20,27 @@ if [ "${script_dir}" != "${PWD}" ]; then
|
|||||||
ln -sf "${script_dir}/build" "${PWD}/build"
|
ln -sf "${script_dir}/build" "${PWD}/build"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# This is the gid of the "docker" group on host. In case of docker in docker builds
|
||||||
|
# for some of the targets (clh builds from source), the nested container user needs to
|
||||||
|
# be part of this group.
|
||||||
|
docker_gid=$(getent group docker | cut -d: -f3 || { echo >&2 "Missing docker group, docker needs to be installed" && false; })
|
||||||
|
|
||||||
|
# If docker gid is the effective group id of the user, do not pass it as
|
||||||
|
# an additional group.
|
||||||
|
if [ ${docker_gid} == ${gid} ]; then
|
||||||
|
docker_gid=""
|
||||||
|
fi
|
||||||
|
|
||||||
docker build -q -t build-kata-deploy \
|
docker build -q -t build-kata-deploy \
|
||||||
--build-arg IMG_USER="${USER}" \
|
--build-arg IMG_USER="${USER}" \
|
||||||
--build-arg UID=${uid} \
|
--build-arg UID=${uid} \
|
||||||
--build-arg GID=${gid} \
|
--build-arg GID=${gid} \
|
||||||
|
--build-arg HOST_DOCKER_GID=${docker_gid} \
|
||||||
"${script_dir}/dockerbuild/"
|
"${script_dir}/dockerbuild/"
|
||||||
|
|
||||||
docker run \
|
docker run \
|
||||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
--user ${uid}:${gid} \
|
|
||||||
--env USER=${USER} -v "${kata_dir}:${kata_dir}" \
|
--env USER=${USER} -v "${kata_dir}:${kata_dir}" \
|
||||||
--rm \
|
--rm \
|
||||||
-w ${script_dir} \
|
-w ${script_dir} \
|
||||||
build-kata-deploy "${kata_deploy_create}" $@
|
build-kata-deploy "${kata_deploy_create}" $@
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ build_clh_from_source() {
|
|||||||
repo_dir="${repo_dir//.git}"
|
repo_dir="${repo_dir//.git}"
|
||||||
rm -rf "${repo_dir}"
|
rm -rf "${repo_dir}"
|
||||||
git clone "${cloud_hypervisor_repo}"
|
git clone "${cloud_hypervisor_repo}"
|
||||||
|
git config --global --add safe.directory "$PWD/repo_dir"
|
||||||
pushd "${repo_dir}"
|
pushd "${repo_dir}"
|
||||||
|
|
||||||
if [ -n "${cloud_hypervisor_pr}" ]; then
|
if [ -n "${cloud_hypervisor_pr}" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user