Skip to content

Commit

Permalink
feat: use dotnet 8 chiseled images
Browse files Browse the repository at this point in the history
  • Loading branch information
aneojgurhem committed Feb 12, 2024
1 parent 8741f31 commit 593cac2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 28 deletions.
20 changes: 12 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 as base
RUN groupadd --gid 5000 armonikuser && useradd --home-dir /home/armonikuser --create-home --uid 5000 --gid 5000 --shell /bin/sh --skel /dev/null armonikuser
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled as base

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG VERSION=1.0.0.0
ARG TARGETARCH

RUN mkdir /cache /local_storage

WORKDIR /src
# git ls-tree -r HEAD --name-only --full-tree | grep "csproj$" | xargs -I % sh -c "export D=\$(dirname %) ; echo COPY [\\\"%\\\", \\\"\$D/\\\"]"
COPY ["Adaptors/Amqp/src/ArmoniK.Core.Adapters.Amqp.csproj", "Adaptors/Amqp/src/"]
Expand Down Expand Up @@ -72,6 +73,9 @@ WORKDIR /src/Control/Submitter/src
RUN dotnet publish "ArmoniK.Core.Control.Submitter.csproj" -a $TARGETARCH --no-restore -o /app/publish/submitter /p:UseAppHost=false -p:RunAnalyzers=false -p:WarningLevel=0 -p:PackageVersion=$VERSION -p:Version=$VERSION

FROM base as polling_agent
WORKDIR /
COPY --from=build --chown=$APP_UID:$APP_UID /cache /cache
COPY --from=build --chown=$APP_UID:$APP_UID /local_storage /local_storage
WORKDIR /adapters/queue/pubsub
COPY --from=build /app/publish/pubsub .
WORKDIR /adapters/queue/amqp
Expand All @@ -80,8 +84,7 @@ WORKDIR /adapters/queue/rabbit
COPY --from=build /app/publish/rabbit .
WORKDIR /app
COPY --from=build /app/publish/polling_agent .
RUN mkdir /cache /local_storage && chown armonikuser: /cache /local_storage
USER armonikuser
USER $APP_UID

ENV ASPNETCORE_URLS http://+:1080
EXPOSE 1080
Expand All @@ -92,7 +95,7 @@ ENTRYPOINT ["dotnet", "ArmoniK.Core.Compute.PollingAgent.dll"]
FROM base as metrics
WORKDIR /app
COPY --from=build /app/publish/metrics .
USER armonikuser
USER $APP_UID

ENV ASPNETCORE_URLS http://+:1080
EXPOSE 1080
Expand All @@ -103,7 +106,7 @@ ENTRYPOINT ["dotnet", "ArmoniK.Core.Control.Metrics.dll"]
FROM base as partition_metrics
WORKDIR /app
COPY --from=build /app/publish/partition_metrics .
USER armonikuser
USER $APP_UID

ENV ASPNETCORE_URLS http://+:1080
EXPOSE 1080
Expand All @@ -112,6 +115,8 @@ ENTRYPOINT ["dotnet", "ArmoniK.Core.Control.PartitionMetrics.dll"]


FROM base as submitter
WORKDIR /
COPY --from=build --chown=$APP_UID:$APP_UID /local_storage /local_storage
WORKDIR /adapters/queue/pubsub
COPY --from=build /app/publish/pubsub .
WORKDIR /adapters/queue/amqp
Expand All @@ -120,8 +125,7 @@ WORKDIR /adapters/queue/rabbit
COPY --from=build /app/publish/rabbit .
WORKDIR /app
COPY --from=build /app/publish/submitter .
RUN mkdir /local_storage && chown armonikuser: /local_storage
USER armonikuser
USER $APP_UID

ENV ASPNETCORE_URLS http://+:1080, http://+:1081
EXPOSE 1080
Expand Down
6 changes: 2 additions & 4 deletions Tests/Bench/Client/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled AS base
WORKDIR /app

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
Expand All @@ -25,7 +25,5 @@ RUN dotnet publish -a "${TARGETARCH}" "ArmoniK.Samples.Bench.Client.csproj" --no
FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
RUN groupadd --gid 5000 armonikuser && useradd --home-dir /home/armonikuser --create-home --uid 5000 --gid 5000 --shell /bin/sh --skel /dev/null armonikuser

USER armonikuser
USER $APP_UID
ENTRYPOINT ["dotnet", "ArmoniK.Samples.Bench.Client.dll"]
10 changes: 6 additions & 4 deletions Tests/Bench/Server/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled AS base
WORKDIR /app

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG TARGETARCH
ARG VERSION=1.0.0.0

RUN mkdir /cache

