Skip to content

Commit cfe98de

Browse files
committed
RE1-T119 Migrating to Docker Hardened Images
1 parent 4546687 commit cfe98de

6 files changed

Lines changed: 46 additions & 38 deletions

File tree

Web/Resgrid.Web.Eventing/Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
22
ARG BUILD_VERSION=3.5.0
33

4-
FROM mcr.microsoft.com/dotnet/aspnet:9.0.3-noble-amd64 AS base
4+
#FROM mcr.microsoft.com/dotnet/runtime:9.0.3-noble-amd64 AS base
5+
FROM dhi.io/dotnet:9.0.16-debian13 AS base
56
ARG BUILD_VERSION
67
WORKDIR /app
78
EXPOSE 80
89

9-
FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build
10+
#FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build
11+
FROM dhi.io/dotnet:9.0.314-sdk-debian13 AS build
1012
ARG BUILD_VERSION
1113
WORKDIR /src
1214
COPY ["Web/Resgrid.Web.Eventing/Resgrid.Web.Eventing.csproj", "Web/Resgrid.Web.Eventing/"]
@@ -24,12 +26,11 @@ WORKDIR "/src/Web/Resgrid.Web.Eventing"
2426
FROM build AS publish
2527
ARG BUILD_VERSION
2628
RUN dotnet publish "Resgrid.Web.Eventing.csproj" -c Release -o /app/publish -p:Version=${BUILD_VERSION}
29+
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait /app/publish/wait
30+
RUN chmod +x /app/publish/wait
2731

2832
FROM base AS final
29-
## Add the wait script to the image
30-
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait wait
31-
RUN chmod +x wait
32-
3333
WORKDIR /app
3434
COPY --from=publish /app/publish .
35-
ENTRYPOINT ["sh", "-c", "./wait && dotnet Resgrid.Web.Eventing.dll"]
35+
ENTRYPOINT ["./wait"]
36+
CMD ["dotnet", "Resgrid.Web.Eventing.dll"]

Web/Resgrid.Web.Mcp/Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
ARG BUILD_VERSION=3.5.0
44

5-
FROM mcr.microsoft.com/dotnet/aspnet:9.0.3-noble-amd64 AS base
5+
#FROM mcr.microsoft.com/dotnet/runtime:9.0.3-noble-amd64 AS base
6+
FROM dhi.io/dotnet:9.0.16-debian13 AS base
67
ARG BUILD_VERSION
78
WORKDIR /app
89
EXPOSE 8080
910

10-
FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build
11+
#FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build
12+
FROM dhi.io/dotnet:9.0.314-sdk-debian13 AS build
1113
ARG BUILD_VERSION
1214
WORKDIR /src
1315
COPY ["Web/Resgrid.Web.Mcp/Resgrid.Web.Mcp.csproj", "Web/Resgrid.Web.Mcp/"]
@@ -35,13 +37,11 @@ WORKDIR "/src/Web/Resgrid.Web.Mcp"
3537
FROM build AS publish
3638
ARG BUILD_VERSION
3739
RUN dotnet publish "Resgrid.Web.Mcp.csproj" -c Release -o /app/publish -p:Version=${BUILD_VERSION}
40+
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait /app/publish/wait
41+
RUN chmod +x /app/publish/wait
3842

3943
FROM base AS final
40-
## Add the wait script to the image
41-
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait wait
42-
RUN chmod +x wait
43-
4444
WORKDIR /app
4545
COPY --from=publish /app/publish .
46-
47-
ENTRYPOINT ["sh", "-c", "./wait && dotnet Resgrid.Web.Mcp.dll"]
46+
ENTRYPOINT ["./wait"]
47+
CMD ["dotnet", "Resgrid.Web.Mcp.dll"]

Web/Resgrid.Web.Services/Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
ARG BUILD_VERSION=3.5.0
44

5-
FROM mcr.microsoft.com/dotnet/aspnet:9.0.3-noble-amd64 AS base
5+
#FROM mcr.microsoft.com/dotnet/runtime:9.0.3-noble-amd64 AS base
6+
FROM dhi.io/dotnet:9.0.16-debian13 AS base
67
ARG BUILD_VERSION
78
WORKDIR /app
89
EXPOSE 80
910

10-
FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build
11+
#FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build
12+
FROM dhi.io/dotnet:9.0.314-sdk-debian13 AS build
1113
ARG BUILD_VERSION
1214
WORKDIR /src
1315
COPY ["Web/Resgrid.Web.Services/Resgrid.Web.Services.csproj", "Web/Resgrid.Web.Services/"]
@@ -35,12 +37,11 @@ WORKDIR "/src/Web/Resgrid.Web.Services"
3537
FROM build AS publish
3638
ARG BUILD_VERSION
3739
RUN dotnet publish "Resgrid.Web.Services.csproj" -c Release -o /app/publish -p:Version=${BUILD_VERSION}
40+
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait /app/publish/wait
41+
RUN chmod +x /app/publish/wait
3842

