Update injection of values to frontend
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Simon 2021-10-03 02:08:31 +01:00
parent 90346cefda
commit a9e1baf7c3
6 changed files with 107 additions and 19 deletions

View File

@ -11,7 +11,7 @@ namespace ManagementPage.Database
private const string _accountsCollectionName = "Accounts";
private const string _deviceCollectionName = "Devices";
private const string _databaseName = "Environment";
private const string _uri = "mongodb://192.168.0.159:27017";
private readonly string _uri;
private readonly IMongoDatabase _database;
private readonly MongoClient _client;
@ -20,8 +20,9 @@ namespace ManagementPage.Database
public IMongoCollection<DeviceData> DeviceCollection { get; private set; }
public MongoDbClient()
public MongoDbClient(IConfiguration configRoot)
{
_uri = configRoot["mongodb:uri"];
_client = new MongoClient(_uri);
_database = _client.GetDatabase(_databaseName);
BsonClassMap.RegisterClassMap<EnvironmentData>(cm =>

View File

@ -6,6 +6,9 @@
<RazorPage_SelectedScaffolderID>RazorPageScaffolder</RazorPage_SelectedScaffolderID>
<RazorPage_SelectedScaffolderCategoryPath>root/Common/RazorPage</RazorPage_SelectedScaffolderCategoryPath>
<NameOfLastUsedPublishProfile>P:\EnvironmentManagement\ManagementPage\ManagementPage\Properties\PublishProfiles\registry.jacknet.io.pubxml</NameOfLastUsedPublishProfile>
<ActiveDebugProfile>Docker</ActiveDebugProfile>
<ActiveDebugProfile>ManagementPage</ActiveDebugProfile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

View File

@ -3,7 +3,7 @@
@{
ViewData["Title"] = "Error";
}
<div style="font-family:'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif">
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@ -12,15 +12,4 @@
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
}

View File

@ -6,6 +6,9 @@
"Microsoft.AspNetCore": "Warning"
}
},
"mongodb": {
"uri": "mongodb://192.168.0.159:27017"
},
"oidc": {
"region": "openid-connect",
"clientid": "51m0n-temperature",

View File

@ -2,14 +2,31 @@ version: "3.4"
services:
frontend:
image: registry.jacknet.io/51m0n/environment-frontend:latest
depends_on:
- database
environment:
- ASPNETCORE_oidc_region=openid-connect
- ASPNETCORE_oidc_clientid=51m0n-temperature
- ASPNETCORE_oidc_clientsecret=
- ASPNETCORE_mongodb_uri=mongodb://database:27017/
database:
image: mongodb:latest
image: mongo:latest
apiserver:
image: registry.jacknet.io/51m0n/environment-api:latest
environment:
- GIN_DB_PATH=mongodb://database:27017
- GIN_DB_PATH=mongodb://database:27017/
depends_on:
- database
proxy:
image: nginx:latest
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "9030:9000"
depends_on:
- apiserver
- frontend

75
env_page_nginx.conf Normal file
View File

@ -0,0 +1,75 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
# include /etc/nginx/conf.d/*.conf;
server {
listen 9000;
listen [::]:9000;
server_name localhost;
# To allow special characters in headers
ignore_invalid_headers off;
# Allow any size file to be uploaded.
# Set to a value such as 1000m; to restrict file size to a specific value
client_max_body_size 1m;
# To disable buffering
proxy_buffering off;
location /api/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
proxy_set_header Connection "";
chunked_transfer_encoding off;
proxy_pass http://apiserver:8080/;
}
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
proxy_set_header Connection "";
chunked_transfer_encoding off;
proxy_pass http://frontend;
}
}
}