Files
kata-containers/tools/packaging/static-build/virtiofsd/gnu/Dockerfile
Hyounggyu Choi 2962e14c10 virtiofsd: fix RUSTUP_HOME and CARGO_HOME permissions for non-root builds
The following error was observed during virtiofsd static build:

```
error: could not create temp file /opt/rustup/tmp/p44enysfaxwdbvw4_file:
Permission denied (os error 13)
```

This occurs because RUSTUP_HOME and CARGO_HOME were initialized by the
root user during `docker build`, but `cargo build` is executed as a
non-root user via 'docker run --user'.

Ensure these directories are writable by adjusting the permission after
the toolchain installation is complete.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2026-01-09 14:01:20 +01:00

47 lines
1.7 KiB
Docker

# Copyright (c) 2022 Intel
#
# SPDX-License-Identifier: Apache-2.0
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
ARG RUST_TOOLCHAIN
ENV RUSTUP_HOME="/opt/rustup"
ENV CARGO_HOME="/opt/cargo"
ENV PATH="/opt/cargo/bin/:${PATH}"
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN mkdir ${RUSTUP_HOME} ${CARGO_HOME}
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
git \
libcap-ng-dev \
libseccomp-dev \
unzip && \
apt-get clean && rm -rf /var/lib/lists/ && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${RUST_TOOLCHAIN} && \
chmod -R a+rwX ${RUSTUP_HOME} ${CARGO_HOME}
RUN ARCH=$(uname -m); \
rust_arch=""; \
libc=""; \
arch_libc=""; \
extra_rust_flags=" -C link-self-contained=yes"; \
case "${ARCH}" in \
"aarch64") rust_arch="${ARCH}"; libc="musl"; arch_libc="" ;; \
"ppc64le") rust_arch="powerpc64le"; libc="gnu"; arch_libc=${rust_arch}-linux-${libc}; extra_rust_flags="" ;; \
"riscv64") rust_arch="riscv64gc"; libc="gnu"; arch_libc=${ARCH}-linux-${libc}; extra_rust_flags="" ;; \
"x86_64") rust_arch="${ARCH}"; libc="musl"; arch_libc="" ;; \
"s390x") rust_arch="${ARCH}"; libc="gnu"; arch_libc=${rust_arch}-linux-${libc}; extra_rust_flags="" ;; \
*) echo "Unsupported architecture: ${ARCH}" && exit 1 ;; \
esac; \
echo "RUST_ARCH=${rust_arch}" > /etc/profile.d/rust.sh; \
echo "LIBC=${libc}" >> /etc/profile.d/rust.sh; \
echo "ARCH_LIBC=${arch_libc}" >> /etc/profile.d/rust.sh; \
echo "EXTRA_RUST_FLAGS=\"${extra_rust_flags}\"" >> /etc/profile.d/rust.sh;