From cd6fa44e625a7114572d2a31d3840fa0b159808e Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 29 Jan 2024 17:55:25 +0100 Subject: [PATCH] add docker support --- .dockerignore | 25 +++++++++++++++++++++++++ backend/MemeBE/Dockerfile | 23 +++++++++++++++++++++++ backend/MemeBE/MemeBE.csproj | 7 +++++++ 3 files changed, 55 insertions(+) create mode 100644 .dockerignore create mode 100644 backend/MemeBE/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cd967fc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/.idea +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md \ No newline at end of file diff --git a/backend/MemeBE/Dockerfile b/backend/MemeBE/Dockerfile new file mode 100644 index 0000000..1fc33d7 --- /dev/null +++ b/backend/MemeBE/Dockerfile @@ -0,0 +1,23 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER $APP_UID +WORKDIR /app +EXPOSE 8080 +EXPOSE 8081 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["backend/MemeBE/MemeBE.csproj", "backend/MemeBE/"] +RUN dotnet restore "backend/MemeBE/MemeBE.csproj" +COPY . . +WORKDIR "/src/backend/MemeBE" +RUN dotnet build "MemeBE.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "MemeBE.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "MemeBE.dll"] diff --git a/backend/MemeBE/MemeBE.csproj b/backend/MemeBE/MemeBE.csproj index 412f8c9..16a4185 100644 --- a/backend/MemeBE/MemeBE.csproj +++ b/backend/MemeBE/MemeBE.csproj @@ -5,6 +5,7 @@ enable enable true + Linux @@ -18,4 +19,10 @@ + + + .dockerignore + + +