Skip to content

Commit c189696

Browse files
committed
fix DockerFile
1 parent f8fb129 commit c189696

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

Dockerfile

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1-
# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
2-
3-
# This stage is used when running from VS in fast mode (Default for Debug configuration)
4-
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
5-
USER $APP_UID
6-
WORKDIR /app
7-
EXPOSE 8080
8-
EXPOSE 8081
9-
10-
11-
# This stage is used to build the service project
1+
# Build stage
122
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
133
ARG BUILD_CONFIGURATION=Release
144
WORKDIR /src
15-
COPY ["eAuthor.API/eAuthor.API.csproj", "eAuthor.API/"]
16-
RUN dotnet restore "./eAuthor.API/eAuthor.API.csproj"
5+
6+
# Copy project file(s) and restore as distinct layers for better caching
7+
COPY ["src/eAuthor.API/eAuthor.API.csproj", "src/eAuthor.API/"]
8+
RUN dotnet restore "src/eAuthor.API/eAuthor.API.csproj"
9+
10+
# Copy the rest of the source
1711
COPY . .
18-
WORKDIR "/src/eAuthor.API"
19-
RUN dotnet build "./eAuthor.API.csproj" -c $BUILD_CONFIGURATION -o /app/build
2012

21-
# This stage is used to publish the service project to be copied to the final stage
13+
# Build
14+
WORKDIR "/src/src/eAuthor.API"
15+
RUN dotnet build "eAuthor.API.csproj" -c $BUILD_CONFIGURATION -o /app/build
16+
17+
# Publish stage
2218
FROM build AS publish
2319
ARG BUILD_CONFIGURATION=Release
24-
RUN dotnet publish "./eAuthor.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
20+
RUN dotnet publish "eAuthor.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
2521

26-
# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
27-
FROM base AS final
22+
# Runtime stage
23+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final
2824
WORKDIR /app
25+
26+
# Kestrel will listen on 8080
27+
ENV ASPNETCORE_URLS=http://+:8080
28+
EXPOSE 8080
29+
30+
# If you want to run as non-root, uncomment the next line (aspnet image includes 'app' user)
31+
# USER app
32+
2933
COPY --from=publish /app/publish .
3034
ENTRYPOINT ["dotnet", "eAuthor.API.dll"]

0 commit comments

Comments
 (0)