forked from microsoft/github-copilot-vibe-coding-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.dotnet
More file actions
33 lines (25 loc) · 1 KB
/
Copy pathDockerfile.dotnet
File metadata and controls
33 lines (25 loc) · 1 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
# Stage 1: Build the application
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
# Copy the project files
COPY ["dotnet/ContosoSnsWebApp/ContosoSnsWebApp.csproj", "ContosoSnsWebApp/"]
RUN dotnet restore "ContosoSnsWebApp/ContosoSnsWebApp.csproj"
# Copy the rest of the application code
COPY ["dotnet/ContosoSnsWebApp/", "ContosoSnsWebApp/"]
# Build the application
WORKDIR "/src/ContosoSnsWebApp"
RUN dotnet build "ContosoSnsWebApp.csproj" -c Release -o /app/build
# Stage 2: Publish the application
FROM build AS publish
RUN dotnet publish "ContosoSnsWebApp.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
# Copy the published files from the build stage
COPY --from=publish /app/publish .
# Set the entry point for the container
ENTRYPOINT ["dotnet", "ContosoSnsWebApp.dll"]