WORKDIR /src
COPY ["Tests/Bench/Server/src/ArmoniK.Samples.Bench.Server.csproj", "Tests/Bench/Server/src/"]
COPY ["Common/src/ArmoniK.Core.Common.csproj", "Common/src/"]
Expand All @@ -17,10 +19,10 @@ WORKDIR "/src/Tests/Bench/Server/src"
RUN dotnet publish -a "${TARGETARCH}" "ArmoniK.Samples.Bench.Server.csproj" -o /app/publish -p:RunAnalyzers=false -p:WarningLevel=0 -p:PackageVersion="$VERSION" -p:Version="$VERSION"

FROM base AS final
WORKDIR /
COPY --from=build --chown=$APP_UID:$APP_UID /cache /cache
WORKDIR /app
COPY --from=build /app/publish .
RUN groupadd --gid 5000 armonikuser && useradd --home-dir /home/armonikuser --create-home --uid 5000 --gid 5000 --shell /bin/sh --skel /dev/null armonikuser
RUN mkdir /cache && chown armonikuser: /cache
USER armonikuser
USER $APP_UID
EXPOSE 1080
ENTRYPOINT ["dotnet", "ArmoniK.Samples.Bench.Server.dll"]
6 changes: 2 additions & 4 deletions Tests/HtcMock/Client/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled AS base
WORKDIR /app

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
Expand All @@ -25,7 +25,5 @@ RUN dotnet publish -a "${TARGETARCH}" "ArmoniK.Samples.HtcMock.Client.csproj" --
FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
RUN groupadd --gid 5000 armonikuser && useradd --home-dir /home/armonikuser --create-home --uid 5000 --gid 5000 --shell /bin/sh --skel /dev/null armonikuser

USER armonikuser
USER $APP_UID
ENTRYPOINT ["dotnet", "ArmoniK.Samples.HtcMock.Client.dll"]
10 changes: 6 additions & 4 deletions Tests/HtcMock/Server/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled AS base
WORKDIR /app

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG TARGETARCH
ARG VERSION=1.0.0.0

RUN mkdir /cache

WORKDIR /src
COPY ["Tests/HtcMock/Server/src/ArmoniK.Samples.HtcMock.Server.csproj", "Tests/HtcMock/Server/src/"]
COPY ["Common/src/ArmoniK.Core.Common.csproj", "Common/src/"]
Expand All @@ -17,10 +19,10 @@ WORKDIR "/src/Tests/HtcMock/Server/src"
RUN dotnet publish -a "${TARGETARCH}" "ArmoniK.Samples.HtcMock.Server.csproj" -o /app/publish -p:RunAnalyzers=false -p:WarningLevel=0 -p:PackageVersion="$VERSION" -p:Version="$VERSION"

FROM base AS final
WORKDIR /
COPY --from=build --chown=$APP_UID:$APP_UID /cache /cache
WORKDIR /app
COPY --from=build /app/publish .
RUN groupadd --gid 5000 armonikuser && useradd --home-dir /home/armonikuser --create-home --uid 5000 --gid 5000 --shell /bin/sh --skel /dev/null armonikuser
RUN mkdir /cache && chown armonikuser: /cache
USER armonikuser
EXPOSE 1080
USER $APP_UID
ENTRYPOINT ["dotnet", "ArmoniK.Samples.HtcMock.Server.dll"]
10 changes: 6 additions & 4 deletions Tests/Stream/Server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled AS base
WORKDIR /app
ENV ASPNETCORE_URLS http://+:1080;https://+1443
EXPOSE 1080
Expand All @@ -10,6 +10,8 @@ FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG TARGETARCH
ARG VERSION=1.0.0.0

RUN mkdir /cache

WORKDIR /src
COPY ["Tests/Stream/Server/ArmoniK.Extensions.Common.StreamWrapper.Tests.Server.csproj", "Tests/Stream/Server/"]
COPY ["Tests/Stream/Common/ArmoniK.Extensions.Common.StreamWrapper.Tests.Common.csproj", "Tests/Stream/Common/"]
Expand All @@ -22,10 +24,10 @@ WORKDIR "/src/Tests/Stream/Server"
RUN dotnet publish -a "${TARGETARCH}" "ArmoniK.Extensions.Common.StreamWrapper.Tests.Server.csproj" --no-restore -o /app/publish -p:RunAnalyzers=false -p:WarningLevel=0 -p:PackageVersion="$VERSION" -p:Version="$VERSION"

FROM base AS final
WORKDIR /
COPY --from=build --chown=$APP_UID:$APP_UID /cache /cache
WORKDIR /app
COPY --from=build /app/publish .
RUN groupadd --gid 5000 armonikuser && useradd --home-dir /home/armonikuser --create-home --uid 5000 --gid 5000 --shell /bin/sh --skel /dev/null armonikuser
RUN mkdir /cache && chown armonikuser: /cache
USER armonikuser
USER $APP_UID

ENTRYPOINT ["dotnet", "ArmoniK.Extensions.Common.StreamWrapper.Tests.Server.dll"]

0 comments on commit 593cac2

Please sign in to comment.