From 254a80eef42c80eb31747ee79b634dcf8a40b5bf Mon Sep 17 00:00:00 2001 From: Baligh Hatem Mehrez Date: Thu, 8 Jun 2023 17:02:18 +0300 Subject: [PATCH] creating file: Dockerfile --- Dockerfile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..0008a88a7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder +WORKDIR /app + +# caches restore result by copying csproj file separately +COPY *.csproj . +RUN dotnet restore + +COPY . . +RUN dotnet publish --output /app/ --configuration Release --no-restore +RUN sed -n 's:.*\(.*\).*:\1:p' *.csproj > __assemblyname +RUN if [ ! -s __assemblyname ]; then filename=$(ls *.csproj); echo ${filename%.*} > __assemblyname; fi + +# Stage 2 +FROM mcr.microsoft.com/dotnet/aspnet:7.0 +WORKDIR /app +COPY --from=builder /app . + +ENV PORT 5000 +EXPOSE 5000 + +ENTRYPOINT dotnet $(cat /app/__assemblyname).dll --urls "http://*:5000"