docker: Determine nproc for darwin. (closes #52)

docker: Further separate apt and rust cache mounts.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-06-16 03:16:41 +00:00
parent f4e6807a3c
commit fc3fcf4526
5 changed files with 13 additions and 17 deletions

View File

@@ -8,8 +8,8 @@ WORKDIR /
COPY --link --from=input . .
RUN \
--mount=type=cache,dst=${var_cache},sharing=locked \
--mount=type=cache,dst=${var_lib_apt},sharing=locked \
--mount=type=cache,dst=/var/cache,id=${var_cache},sharing=locked \
--mount=type=cache,dst=/var/lib/apt,id=${var_lib_apt},sharing=locked \
<<EOF
set -eux
apt-get -y -U install --no-install-recommends openssl gawk
@@ -156,8 +156,8 @@ ARG complement_run=".*"
WORKDIR /
RUN \
--mount=type=cache,dst=${var_cache},sharing=locked \
--mount=type=cache,dst=${var_lib_apt},sharing=locked \
--mount=type=cache,dst=/var/cache,id=${var_cache},sharing=locked \
--mount=type=cache,dst=/var/lib/apt,id=${var_lib_apt},sharing=locked \
--mount=type=cache,dst=/go/pkg/mod/cache,sharing=locked \
<<EOF
set -eux

View File

@@ -85,7 +85,7 @@ RUN <<EOF
cmake \
--build build \
--target install \
--parallel ${nprocs}
--parallel "${nprocs}"
EOF

View File

@@ -17,8 +17,8 @@ COPY --link --from=input . .
ENV DEBIAN_FRONTEND="${DEBIAN_FRONTEND}"
RUN \
--mount=type=cache,dst=${var_cache},sharing=locked \
--mount=type=cache,dst=${var_lib_apt},sharing=locked \
--mount=type=cache,dst=/var/cache,id=${var_cache},sharing=locked \
--mount=type=cache,dst=/var/lib/apt,id=${var_lib_apt},sharing=locked \
<<EOF
echo $(uname -a) $0 $-
set -eux

View File

@@ -1466,7 +1466,7 @@ target "rust" {
cargo_installs = join(" ", cargo_installs)
CARGO_TERM_VERBOSE = CARGO_TERM_VERBOSE
RUSTUP_HOME = "/opt/rust/rustup/${sys_name}"
RUSTUP_HOME = "/opt/rust/rustup/${sys_name}/${sys_target}"
CARGO_HOME = "/opt/rust/cargo/${sys_name}/${sys_target}"
}
}
@@ -1671,8 +1671,8 @@ target "base" {
}
args = {
DEBIAN_FRONTEND="noninteractive"
var_lib_apt = "/var/lib/apt"
var_cache = "/var/cache"
var_lib_apt = "/var/lib/apt/${sys_name}/${sys_version}/${sys_target}"
var_cache = "/var/cache/${sys_name}/${sys_version}/${sys_target}"
packages = join(" ", base_pkgs)
}
}

View File

@@ -56,8 +56,6 @@ sys_targets="${env_sys_targets:-$default_sys_targets}"
sys_versions="${env_sys_versions:-$default_sys_versions}"
docker_dir="$PWD/$BASEDIR"
runner_name=$(echo $RUNNER_NAME | cut -d"." -f1)
runner_num=$(echo $RUNNER_NAME | cut -d"." -f2)
builder_name="${GITHUB_ACTOR:-owo}"
toolchain_toml="$docker_dir/../rust-toolchain.toml"
rust_msrv=$(grep "channel = " "$toolchain_toml" | cut -d'=' -f2 | sed 's/\s"\|"$//g')
@@ -92,11 +90,9 @@ if test "$CI" = "true"; then
args="$args --allow=network.host"
fi
if test ! -z "$runner_num"; then
#cpu_num=$(expr $runner_num % $(nproc))
#args="$args --cpuset-cpus=${cpu_num}"
#args="$args --set *.args.nprocs=1"
# https://github.com/moby/buildkit/issues/1276
if test "$(uname)" = "Darwin"; then
nprocs=$(sysctl -n hw.logicalcpu)
args="$args --set *.args.nprocs=${nprocs}"
:
else
nprocs=$(nproc)