Skip to content

Commit 4cd45c8

Browse files
refactor: update dockerfile to use consistent working directories and output paths
1 parent f20bf82 commit 4cd45c8

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# use ASP.NET Core 9.0 runtime image (alpine) as base
22
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine AS base
3-
WORKDIR /app
3+
WORKDIR /artifacts
44
EXPOSE 8080
55

66
# use SDK image (Alpine) for build
77
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build
8-
WORKDIR /src
8+
WORKDIR /workdir
99

1010
# copy only csproj and sln to restore as early as possible
1111
COPY ["Source/HttpsRichardy.Federation.WebApi/HttpsRichardy.Federation.WebApi.csproj", "HttpsRichardy.Federation.WebApi/"]
@@ -17,22 +17,22 @@ RUN dotnet restore "HttpsRichardy.Federation.WebApi/HttpsRichardy.Federation.Web
1717
# copy the rest of the source code
1818
COPY Source/ ./Source/
1919

20-
WORKDIR "/src/Source/HttpsRichardy.Federation.WebApi"
20+
WORKDIR "/workdir/Source/HttpsRichardy.Federation.WebApi"
2121

2222
# build in Release mode
23-
RUN dotnet build "HttpsRichardy.Federation.WebApi.csproj" -c Release -o /app/build
23+
RUN dotnet build "HttpsRichardy.Federation.WebApi.csproj" -c Release -o /artifacts/build
2424

2525
# publish the project for production
26-
RUN dotnet publish "HttpsRichardy.Federation.WebApi.csproj" -c Release -o /app/publish /p:UseAppHost=false
26+
RUN dotnet publish "HttpsRichardy.Federation.WebApi.csproj" -c Release -o /artifacts/publish /p:UseAppHost=false
2727

2828
# final image to run the app
2929
FROM base AS final
30-
WORKDIR /app
30+
WORKDIR /artifacts
3131

3232
ENV ASPNETCORE_URLS=http://+:8080
3333
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true
3434

3535
# copy published files from the build stage
36-
COPY --from=build /app/publish .
36+
COPY --from=build /artifacts/publish .
3737

3838
ENTRYPOINT ["dotnet", "HttpsRichardy.Federation.WebApi.dll"]

0 commit comments

Comments
 (0)