Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy to Production - Add Skia #7

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DevCraftAspire.ApiService/DevCraftAspire.ApiService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Telerik.Drawing.Skia" Version="18.0.24.305" />
<PackageReference Include="Telerik.Reporting.OpenXmlRendering" Version="18.0.24.305" />
<PackageReference Include="Telerik.Reporting.Services.AspNetCore" Version="18.0.24.305" />
</ItemGroup>
Expand Down
8 changes: 5 additions & 3 deletions DevCraftAspire.Web/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@

<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>

@* didnt work

<environment include="Development">
<script src="https://localhost:7443/reports/resources/js/telerikReportViewer"></script>
</environment>

<environment include="Staging,Production">
@* Should resolve to https://apiservice.purpledune-16458cf6.eastus2.azurecontainerapps.io/reports/resources/js/telerikReportViewer in Azure *@
<script src="@(Environment.GetEnvironmentVariable("services__apiservice__https__0"))/reports/resources/js/telerikReportViewer"></script>
</environment>

</environment>
*@

<style>
#rv1 {
position: relative;
Expand Down
28 changes: 17 additions & 11 deletions DevCraftAspire.Web/Components/Pages/Home.razor
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
@page "/"
@using Telerik.ReportViewer.Blazor
@using DevCraftAspire.Web.Clients
@inject IJSRuntime JSRuntime
@inject ReportsApiClient ReportsApi

@* Important: prerender the ReportViewer *@
@rendermode InteractiveServer



@* Important: Viewer's resources are loaded in App.razor *@
@* Important: Viewer's resources are dynamically loaded in OnAfterRenderAsync because I don't know the base URL yet *@
<ReportViewer @ref="ReportViewer1"
ViewerId="rv1"
ServiceUrl="@ApiServiceUrl"
Expand All @@ -17,14 +16,7 @@
Scale="1.0" />

@code {
#if DEBUG
// Dev environment hack
private string ApiServiceUrl { get; } = "https://localhost:7443/reports";
#elif RELEASE
// Production hack uses https://apiservice.purpledune-16458cf6.eastus2.azurecontainerapps.io
private string ApiServiceUrl { get; } = $"{Environment.GetEnvironmentVariable("services__apiservice__https__0")}/reports";
#endif

private string? ApiServiceUrl { get; set; }
private ReportViewer? ReportViewer1 { get; set; }
private ReportSourceOptions MyReportSource { get; set; } = new() { Report = "Barcodes Report.trdp" };

Expand All @@ -35,6 +27,20 @@

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
var rootUrl = "";
#if DEBUG
rootUrl = "https://localhost:7443";
#elif RELEASE
rootUrl = Environment.GetEnvironmentVariable("services__apiservice__https__0");
#endif

await JSRuntime.InvokeVoidAsync("loadScript", $"{rootUrl}/reports");

this.ApiServiceUrl = $"{rootUrl}/reports";
}

await base.OnAfterRenderAsync(firstRender);
}
}
68 changes: 68 additions & 0 deletions aspire-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"resources": {
"cache": {
"type": "container.v0",
"connectionString": "{cache.bindings.tcp.host}:{cache.bindings.tcp.port}",
"image": "docker.io/library/redis:7.2.4",
"bindings": {
"tcp": {
"scheme": "tcp",
"protocol": "tcp",
"transport": "tcp",
"targetPort": 6379
}
}
},
"apiservice": {
"type": "project.v0",
"path": "DevCraftAspire.ApiService/DevCraftAspire.ApiService.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory",
"ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"external": true
},
"https": {
"scheme": "https",
"protocol": "tcp",
"transport": "http",
"external": true
}
}
},
"webfrontend": {
"type": "project.v0",
"path": "DevCraftAspire.Web/DevCraftAspire.Web.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY": "in_memory",
"ASPNETCORE_FORWARDEDHEADERS_ENABLED": "true",
"ConnectionStrings__cache": "{cache.connectionString}",
"services__apiservice__http__0": "{apiservice.bindings.http.url}",
"services__apiservice__https__0": "{apiservice.bindings.https.url}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http",
"external": true
},
"https": {
"scheme": "https",
"protocol": "tcp",
"transport": "http",
"external": true
}
}
}
}
}