3943
FROM base AS final
40-
## Add the wait script to the image
41-
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait wait
42-
RUN chmod +x wait
43-
4444
WORKDIR /app
4545
COPY --from=publish /app/publish .
46-
ENTRYPOINT ["sh", "-c", "./wait && dotnet Resgrid.Web.Services.dll"]
46+
ENTRYPOINT ["./wait"]
47+
CMD ["dotnet", "Resgrid.Web.Services.dll"]

Web/Resgrid.Web.Tts/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
ARG BUILD_VERSION=3.5.0
22

3-
FROM mcr.microsoft.com/dotnet/aspnet:9.0.3-noble-amd64 AS base
3+
#FROM mcr.microsoft.com/dotnet/runtime:9.0.3-noble-amd64 AS base
4+
FROM dhi.io/dotnet:9.0.16-debian13 AS base
45
ARG BUILD_VERSION
56
WORKDIR /app
67
EXPOSE 8080
78

8-
FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build
9+
#FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build
10+
FROM dhi.io/dotnet:9.0.314-sdk-debian13 AS build
911
ARG BUILD_VERSION
1012
WORKDIR /src
1113

@@ -64,4 +66,4 @@ COPY --from=build /app/publish .
6466

6567
ENV ASPNETCORE_URLS=http://+:8080
6668
USER appuser
67-
ENTRYPOINT ["dotnet", "Resgrid.Web.Tts.dll"]
69+
ENTRYPOINT ["dotnet", "Resgrid.Web.Tts.dll"]

Web/Resgrid.Web/Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
22
ARG BUILD_VERSION=3.5.0
33

4-
FROM mcr.microsoft.com/dotnet/aspnet:9.0.3-noble-amd64 AS base
4+
#FROM mcr.microsoft.com/dotnet/aspnet:9.0.3-noble-amd64 AS base
5+
FROM dhi.io/aspnetcore:9.0.16-debian13 AS base
56
ARG BUILD_VERSION
67
WORKDIR /app
78
EXPOSE 80
89

910
#FROM node:18.19-alpine3.19 AS node_base
10-
FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build
11+
#FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build
12+
FROM dhi.io/dotnet:9.0.314-sdk-debian13 AS build
1113
#RUN apt-get update && apt-get install nodejs
1214
#COPY --from=node_base . .
1315
#COPY --from=node_base /usr/lib /usr/lib
@@ -52,12 +54,12 @@ ENV PATH="${PATH}:/root/.dotnet/tools"
5254
RUN for i in 1 2 3; do libman restore && break || { echo "libman restore attempt $i failed, retrying..."; sleep 10; }; done
5355
ENV SKIP_LIBMAN_RESTORE=1
5456
RUN dotnet publish "Resgrid.Web.csproj" -c Release -o /app/publish -p:Version=${BUILD_VERSION}
57+
## Download the wait script in the build stage where a shell is available
58+
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait /app/publish/wait
59+
RUN chmod +x /app/publish/wait
5560

5661
FROM base AS final
57-
## Add the wait script to the image
58-
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait wait
59-
RUN chmod +x wait
60-
6162
WORKDIR /app
6263
COPY --from=publish /app/publish .
63-
ENTRYPOINT ["sh", "-c", "./wait && dotnet Resgrid.Web.dll"]
64+
ENTRYPOINT ["./wait"]
65+
CMD ["dotnet", "Resgrid.Web.dll"]

Workers/Resgrid.Workers.Console/Dockerfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
22
ARG BUILD_VERSION=3.5.0
33

4-
FROM mcr.microsoft.com/dotnet/runtime:9.0.3-noble-amd64 AS base
4+
#FROM mcr.microsoft.com/dotnet/runtime:9.0.3-noble-amd64 AS base
5+
FROM dhi.io/dotnet:9.0.16-debian13 AS base
56
ARG BUILD_VERSION
67
WORKDIR /app
78

8-
FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build
9+
#FROM mcr.microsoft.com/dotnet/sdk:9.0.202-noble-amd64 AS build
10+
FROM dhi.io/dotnet:9.0.314-sdk-debian13 AS build
911
ARG BUILD_VERSION
1012
WORKDIR /src
1113

@@ -35,11 +37,10 @@ WORKDIR "/src/Workers/Resgrid.Workers.Console"
3537
FROM build AS publish
3638
ARG BUILD_VERSION
3739
RUN dotnet publish "Resgrid.Workers.Console.csproj" -c Release -o /app/publish -p:Version=${BUILD_VERSION}
40+
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait /app/publish/wait
41+
RUN chmod +x /app/publish/wait
3842

3943
FROM base AS final
40-
## Add the wait script to the image
41-
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait wait
42-
RUN chmod +x wait
4344

4445
WORKDIR /app
4546

@@ -65,4 +66,5 @@ RUN set -xe \
6566

6667
COPY --from=publish /app/publish .
6768

68-
ENTRYPOINT ["sh", "-c", "./wait && dotnet Resgrid.Workers.Console.dll"]
69+
ENTRYPOINT ["./wait"]
70+
CMD ["dotnet", "Resgrid.Workers.Console.dll"]

0 commit comments

Comments
 (0)