-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
35 lines (27 loc) · 995 Bytes
/
Dockerfile
File metadata and controls
35 lines (27 loc) · 995 Bytes
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
35
# Use the official .NET 10 runtime as the base image
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
# Install curl for health checks
RUN apt-get update && apt-get install --no-install-recommends -y curl && rm -rf /var/lib/apt/lists/*
# Use the official .NET 10 SDK image for building
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
# Copy project files and Directory.Build.props first for better caching
COPY ["Directory.Build.props", "."]
COPY ["global.json", "."]
COPY ["UserApi.csproj", "."]
COPY ["UserApi.Tests/UserApi.Tests.csproj", "UserApi.Tests/"]
# Restore dependencies
RUN dotnet restore "./UserApi.csproj"
# Copy source code
COPY . .
# Build the project
RUN dotnet build "UserApi.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "UserApi.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "UserApi.dll"]