Skip to content

Commit f1a6334

Browse files
committed
Refactor Dockerfile to streamline build and runtime stages, and set default ASP.NET port for .NET 8.0
1 parent 01bea2b commit f1a6334

File tree

1 file changed

+7
-16
lines changed
  • src/Application/src/RazorPagesTestSample

1 file changed

+7
-16
lines changed
Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
1-
# Use the official .NET 8 SDK image as a build stage
2-
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
3-
4-
# Set the working directory
1+
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
52
WORKDIR /app
63

7-
# Copy the project file and restore dependencies
4+
# Copy csproj and restore as distinct layers
85
COPY *.csproj ./
96
RUN dotnet restore
107

11-
# Copy the rest of the application code
8+
# Copy everything else and build
129
COPY . ./
13-
14-
# Build the application
1510
RUN dotnet publish -c Release -o out
1611

17-
# Use the official .NET 8 runtime image as a runtime stage
12+
# Build runtime image
1813
FROM mcr.microsoft.com/dotnet/aspnet:8.0
19-
20-
# Set the working directory
2114
WORKDIR /app
22-
23-
# Copy the built application from the build stage
24-
COPY --from=build /app/out .
25-
26-
# Set the entry point for the application
15+
COPY --from=build-env /app/out .
16+
# Default ASP.NET port changed with .NET 8.0
17+
ENV ASPNETCORE_HTTP_PORTS=80
2718
ENTRYPOINT ["dotnet", "RazorPagesTestSample.dll"]

0 commit comments

Comments
 (0)