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

Dashboard #763

Merged
merged 18 commits into from
Mar 4, 2025
Merged

Dashboard #763

merged 18 commits into from
Mar 4, 2025

Conversation

Ceredron
Copy link
Collaborator

@Ceredron Ceredron commented Feb 27, 2025

Description

This is a simple app that bootstraps Hangfire dashboard in an Azure Container App. This container app is secured by Azure AD authentication through the integrated container apps solution.

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

Summary by CodeRabbit

  • New Features
    • Introduced a new dashboard web application featuring integrated monitoring and background job management.
    • Enabled secure, dynamic cloud deployments with enhanced configuration and authentication options.
    • Automated deployment workflows now support multiple environments, streamlining updates.
    • Added support for PostgreSQL database connections and integrated logging configurations.
    • Added configuration files for development and production environments to manage application settings.
  • Chores
    • Improved container build efficiency through refined file exclusion settings.
    • Restructured project organization for clearer project management and maintenance.

Copy link
Contributor

coderabbitai bot commented Feb 27, 2025

📝 Walkthrough

Walkthrough

This pull request introduces new infrastructure files and configurations. It adds Bicep files to deploy an Azure Container App dashboard and its associated parameter file, a Docker ignore file, and a GitHub Actions workflow for deployment. It also updates the solution file with two new projects and introduces several new files to support an ASP.NET Core dashboard application, including a Dockerfile, launch settings, configuration files, and supporting C# code. Additionally, a minor removal of an unused using directive is included.

Changes

