build script for maui apk adjusted 2 #2
2
.github/workflows/deploy.prod-env.yml
vendored
2
.github/workflows/deploy.prod-env.yml
vendored
@ -26,5 +26,5 @@ jobs:
|
||||
docker pull git.wohlleben.dev/itob/rbl-news-webapp:latest
|
||||
docker stop rbl-news-webapp
|
||||
docker rm rbl-news-webapp
|
||||
docker run --init -d --name rbl-news-webapp -p 8000:8080 --restart=always git.wohlleben.dev/itob/rbl-news-webapp:latest
|
||||
docker run --init -d --name rbl-news-webapp -p 8000:8080 -e RblApiUrl=${{ vars.RBL_PROD_ENV_API_URL }} --restart=always git.wohlleben.dev/itob/rbl-news-webapp:latest
|
||||
docker system prune -af
|
||||
2
.github/workflows/deploy.test-env.yml
vendored
2
.github/workflows/deploy.test-env.yml
vendored
@ -40,5 +40,5 @@ jobs:
|
||||
docker pull git.wohlleben.dev/itob/rbl-news-webapp:latest
|
||||
docker stop rbl-news-webapp
|
||||
docker rm rbl-news-webapp
|
||||
docker run --init -d --name rbl-news-webapp -p 8000:8080 --restart=always git.wohlleben.dev/itob/rbl-news-webapp:latest
|
||||
docker run --init -d --name rbl-news-webapp -p 8000:8080 -e RblApiUrl=${{ vars.RBL_TEST_ENV_API_URL }} --restart=always git.wohlleben.dev/itob/rbl-news-webapp:latest
|
||||
docker system prune -af
|
||||
@ -30,8 +30,21 @@ namespace RBLNews.Maui
|
||||
builder.Services.AddBlazorWebViewDeveloperTools();
|
||||
builder.Logging.AddDebug();
|
||||
#endif
|
||||
|
||||
MauiApp app = builder.Build();
|
||||
|
||||
return builder.Build();
|
||||
using var serviceScope = app.Services.CreateScope();
|
||||
var services = serviceScope.ServiceProvider;
|
||||
|
||||
var environmentVariablesService = services.GetRequiredService<EnvironmentVariablesService>();
|
||||
string? backendApiUrl = environmentVariablesService.RblApiUrl;
|
||||
|
||||
if (string.IsNullOrEmpty(backendApiUrl))
|
||||
{
|
||||
throw new Exception($"can't instantiate services, due to paramters are null. backendApiUrl: '{backendApiUrl}'");
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
6
RBLNews.Shared/Services/EnvironmentVariablesService.cs
Normal file
6
RBLNews.Shared/Services/EnvironmentVariablesService.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace RBLNews.Shared.Services;
|
||||
|
||||
public class EnvironmentVariablesService
|
||||
{
|
||||
public string? RblApiUrl => Environment.GetEnvironmentVariable("RblApiUrl");
|
||||
}
|
||||
@ -15,15 +15,23 @@ namespace RBLNews.Shared.Services
|
||||
|
||||
public class FeedDataService : IFeedDataService
|
||||
{
|
||||
private readonly EnvironmentVariablesService _environmentVariablesService;
|
||||
|
||||
private static readonly HttpClient httpClient = new();
|
||||
|
||||
public RssVM Feeds { get; private set; }
|
||||
|
||||
public Action DataChanged { get; set; }
|
||||
|
||||
|
||||
public FeedDataService(EnvironmentVariablesService environmentVariablesService)
|
||||
{
|
||||
this._environmentVariablesService = environmentVariablesService;
|
||||
}
|
||||
|
||||
public async Task LoadFeeds()
|
||||
{
|
||||
Feeds = await httpClient.GetFromJsonAsync<RssVM>("https://rblnews.de/api/feeds") ?? new RssVM();
|
||||
Feeds = await httpClient.GetFromJsonAsync<RssVM>($"{this._environmentVariablesService.RblApiUrl}/api/feeds") ?? new RssVM();
|
||||
DataChanged.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,20 +5,33 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorComponents()
|
||||
.AddInteractiveServerComponents();
|
||||
.AddInteractiveServerComponents();
|
||||
builder.Services.AddBlazorBootstrap();
|
||||
|
||||
builder.Services.AddSingleton<IFeedDataService, FeedDataService>();
|
||||
builder.Services.AddSingleton<AppLifecycleService>();
|
||||
builder.Services.AddSingleton<EnvironmentVariablesService>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
||||
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
using var serviceScope = app.Services.CreateScope();
|
||||
IServiceProvider services = serviceScope.ServiceProvider;
|
||||
|
||||
EnvironmentVariablesService environmentVariablesService = services.GetRequiredService<EnvironmentVariablesService>();
|
||||
string? backendApiUrl = environmentVariablesService.RblApiUrl;
|
||||
|
||||
if (string.IsNullOrEmpty(backendApiUrl))
|
||||
{
|
||||
throw new Exception($"can't instantiate services, due to paramters are null. backendApiUrl: '{backendApiUrl}'");
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
@ -27,7 +40,7 @@ app.UseStaticFiles();
|
||||
app.UseAntiforgery();
|
||||
|
||||
app.MapRazorComponents<App>()
|
||||
.AddInteractiveServerRenderMode()
|
||||
.AddAdditionalAssemblies(typeof(RBLNews.Shared._Imports).Assembly);
|
||||
.AddInteractiveServerRenderMode()
|
||||
.AddAdditionalAssemblies(typeof( RBLNews.Shared._Imports ).Assembly);
|
||||
|
||||
app.Run();
|
||||
app.Run();
|
||||
Loading…
Reference in New Issue
Block a user