Skip to content

Commit b995e0f

Browse files
feat: this commit introduces dockerfile and .dockerignore for proxy application
1 parent 8046f07 commit b995e0f

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

Applications/Proxy/.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/.vs
2+
**/.git
3+
4+
**/bin
5+
**/obj
6+
**/.vscode
7+
**/TestResults
8+
9+
**/appsettings.json
10+
**/appsettings.Development.json
11+
**/appsettings.*.json
12+
13+
.env
14+
.env.*
15+
.env.example
16+
17+
*.user
18+
*.suo
19+
*.userosscache
20+
*.sln.docstates
21+
.gitattributes
22+
23+
Dockerfile
24+
README.md
25+
LICENSE

Applications/Proxy/Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# use ASP.NET Core 9.0 runtime image (alpine) as base
2+
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine AS base
3+
WORKDIR /artifacts
4+
EXPOSE 8080
5+
6+
# use SDK image (Alpine) for build
7+
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build
8+
WORKDIR /workdir
9+
10+
ARG BUILD_CONFIGURATION=Release
11+
ARG SOLUTION=HttpsRichardy.Federation.Proxy
12+
13+
# copy only csproj and sln to restore as early as possible
14+
COPY ["Source/${SOLUTION}.WebApi/${SOLUTION}.WebApi.csproj", "${SOLUTION}.WebApi/"]
15+
COPY ["${SOLUTION}.sln", "./"]
16+
17+
# restore dependencies
18+
RUN dotnet restore "${SOLUTION}.WebApi/${SOLUTION}.WebApi.csproj"
19+
20+
# copy the rest of the source code
21+
COPY Source/ ./Source/
22+
23+
WORKDIR "/workdir/Source/${SOLUTION}.WebApi"
24+
25+
# build in Release mode
26+
RUN dotnet build "${SOLUTION}.WebApi.csproj" -c $BUILD_CONFIGURATION -o /artifacts/build
27+
28+
# publish the project for production
29+
RUN dotnet publish "${SOLUTION}.WebApi.csproj" -c $BUILD_CONFIGURATION -o /artifacts/publish /p:UseAppHost=false
30+
31+
# final image to run the app
32+
FROM base AS final
33+
WORKDIR /artifacts
34+
35+
ENV ASPNETCORE_URLS=http://+:8080
36+
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true
37+
ENV DOTNET_RUNNING_IN_CONTAINER=true
38+
39+
# copy published files from the build stage
40+
COPY --from=build /artifacts/publish .
41+
42+
ENTRYPOINT ["dotnet", "HttpsRichardy.Federation.Proxy.WebApi.dll"]

0 commit comments

Comments
 (0)