From 6ffc55f64e855f07498dce019a28bfffe7b1c4bb Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sun, 14 Nov 2021 15:35:09 +0100 Subject: [PATCH] Add production docker file for backend --- src/backend/server/{Todo/Todo.Api => }/Dockerfile | 15 +++++++++++---- src/backend/server/{Todo => }/Todo.sln | 6 +++--- src/backend/server/{Todo => }/global.json | 0 .../server/{Todo => src}/Todo.Api/.dockerignore | 0 .../Todo.Api/Controllers/AuthController.cs | 0 .../Todo.Api/Controllers/TodosController.cs | 0 .../Todo.Api/Hubs/Models/TodoResponse.cs | 0 .../server/{Todo => src}/Todo.Api/Hubs/TodoHub.cs | 0 .../server/{Todo => src}/Todo.Api/Program.cs | 0 .../Todo.Api/Properties/launchSettings.json | 0 .../server/{Todo => src}/Todo.Api/Startup.cs | 0 .../server/{Todo => src}/Todo.Api/Todo.Api.csproj | 0 .../Todo.Api/appsettings.Development.json | 0 .../{Todo => src}/Todo.Api/appsettings.json | 0 .../Todo.Core/DependencyInjection.cs | 0 .../{Todo => src}/Todo.Core/Entities/Todo.cs | 0 .../{Todo => src}/Todo.Core/Entities/User.cs | 0 .../Interfaces/Persistence/ITodoRepository.cs | 0 .../Interfaces/Persistence/IUserRepository.cs | 0 .../{Todo => src}/Todo.Core/Todo.Core.csproj | 0 .../Todo.Persistence/DependencyInjection.cs | 0 .../Todo.Persistence/Mongo/Migrations.cs | 0 .../Mongo/Repositories/Dtos/MongoTodo.cs | 0 .../Mongo/Repositories/Dtos/MongoUser.cs | 0 .../Mongo/Repositories/TodoRepository.cs | 0 .../Mongo/Repositories/UserRepository.cs | 0 .../Todo.Persistence/Todo.Persistence.csproj | 0 27 files changed, 14 insertions(+), 7 deletions(-) rename src/backend/server/{Todo/Todo.Api => }/Dockerfile (54%) rename src/backend/server/{Todo => }/Todo.sln (86%) rename src/backend/server/{Todo => }/global.json (100%) rename src/backend/server/{Todo => src}/Todo.Api/.dockerignore (100%) rename src/backend/server/{Todo => src}/Todo.Api/Controllers/AuthController.cs (100%) rename src/backend/server/{Todo => src}/Todo.Api/Controllers/TodosController.cs (100%) rename src/backend/server/{Todo => src}/Todo.Api/Hubs/Models/TodoResponse.cs (100%) rename src/backend/server/{Todo => src}/Todo.Api/Hubs/TodoHub.cs (100%) rename src/backend/server/{Todo => src}/Todo.Api/Program.cs (100%) rename src/backend/server/{Todo => src}/Todo.Api/Properties/launchSettings.json (100%) rename src/backend/server/{Todo => src}/Todo.Api/Startup.cs (100%) rename src/backend/server/{Todo => src}/Todo.Api/Todo.Api.csproj (100%) rename src/backend/server/{Todo => src}/Todo.Api/appsettings.Development.json (100%) rename src/backend/server/{Todo => src}/Todo.Api/appsettings.json (100%) rename src/backend/server/{Todo => src}/Todo.Core/DependencyInjection.cs (100%) rename src/backend/server/{Todo => src}/Todo.Core/Entities/Todo.cs (100%) rename src/backend/server/{Todo => src}/Todo.Core/Entities/User.cs (100%) rename src/backend/server/{Todo => src}/Todo.Core/Interfaces/Persistence/ITodoRepository.cs (100%) rename src/backend/server/{Todo => src}/Todo.Core/Interfaces/Persistence/IUserRepository.cs (100%) rename src/backend/server/{Todo => src}/Todo.Core/Todo.Core.csproj (100%) rename src/backend/server/{Todo => src}/Todo.Persistence/DependencyInjection.cs (100%) rename src/backend/server/{Todo => src}/Todo.Persistence/Mongo/Migrations.cs (100%) rename src/backend/server/{Todo => src}/Todo.Persistence/Mongo/Repositories/Dtos/MongoTodo.cs (100%) rename src/backend/server/{Todo => src}/Todo.Persistence/Mongo/Repositories/Dtos/MongoUser.cs (100%) rename src/backend/server/{Todo => src}/Todo.Persistence/Mongo/Repositories/TodoRepository.cs (100%) rename src/backend/server/{Todo => src}/Todo.Persistence/Mongo/Repositories/UserRepository.cs (100%) rename src/backend/server/{Todo => src}/Todo.Persistence/Todo.Persistence.csproj (100%) diff --git a/src/backend/server/Todo/Todo.Api/Dockerfile b/src/backend/server/Dockerfile similarity index 54% rename from src/backend/server/Todo/Todo.Api/Dockerfile rename to src/backend/server/Dockerfile index 247c1fa..21d696b 100644 --- a/src/backend/server/Todo/Todo.Api/Dockerfile +++ b/src/backend/server/Dockerfile @@ -5,11 +5,18 @@ EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src -COPY ["Todo.Api/Todo.Api.csproj", "Todo.Api/"] -RUN dotnet restore "Todo.Api/Todo.Api.csproj" + +COPY *.sln . +COPY ["src/Todo.Api/Todo.Api.csproj", "src/Todo.Api/"] +COPY ["src/Todo.Core/Todo.Core.csproj", "src/Todo.Core/"] +COPY ["src/Todo.Persistence/Todo.Persistence.csproj", "src/Todo.Persistence/"] + +RUN dotnet restore . + COPY . . -WORKDIR "/src/Todo.Api" -RUN dotnet build "Todo.Api.csproj" -c Release -o /app/build + +WORKDIR "src/Todo.Api" +RUN dotnet build . -c Release -o /app/build FROM build AS publish RUN dotnet publish "Todo.Api.csproj" -c Release -o /app/publish diff --git a/src/backend/server/Todo/Todo.sln b/src/backend/server/Todo.sln similarity index 86% rename from src/backend/server/Todo/Todo.sln rename to src/backend/server/Todo.sln index 814191a..fcd154c 100644 --- a/src/backend/server/Todo/Todo.sln +++ b/src/backend/server/Todo.sln @@ -1,10 +1,10 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Todo.Api", "Todo.Api\Todo.Api.csproj", "{FA037FDE-DAA4-4A95-ABA5-64DCFEDDBA4E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Todo.Api", "src\Todo.Api\Todo.Api.csproj", "{FA037FDE-DAA4-4A95-ABA5-64DCFEDDBA4E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Todo.Persistence", "Todo.Persistence\Todo.Persistence.csproj", "{7636E7CC-C9A5-41D4-BBFE-B107497A5C8A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Todo.Persistence", "src\Todo.Persistence\Todo.Persistence.csproj", "{7636E7CC-C9A5-41D4-BBFE-B107497A5C8A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Todo.Core", "Todo.Core\Todo.Core.csproj", "{F134CAB6-15A5-45CB-8782-B61AB67B5C9C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Todo.Core", "src\Todo.Core\Todo.Core.csproj", "{F134CAB6-15A5-45CB-8782-B61AB67B5C9C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/backend/server/Todo/global.json b/src/backend/server/global.json similarity index 100% rename from src/backend/server/Todo/global.json rename to src/backend/server/global.json diff --git a/src/backend/server/Todo/Todo.Api/.dockerignore b/src/backend/server/src/Todo.Api/.dockerignore similarity index 100% rename from src/backend/server/Todo/Todo.Api/.dockerignore rename to src/backend/server/src/Todo.Api/.dockerignore diff --git a/src/backend/server/Todo/Todo.Api/Controllers/AuthController.cs b/src/backend/server/src/Todo.Api/Controllers/AuthController.cs similarity index 100% rename from src/backend/server/Todo/Todo.Api/Controllers/AuthController.cs rename to src/backend/server/src/Todo.Api/Controllers/AuthController.cs diff --git a/src/backend/server/Todo/Todo.Api/Controllers/TodosController.cs b/src/backend/server/src/Todo.Api/Controllers/TodosController.cs similarity index 100% rename from src/backend/server/Todo/Todo.Api/Controllers/TodosController.cs rename to src/backend/server/src/Todo.Api/Controllers/TodosController.cs diff --git a/src/backend/server/Todo/Todo.Api/Hubs/Models/TodoResponse.cs b/src/backend/server/src/Todo.Api/Hubs/Models/TodoResponse.cs similarity index 100% rename from src/backend/server/Todo/Todo.Api/Hubs/Models/TodoResponse.cs rename to src/backend/server/src/Todo.Api/Hubs/Models/TodoResponse.cs diff --git a/src/backend/server/Todo/Todo.Api/Hubs/TodoHub.cs b/src/backend/server/src/Todo.Api/Hubs/TodoHub.cs similarity index 100% rename from src/backend/server/Todo/Todo.Api/Hubs/TodoHub.cs rename to src/backend/server/src/Todo.Api/Hubs/TodoHub.cs diff --git a/src/backend/server/Todo/Todo.Api/Program.cs b/src/backend/server/src/Todo.Api/Program.cs similarity index 100% rename from src/backend/server/Todo/Todo.Api/Program.cs rename to src/backend/server/src/Todo.Api/Program.cs diff --git a/src/backend/server/Todo/Todo.Api/Properties/launchSettings.json b/src/backend/server/src/Todo.Api/Properties/launchSettings.json similarity index 100% rename from src/backend/server/Todo/Todo.Api/Properties/launchSettings.json rename to src/backend/server/src/Todo.Api/Properties/launchSettings.json diff --git a/src/backend/server/Todo/Todo.Api/Startup.cs b/src/backend/server/src/Todo.Api/Startup.cs similarity index 100% rename from src/backend/server/Todo/Todo.Api/Startup.cs rename to src/backend/server/src/Todo.Api/Startup.cs diff --git a/src/backend/server/Todo/Todo.Api/Todo.Api.csproj b/src/backend/server/src/Todo.Api/Todo.Api.csproj similarity index 100% rename from src/backend/server/Todo/Todo.Api/Todo.Api.csproj rename to src/backend/server/src/Todo.Api/Todo.Api.csproj diff --git a/src/backend/server/Todo/Todo.Api/appsettings.Development.json b/src/backend/server/src/Todo.Api/appsettings.Development.json similarity index 100% rename from src/backend/server/Todo/Todo.Api/appsettings.Development.json rename to src/backend/server/src/Todo.Api/appsettings.Development.json diff --git a/src/backend/server/Todo/Todo.Api/appsettings.json b/src/backend/server/src/Todo.Api/appsettings.json similarity index 100% rename from src/backend/server/Todo/Todo.Api/appsettings.json rename to src/backend/server/src/Todo.Api/appsettings.json diff --git a/src/backend/server/Todo/Todo.Core/DependencyInjection.cs b/src/backend/server/src/Todo.Core/DependencyInjection.cs similarity index 100% rename from src/backend/server/Todo/Todo.Core/DependencyInjection.cs rename to src/backend/server/src/Todo.Core/DependencyInjection.cs diff --git a/src/backend/server/Todo/Todo.Core/Entities/Todo.cs b/src/backend/server/src/Todo.Core/Entities/Todo.cs similarity index 100% rename from src/backend/server/Todo/Todo.Core/Entities/Todo.cs rename to src/backend/server/src/Todo.Core/Entities/Todo.cs diff --git a/src/backend/server/Todo/Todo.Core/Entities/User.cs b/src/backend/server/src/Todo.Core/Entities/User.cs similarity index 100% rename from src/backend/server/Todo/Todo.Core/Entities/User.cs rename to src/backend/server/src/Todo.Core/Entities/User.cs diff --git a/src/backend/server/Todo/Todo.Core/Interfaces/Persistence/ITodoRepository.cs b/src/backend/server/src/Todo.Core/Interfaces/Persistence/ITodoRepository.cs similarity index 100% rename from src/backend/server/Todo/Todo.Core/Interfaces/Persistence/ITodoRepository.cs rename to src/backend/server/src/Todo.Core/Interfaces/Persistence/ITodoRepository.cs diff --git a/src/backend/server/Todo/Todo.Core/Interfaces/Persistence/IUserRepository.cs b/src/backend/server/src/Todo.Core/Interfaces/Persistence/IUserRepository.cs similarity index 100% rename from src/backend/server/Todo/Todo.Core/Interfaces/Persistence/IUserRepository.cs rename to src/backend/server/src/Todo.Core/Interfaces/Persistence/IUserRepository.cs diff --git a/src/backend/server/Todo/Todo.Core/Todo.Core.csproj b/src/backend/server/src/Todo.Core/Todo.Core.csproj similarity index 100% rename from src/backend/server/Todo/Todo.Core/Todo.Core.csproj rename to src/backend/server/src/Todo.Core/Todo.Core.csproj diff --git a/src/backend/server/Todo/Todo.Persistence/DependencyInjection.cs b/src/backend/server/src/Todo.Persistence/DependencyInjection.cs similarity index 100% rename from src/backend/server/Todo/Todo.Persistence/DependencyInjection.cs rename to src/backend/server/src/Todo.Persistence/DependencyInjection.cs diff --git a/src/backend/server/Todo/Todo.Persistence/Mongo/Migrations.cs b/src/backend/server/src/Todo.Persistence/Mongo/Migrations.cs similarity index 100% rename from src/backend/server/Todo/Todo.Persistence/Mongo/Migrations.cs rename to src/backend/server/src/Todo.Persistence/Mongo/Migrations.cs diff --git a/src/backend/server/Todo/Todo.Persistence/Mongo/Repositories/Dtos/MongoTodo.cs b/src/backend/server/src/Todo.Persistence/Mongo/Repositories/Dtos/MongoTodo.cs similarity index 100% rename from src/backend/server/Todo/Todo.Persistence/Mongo/Repositories/Dtos/MongoTodo.cs rename to src/backend/server/src/Todo.Persistence/Mongo/Repositories/Dtos/MongoTodo.cs diff --git a/src/backend/server/Todo/Todo.Persistence/Mongo/Repositories/Dtos/MongoUser.cs b/src/backend/server/src/Todo.Persistence/Mongo/Repositories/Dtos/MongoUser.cs similarity index 100% rename from src/backend/server/Todo/Todo.Persistence/Mongo/Repositories/Dtos/MongoUser.cs rename to src/backend/server/src/Todo.Persistence/Mongo/Repositories/Dtos/MongoUser.cs diff --git a/src/backend/server/Todo/Todo.Persistence/Mongo/Repositories/TodoRepository.cs b/src/backend/server/src/Todo.Persistence/Mongo/Repositories/TodoRepository.cs similarity index 100% rename from src/backend/server/Todo/Todo.Persistence/Mongo/Repositories/TodoRepository.cs rename to src/backend/server/src/Todo.Persistence/Mongo/Repositories/TodoRepository.cs diff --git a/src/backend/server/Todo/Todo.Persistence/Mongo/Repositories/UserRepository.cs b/src/backend/server/src/Todo.Persistence/Mongo/Repositories/UserRepository.cs similarity index 100% rename from src/backend/server/Todo/Todo.Persistence/Mongo/Repositories/UserRepository.cs rename to src/backend/server/src/Todo.Persistence/Mongo/Repositories/UserRepository.cs diff --git a/src/backend/server/Todo/Todo.Persistence/Todo.Persistence.csproj b/src/backend/server/src/Todo.Persistence/Todo.Persistence.csproj similarity index 100% rename from src/backend/server/Todo/Todo.Persistence/Todo.Persistence.csproj rename to src/backend/server/src/Todo.Persistence/Todo.Persistence.csproj