Skip to content
Snippets Groups Projects
Commit a539f643 authored by Lucca Santangelo Dodera's avatar Lucca Santangelo Dodera
Browse files

Merge branch 'feature/remove-https' into 'master'

remove https and docker

See merge request !6
parents 165c6239 f934cca1
No related branches found
No related tags found
1 merge request!6remove https and docker
obj
bin
\ No newline at end of file
# https://hub.docker.com/_/microsoft-dotnet-core
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /app
EXPOSE 5000
# 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
......@@ -21,6 +21,7 @@ namespace Tsi1.Api
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.UseUrls("http://*:5000/");
});
}
}
......@@ -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"
}
......
......@@ -40,10 +40,15 @@ namespace Tsi1.Api
{
services.AddControllers();
services.AddDbContext<Tsi1Context>(x => x.UseNpgsql(Configuration.GetConnectionString("PostgreSql")));
var isElasticCloud = bool.Parse(Configuration.GetSection("IsElasticCloud").Value);
var postgreSqlSection = isElasticCloud ? "PostgreSqlCloud" : "PostgreSql";
var mongoDbSection = isElasticCloud ? "Tsi1DatabaseSettingsCloud" : "Tsi1DatabaseSettings";
services.AddDbContext<Tsi1Context>(x => x.UseNpgsql(Configuration.GetConnectionString(postgreSqlSection)));
services.Configure<Tsi1DatabaseSettings>(
Configuration.GetSection(nameof(Tsi1DatabaseSettings)));
Configuration.GetSection(mongoDbSection));
services.AddSingleton<ITsi1DatabaseSettings>(sp =>
sp.GetRequiredService<IOptions<Tsi1DatabaseSettings>>().Value);
......@@ -131,7 +136,7 @@ namespace Tsi1.Api
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
// app.UseHttpsRedirection();
app.UseSwagger();
app.UseSwaggerUI(c =>
......
{
"IsElasticCloud": true,
"ConnectionStrings": {
"PostgreSql": "Host=localhost;Database=tsi1;Username=postgres;Password=111111"
"PostgreSql": "Host=localhost;Database=tsi1;Username=postgres;Password=111111",
"PostgreSqlCloud": "Host=postgres;Database=tsi1;Username=postgres;Password=postgres"
},
"Tsi1DatabaseSettings": {
"Tsi1CollectionName": "Messages",
"ConnectionString": "mongodb://localhost:27017",
"DatabaseName": "Tsi1Db"
},
"Tsi1DatabaseSettingsCloud": {
"Tsi1CollectionName": "Messages",
"ConnectionString": "mongodb://mongo:27017",
"DatabaseName": "Tsi1Db"
},
"jwtTokenConfig": {
"secret": "1234567890123456789",
"issuer": "https://localhost:44363",
"audience": "https://localhost:44363",
"issuer": "https://localhost:5000",
"audience": "https://localhost:5000",
"accessTokenExpiration": 20,
"refreshTokenExpiration": 60
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment