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

docker

parent 0e77295d
No related branches found
No related tags found
1 merge request!6remove https and docker
# https://hub.docker.com/_/microsoft-dotnet-core # https://hub.docker.com/_/microsoft-dotnet-core
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /app WORKDIR /app
EXPOSE 443 EXPOSE 5000
# copy csproj and restore as distinct layers # copy csproj and restore as distinct layers
WORKDIR /src WORKDIR /src
......
...@@ -40,10 +40,15 @@ namespace Tsi1.Api ...@@ -40,10 +40,15 @@ namespace Tsi1.Api
{ {
services.AddControllers(); 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>( services.Configure<Tsi1DatabaseSettings>(
Configuration.GetSection(nameof(Tsi1DatabaseSettings))); Configuration.GetSection(mongoDbSection));
services.AddSingleton<ITsi1DatabaseSettings>(sp => services.AddSingleton<ITsi1DatabaseSettings>(sp =>
sp.GetRequiredService<IOptions<Tsi1DatabaseSettings>>().Value); sp.GetRequiredService<IOptions<Tsi1DatabaseSettings>>().Value);
......
{ {
"IsElasticCloud": true,
"ConnectionStrings": { "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": { "Tsi1DatabaseSettings": {
"Tsi1CollectionName": "Messages", "Tsi1CollectionName": "Messages",
"ConnectionString": "mongodb://localhost:27017", "ConnectionString": "mongodb://localhost:27017",
"DatabaseName": "Tsi1Db" "DatabaseName": "Tsi1Db"
}, },
"Tsi1DatabaseSettingsCloud": {
"Tsi1CollectionName": "Messages",
"ConnectionString": "mongodb://mongo:27017",
"DatabaseName": "Tsi1Db"
},
"jwtTokenConfig": { "jwtTokenConfig": {
"secret": "1234567890123456789", "secret": "1234567890123456789",
"issuer": "https://localhost:44363", "issuer": "https://localhost:5000",
"audience": "https://localhost:44363", "audience": "https://localhost:5000",
"accessTokenExpiration": 20, "accessTokenExpiration": 20,
"refreshTokenExpiration": 60 "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