-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathDockerfile.dotnet
More file actions
34 lines (26 loc) · 1.06 KB
/
Dockerfile.dotnet
File metadata and controls
34 lines (26 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Stage 1: Build the application
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
# Copy the project files
COPY ["dotnet/Contoso.BlazorApp/Contoso.BlazorApp.csproj", "Contoso.BlazorApp/"]
RUN dotnet restore "Contoso.BlazorApp/Contoso.BlazorApp.csproj"
# Copy the rest of the application code
COPY ["dotnet/Contoso.BlazorApp/", "Contoso.BlazorApp/"]
# Build the application
WORKDIR "/src/Contoso.BlazorApp"
RUN dotnet build "Contoso.BlazorApp.csproj" -c Release -o /app/build
# Stage 2: Publish the application
FROM build AS publish
RUN dotnet publish "Contoso.BlazorApp.csproj" -c Release -o /app/publish /p:UseAppHost=false
# Stage 3: Final stage with the runtime image
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final
WORKDIR /app
EXPOSE 8080
# Set the environment variables
ENV ASPNETCORE_URLS=http://+:8080
ENV DOTNET_RUNNING_IN_CONTAINER=true
ENV ApiSettings__BaseUrl="${ApiSettings__BaseUrl}"
# Copy the published files from the build stage
COPY --from=publish /app/publish .
# Set the entry point for the container
ENTRYPOINT ["dotnet", "Contoso.BlazorApp.dll"]