-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (52 loc) · 2.85 KB
/
Copy pathDockerfile
File metadata and controls
64 lines (52 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0.400-alpine3.23 AS build
ARG TARGETARCH
WORKDIR /tmp
# Pre-install packages for offline usage
RUN dotnet new console && \
dotnet add package Exercism.Tests --version 0.1.0-beta1 && \
dotnet add package Exercism.Tests.xunit.v3 --version 0.1.0-beta1 && \
dotnet add package FakeItEasy --version 6.2.1 && \
dotnet add package FsCheck --version 2.14.4 && \
dotnet add package FsCheck --version 3.1.0 && \
dotnet add package FsCheck --version 3.3.2 && \
dotnet add package FsCheck.Xunit --version 2.14.4 && \
dotnet add package FsCheck.Xunit.v3 --version 3.3.2 && \
dotnet add package Microsoft.NET.Test.Sdk --version 17.12.0 && \
dotnet add package Microsoft.NET.Test.Sdk --version 18.3.0 && \
dotnet add package Microsoft.Reactive.Testing --version 5.0.0 && \
dotnet add package Sprache --version 2.3.1 && \
dotnet add package Superpower --version 3.1.0 && \
dotnet add package xunit --version 2.8.1 && \
dotnet add package xunit.v3 --version 1.1.0 && \
dotnet add package xunit.v3 --version 3.2.2 && \
dotnet add package xunit.runner.visualstudio --version 3.0.1 && \
dotnet add package xunit.runner.visualstudio --version 3.1.5 && \
dotnet add package BenchmarkDotNet --version 0.14.0 && \
dotnet add package Microsoft.Extensions.TimeProvider.Testing --version 9.2.0
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY src/Exercism.TestRunner.CSharp/Exercism.TestRunner.CSharp.csproj ./
RUN dotnet restore -a $TARGETARCH
# Copy everything else and build
COPY src/Exercism.TestRunner.CSharp/ ./
RUN dotnet publish -a $TARGETARCH --output /opt/test-runner --no-restore
# Slim the pre-installed NuGet cache before it is copied into the runtime image.
# Restore from the global packages folder uses the extracted files, so the .nupkg
# archives, foreign-platform Capstone natives (a BenchmarkDotNet disassembly
# dependency) and the build-only crossgen2 tool are all redundant.
RUN find /root/.nuget/packages -type f \( -name '*.nupkg' -o -name '*.snupkg' \) -delete && \
find /root/.nuget/packages/gee.external.capstone -type d \( -name 'win-*' -o -name 'osx-*' -o -name 'linux-x86' -o -name 'linux-arm' \) -prune -exec rm -rf {} + && \
rm -rf /root/.nuget/packages/microsoft.netcore.app.crossgen2.*
# Build runtime image
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0.400-alpine3.23 AS runtime
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
ENV DOTNET_ROLL_FORWARD=Major
ENV DOTNET_NOLOGO=true
ENV DOTNET_CLI_TELEMETRY_OPTOUT=true
# RUN apk add --no-cache icu-libs icu-data-full tzdata
WORKDIR /opt/test-runner
COPY --from=build /opt/test-runner/ .
COPY --from=build /usr/local/bin/ /usr/local/bin/
COPY --from=build /root/.nuget/packages/ /root/.nuget/packages/
COPY run.sh bin/
ENTRYPOINT ["sh", "/opt/test-runner/bin/run.sh"]