Since I’ve become increasingly unsure about the current state of NUKE Build, I’m experimenting with FAKE instead.
FAKE depends on .NET 6, but I’ve already moved to .NET 10. So here’s a container image that can run FAKE while still keeping a newer .NET SDK installed.
NOTE:
The container runs using a non-root user. This mirrors how CI environments and devcontainers typically operate and avoids installing tools as root. For convenience during experimentation the user is granted passwordless sudo (this should never be used in production).
Here is the Dockerfile:
FROM debian:12-slim
# Use bash for the shell (default is sh)
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Set environment variables
ENV USERNAME=container-user \
HOME_DIR="/home/container-user" \
DOTNET_ROOT=/opt/dotnet \
DEBIAN_FRONTEND=noninteractive
# Update PATH once with all directories
ENV PATH="/usr/local/bin:/opt/dotnet:/opt/dotnet/tools:/home/container-user/.local/bin:/home/container-user/.dotnet/tools:$PATH"
# Install base dependencies used later in the image build.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
sudo && \
rm -rf /var/lib/apt/lists/*
# Create non-root user AFTER sudo is installed
ARG USER_UID=1000
ARG USER_GID=1000
RUN groupadd --gid $USER_GID $USERNAME && \
useradd --uid $USER_UID --gid $USER_GID --create-home --shell /bin/bash $USERNAME && \
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Install .NET SDK (consolidated into one layer, fixed version)
RUN curl -sSL https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh && \
chmod +x dotnet-install.sh && \
./dotnet-install.sh --version 10.0.100 --install-dir $DOTNET_ROOT && \
./dotnet-install.sh --version 6.0.428 --install-dir $DOTNET_ROOT --skip-non-versioned-files && \
rm dotnet-install.sh
USER $USERNAME
WORKDIR $HOME_DIR
Build: docker build -f build/Dockerfile -t fake-runner:dev .
Run as non-root: docker run --rm -it fake-runner:dev /bin/bash
Run as root: docker run --rm -it --user root fake-runner:dev /bin/bash
Thats it :)

Top comments (0)