From 734e360f04df29e5a044b2d5631788367fb712d5 Mon Sep 17 00:00:00 2001 From: omid Date: Sat, 2 Oct 2021 20:16:49 +0330 Subject: [PATCH] add docker file to run on docker. --- .dockerignore | 25 ++++++++++++++++++++ src/Web/Api/Api.csproj | 4 ++-- src/Web/Api/Dockerfile | 27 ++++++++++++++++++++++ src/Web/Api/Properties/launchSettings.json | 9 +++++++- 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 src/Web/Api/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3729ff0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*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/src/Web/Api/Api.csproj b/src/Web/Api/Api.csproj index c21c409..4cd3f2b 100644 --- a/src/Web/Api/Api.csproj +++ b/src/Web/Api/Api.csproj @@ -8,11 +8,11 @@ - + - + diff --git a/src/Web/Api/Dockerfile b/src/Web/Api/Dockerfile new file mode 100644 index 0000000..f0e77d7 --- /dev/null +++ b/src/Web/Api/Dockerfile @@ -0,0 +1,27 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build +WORKDIR /src +COPY ["src/Web/Api/Api.csproj", "src/Web/Api/"] +COPY ["src/Web/ApiFramework/ApiFramework.csproj", "src/Web/ApiFramework/"] +COPY ["src/Infrastructure/Persistance/Persistance.csproj", "src/Infrastructure/Persistance/"] +COPY ["src/Core/Domain/Domain.csproj", "src/Core/Domain/"] +COPY ["src/Core/Application/Application.csproj", "src/Core/Application/"] +COPY ["src/Common/Common.csproj", "src/Common/"] +RUN dotnet restore "src/Web/Api/Api.csproj" +COPY . . +WORKDIR "/src/src/Web/Api" +RUN dotnet build "Api.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "Api.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Api.dll"] \ No newline at end of file diff --git a/src/Web/Api/Properties/launchSettings.json b/src/Web/Api/Properties/launchSettings.json index 6512274..06f7080 100644 --- a/src/Web/Api/Properties/launchSettings.json +++ b/src/Web/Api/Properties/launchSettings.json @@ -25,6 +25,13 @@ "ASPNETCORE_ENVIRONMENT": "Development" }, "applicationUrl": "https://localhost:5001;http://localhost:5000" - } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", + "publishAllPorts": true, + "useSSL": true + } } } \ No newline at end of file