From 811d1e3a9b0f9eeee1a779fe6f5cad88e1723de9 Mon Sep 17 00:00:00 2001 From: Lucca Santangelo <luccasant95@gmail.com> Date: Thu, 22 Oct 2020 17:11:55 -0300 Subject: [PATCH] remove https --- Tsi1.Api/.dockerignore | 2 ++ Tsi1.Api/Dockerfile | 23 +++++++++++++++++++ Tsi1.Api/Tsi1.Api/Program.cs | 1 + .../Tsi1.Api/Properties/launchSettings.json | 2 +- Tsi1.Api/Tsi1.Api/Startup.cs | 2 +- 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 Tsi1.Api/.dockerignore create mode 100644 Tsi1.Api/Dockerfile diff --git a/Tsi1.Api/.dockerignore b/Tsi1.Api/.dockerignore new file mode 100644 index 0000000..2e9693e --- /dev/null +++ b/Tsi1.Api/.dockerignore @@ -0,0 +1,2 @@ +obj +bin \ No newline at end of file diff --git a/Tsi1.Api/Dockerfile b/Tsi1.Api/Dockerfile new file mode 100644 index 0000000..bf550e5 --- /dev/null +++ b/Tsi1.Api/Dockerfile @@ -0,0 +1,23 @@ +# https://hub.docker.com/_/microsoft-dotnet-core +FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build +WORKDIR /app +EXPOSE 443 + +# copy csproj and restore as distinct layers +WORKDIR /src +COPY Tsi1.Api/*.csproj ./Tsi1.Api/ +COPY Tsi1.BusinessLayer/*.csproj ./Tsi1.BusinessLayer/ +COPY Tsi1.DataLayer/*.csproj ./Tsi1.DataLayer/ +RUN dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p 111111 +RUN dotnet restore ./Tsi1.Api/Tsi1.Api.csproj + +# copy everything else and build app +COPY . ./ +WORKDIR /src/Tsi1.Api +RUN dotnet publish -c release -o /app/publish + +# final stage/image +FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 +WORKDIR /app +COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "Tsi1.Api.dll"] \ No newline at end of file diff --git a/Tsi1.Api/Tsi1.Api/Program.cs b/Tsi1.Api/Tsi1.Api/Program.cs index 50e6716..e864adf 100644 --- a/Tsi1.Api/Tsi1.Api/Program.cs +++ b/Tsi1.Api/Tsi1.Api/Program.cs @@ -21,6 +21,7 @@ namespace Tsi1.Api .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); + webBuilder.UseUrls("http://*:5000/"); }); } } diff --git a/Tsi1.Api/Tsi1.Api/Properties/launchSettings.json b/Tsi1.Api/Tsi1.Api/Properties/launchSettings.json index c733fd6..b1df540 100644 --- a/Tsi1.Api/Tsi1.Api/Properties/launchSettings.json +++ b/Tsi1.Api/Tsi1.Api/Properties/launchSettings.json @@ -21,7 +21,7 @@ "commandName": "Project", "launchBrowser": true, "launchUrl": "swagger/index.html", - "applicationUrl": "https://localhost:5001;http://localhost:5000", + "applicationUrl": "http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/Tsi1.Api/Tsi1.Api/Startup.cs b/Tsi1.Api/Tsi1.Api/Startup.cs index 8dd2b59..91a2dfc 100644 --- a/Tsi1.Api/Tsi1.Api/Startup.cs +++ b/Tsi1.Api/Tsi1.Api/Startup.cs @@ -104,7 +104,7 @@ namespace Tsi1.Api app.UseDeveloperExceptionPage(); } - app.UseHttpsRedirection(); + // app.UseHttpsRedirection(); app.UseSwagger(); app.UseSwaggerUI(c => -- GitLab