humanizr-humanizer
SUCCESS
26m 58s
History Source
SummaryIterations1Transcript24Dockerfile
Dockerfile49 lines · 1510 chars
##############################
# Multi-stage build for Humanizer library using .NET 10 preview
# Stage 1: Build with .NET 10 preview SDK on Ubuntu 22.04
##############################
FROM ubuntu:22.04 AS build
ENV DEBIAN_FRONTEND=noninteractive

RUN set -eux; \
    apt-get update; \
    apt-get install -y --no-install-recommends \
        ca-certificates \
        curl \
        gnupg \
        dirmngr; \
    rm -rf /var/lib/apt/lists/*;

# Install .NET 10.0 preview SDK via dotnet-install script
RUN curl -sSL https://dot.net/v1/dotnet-install.sh -o /tmp/dotnet-install.sh; \
    chmod +x /tmp/dotnet-install.sh; \
    /tmp/dotnet-install.sh --version 10.0.100 --install-dir /usr/share/dotnet --no-path;
ENV DOTNET_ROOT=/usr/share/dotnet
ENV PATH=${DOTNET_ROOT}:$PATH
# Enable globalization invariant mode to avoid ICU requirements in some environments
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true

WORKDIR /src

# Copy the repository contents
COPY . ./

# Avoid pinned global.json in the repository interfering with SDK selection
RUN rm -f global.json || true

# Restore and build the Humanizer project (net10.0)
RUN dotnet restore
RUN dotnet build -c Release -f net10.0 src/Humanizer/Humanizer.csproj

##############################
# Stage 2: Runtime image (smaller)
##############################
FROM ubuntu:22.04 AS runtime
WORKDIR /app

# Copy built outputs from the build stage (net10.0)
COPY --from=build /src/src/Humanizer/bin/Release/net10.0 /app

# Provide a shell for testing
CMD ["bash"]