|
1 | | -# use ASP.NET Core 9.0 runtime image as base |
2 | | -FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base |
| 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 | 3 | WORKDIR /app |
4 | 4 | EXPOSE 8080 |
5 | 5 |
|
6 | | -# use SDK image for build |
7 | | -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build |
| 6 | +# use SDK image (Alpine) for build |
| 7 | +FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build |
8 | 8 | WORKDIR /src |
9 | 9 |
|
10 | | -# copy project files to restore dependencies |
| 10 | +# copy only csproj and sln to restore as early as possible |
11 | 11 | COPY ["Source/Vinder.Federation.WebApi/Vinder.Federation.WebApi.csproj", "Vinder.Federation.WebApi/"] |
12 | | - |
13 | | -# copy the entire solution 'n related projects |
14 | 12 | COPY ["Vinder.Federation.sln", "./"] |
15 | 13 |
|
16 | | -# restore dependencies for the project |
| 14 | +# restore dependencies |
17 | 15 | RUN dotnet restore "Vinder.Federation.WebApi/Vinder.Federation.WebApi.csproj" |
18 | 16 |
|
19 | | -# copy all source code into the container |
| 17 | +# copy the rest of the source code |
20 | 18 | COPY Source/ ./Source/ |
21 | 19 |
|
22 | | -# set working directory to the web project |
23 | 20 | WORKDIR "/src/Source/Vinder.Federation.WebApi" |
24 | 21 |
|
25 | 22 | # build in Release mode |
26 | 23 | RUN dotnet build "Vinder.Federation.WebApi.csproj" -c Release -o /app/build |
27 | 24 |
|
28 | 25 | # publish the project for production |
29 | | -FROM build AS publish |
30 | 26 | RUN dotnet publish "Vinder.Federation.WebApi.csproj" -c Release -o /app/publish /p:UseAppHost=false |
31 | 27 |
|
32 | 28 | # final image to run the app |
33 | 29 | FROM base AS final |
34 | 30 | WORKDIR /app |
35 | 31 |
|
36 | | -# copy published files from the publish stage |
37 | | -COPY --from=publish /app/publish . |
| 32 | +ENV ASPNETCORE_URLS=http://+:8080 |
| 33 | +ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true |
| 34 | + |
| 35 | +# copy published files from the build stage |
| 36 | +COPY --from=build /app/publish . |
38 | 37 |
|
39 | | -# set the command to start the application |
40 | 38 | ENTRYPOINT ["dotnet", "Vinder.Federation.WebApi.dll"] |
0 commit comments