File Path(s) Change Summary
.azure/applications/dashboard/main.bicep, .azure/applications/dashboard/main.bicepparam New Bicep template and parameter file adding parameters and resources for deploying an Azure Container App dashboard, including Key Vault integration, container app setup, and authentication configuration.
.dockerignore New file added with patterns to exclude unnecessary files and directories from the Docker build context.
.github/workflows/deploy-dashboard.yml New GitHub Actions workflow to build, push, and deploy the dashboard application using Azure and GitHub Container Registry.
Altinn.Correspondence.sln Updated solution file adding two new projects: a tools project and the Altinn.Correspondence.Dashboard project, with nested project configurations.
src/Altinn.Correspondence.Integrations/Hangfire/DependencyInjection.cs Minor update removing an unused using directive and adjusting formatting.
tools/Altinn.Correspondence.Dashboard/* New dashboard project files including the project file (.csproj), Dockerfile, a Hangfire dashboard authorization filter, Program.cs, launch settings, and configuration files (appsettings.json and appsettings.Development.json).

Suggested labels

kind/enhancement

Suggested reviewers

  • mSunberg
  • Andreass2

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 431c257 and c926a6e.

📒 Files selected for processing (1)
  • .azure/applications/dashboard/main.bicep (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .azure/applications/dashboard/main.bicep
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (csharp)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Ceredron Ceredron changed the title Feat/dashboard Dashboard Mar 2, 2025
@Ceredron Ceredron marked this pull request as ready for review March 2, 2025 23:00
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (4)
tools/Altinn.Correspondence.Dashboard/Program.cs (2)

7-24: Consider enhancing application configuration with additional reliability features

The service configuration is good for basic functionality, but could benefit from adding:

  1. Health checks for monitoring application status
  2. Explicit error handling for database connection failures
  3. More comprehensive logging configuration
var builder = WebApplication.CreateBuilder(args);
builder.Configuration
    .AddJsonFile("appsettings.json", true, true)
    .AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", true, true)
    .AddJsonFile("appsettings.local.json", true, true);
builder.Services.AddPersistence(builder.Configuration);
builder.Services.AddApplicationInsightsTelemetry(new ApplicationInsightsServiceOptions()
{
    EnableAdaptiveSampling = false
});
builder.Services.AddSingleton<IConnectionFactory, HangfireConnectionFactory>();
+builder.Services.AddHealthChecks()
+    .AddNpgSql(name: "Hangfire-Postgres", tags: new[] { "ready" });
builder.Services.AddHangfire((provider, config) =>
    {
        config.UsePostgreSqlStorage(
            c => c.UseConnectionFactory(provider.GetService<IConnectionFactory>())
        );
        config.UseSerilogLogProvider();
    });

28-35: Add health check endpoints and improve middleware configuration

Consider enhancing the application's middleware pipeline to include health checks and potentially improve security.

app.UseHttpsRedirection();

+// Configure health checks
+app.MapHealthChecks("/health/ready", new HealthCheckOptions
+{
+    Predicate = (check) => check.Tags.Contains("ready")
+});
+app.MapHealthChecks("/health/live", new HealthCheckOptions
+{
+    Predicate = (_) => false
+});

app.UseHangfireDashboard("/hangfire", new DashboardOptions()
{
    Authorization = [new HangfireDashboardAuthorizationFilter()]
});
app.MapGet("/", () => Results.Redirect("/hangfire"));
tools/Altinn.Correspondence.Dashboard/Dockerfile (1)

10-20: Consider optimizing the Docker build process

The build stage copies project files individually before restoring dependencies. Consider consolidating COPY commands where possible to reduce the number of layers.

# This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
-COPY ["tools/Altinn.Correspondence.Dashboard/Altinn.Correspondence.Dashboard.csproj", "tools/Altinn.Correspondence.Dashboard/"]
-COPY ["src/Altinn.Correspondence.Persistence/Altinn.Correspondence.Persistence.csproj", "src/Altinn.Correspondence.Persistence/"]
-COPY ["src/Altinn.Correspondence.Integrations/Altinn.Correspondence.Integrations.csproj", "src/Altinn.Correspondence.Integrations/"]
+COPY ["tools/Altinn.Correspondence.Dashboard/*.csproj", "tools/Altinn.Correspondence.Dashboard/"]
+COPY ["src/Altinn.Correspondence.Persistence/*.csproj", "src/Altinn.Correspondence.Persistence/"]
+COPY ["src/Altinn.Correspondence.Integrations/*.csproj", "src/Altinn.Correspondence.Integrations/"]

RUN dotnet restore "tools/Altinn.Correspondence.Dashboard/Altinn.Correspondence.Dashboard.csproj"
COPY . .
WORKDIR "/src/tools/Altinn.Correspondence.Dashboard"
RUN dotnet build "Altinn.Correspondence.Dashboard.csproj" -c Release -o /app/build
.github/workflows/deploy-dashboard.yml (1)

49-55: Update Azure login action version

The static analysis indicates that the runner version for the Azure login action may be outdated.

Consider updating to a newer version:

- uses: azure/login@v1
+ uses: azure/login@v2
🧰 Tools
🪛 actionlint (1.7.4)

50-50: the runner of "azure/login@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2792114 and accefc2.

📒 Files selected for processing (13)
  • .azure/applications/dashboard/main.bicep (1 hunks)
  • .azure/applications/dashboard/main.bicepparam (1 hunks)
  • .dockerignore (1 hunks)
  • .github/workflows/deploy-dashboard.yml (1 hunks)
  • Altinn.Correspondence.sln (2 hunks)
  • src/Altinn.Correspondence.Integrations/Hangfire/DependencyInjection.cs (1 hunks)
  • tools/Altinn.Correspondence.Dashboard/Altinn.Correspondence.Dashboard.csproj (1 hunks)
  • tools/Altinn.Correspondence.Dashboard/Dockerfile (1 hunks)
  • tools/Altinn.Correspondence.Dashboard/HangfireDashboardAuthorizationFilter.cs (1 hunks)
  • tools/Altinn.Correspondence.Dashboard/Program.cs (1 hunks)
  • tools/Altinn.Correspondence.Dashboard/Properties/launchSettings.json (1 hunks)
  • tools/Altinn.Correspondence.Dashboard/appsettings.Development.json (1 hunks)
  • tools/Altinn.Correspondence.Dashboard/appsettings.json (1 hunks)
✅ Files skipped from review due to trivial changes (6)
  • tools/Altinn.Correspondence.Dashboard/appsettings.Development.json
  • tools/Altinn.Correspondence.Dashboard/appsettings.json
  • .dockerignore
  • tools/Altinn.Correspondence.Dashboard/Properties/launchSettings.json
  • src/Altinn.Correspondence.Integrations/Hangfire/DependencyInjection.cs
  • tools/Altinn.Correspondence.Dashboard/Altinn.Correspondence.Dashboard.csproj
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/deploy-dashboard.yml

50-50: the runner of "azure/login@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.35.1)
.github/workflows/deploy-dashboard.yml

[error] 1-1: wrong new line character: expected \n

(new-lines)

🔇 Additional comments (11)
Altinn.Correspondence.sln (3)

24-27: New project structure added correctly

The solution has been properly extended with a new "tools" folder containing the Dashboard project, following good organizational practices by separating utility applications from the core codebase.


66-69: Project configuration properly defined

Configuration settings for both Debug and Release builds have been correctly added for the Dashboard project.


77-77: Nested project structure configured correctly

The Dashboard project has been properly nested under the "tools" folder, maintaining a clean solution organization.

.github/workflows/deploy-dashboard.yml (4)

3-18: Well-structured deployment workflow trigger

The workflow trigger configuration using workflow_dispatch with environment selection is well-designed, allowing for flexible deployment across multiple environments.


19-23: Appropriate permissions defined

The permissions are correctly configured with the minimum necessary access levels for the workflow operations.


32-48: Container build and push properly configured

The Docker image build and push steps are well-structured, with appropriate tagging using both the commit SHA and 'latest' for versioning.


62-69: Security credentials properly passed as parameters

The workflow correctly passes necessary security credentials and configuration from GitHub secrets to the Bicep deployment.

.azure/applications/dashboard/main.bicep (4)

1-8: Well-defined parameters

All necessary parameters for the deployment are properly defined, including security credentials and configuration values.


14-30: Key Vault access policy properly configured

The access policy is correctly set up to grant the container app the minimum necessary permissions to retrieve secrets from the Key Vault.


32-77: Container App configuration well-structured

The Container App resource is properly defined with appropriate identity, ingress settings, and secrets configuration. The scale configuration limits the app to a single replica, which is appropriate for a dashboard application.


79-113: Robust authentication configuration

The Azure AD authentication for the Container App is comprehensively configured with proper client credentials, issuer, and authorization policy that restricts access to a specific group.

Ceredron and others added 3 commits March 3, 2025 08:16
@Ceredron Ceredron merged commit be15ace into main Mar 4, 2025
6 checks passed
@Ceredron Ceredron deleted the feat/dashboard branch March 4, 2025 10:22
Ceredron added a commit that referenced this pull request Mar 4, 2025
* Dashboard

* This leads to double messages

* Restored old functionality, simplified ours instead

* Got no swagger

* Fixed deploy script

* Fix dockerfile

* Use port 2526 for dashboard

* Github action and biceps

* Updated dockerfile

* Removed unused .http file

* Fixed bicep to include the necessary setup

* FIx

* Clean-up

* Add authentication to bicep

* Delete old script as we do bicep now

* Update .github/workflows/deploy-dashboard.yml

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Fixed auth config

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant