Skip to content

Commit

Permalink
06-composition-via-yarp-and-esi (#22)
Browse files Browse the repository at this point in the history
* Scaffolding an ESI processor

* Adding choose, comment, remove, and vars ESI elements

* Adding try ESI element

* Adding include ESI element

* Adding actions workflow
  • Loading branch information
tpeczek authored Aug 18, 2024
1 parent 8375700 commit f855dd9
Show file tree
Hide file tree
Showing 48 changed files with 1,236 additions and 133 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/06-composition-via-yarp-and-esi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: 06-composition-via-yarp-and-esi
on: workflow_dispatch
permissions:
id-token: write
contents: read
env:
SAMPLE: 06-composition-via-yarp-and-esi
LOCATION: westeurope
RESOURCE_GROUP: rg-micro-frontends-in-action-06
MANAGED_IDENTITY: id-micro-frontends-in-action-06
CONTAINER_REGISTRY: crmicrofrontendsinaction06
CONTAINERAPPS_ENVIRONMENT: ca-env-micro-frontends-in-action-06
DECIDE_CONTAINERAPP: ca-app-decide
INSPIRE_CONTAINERAPP: ca-app-inspire
PROXY_CONTAINERAPP: ca-app-proxy
jobs:
deploy-infrastructure:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Deploy Infrastructure
uses: azure/arm-deploy@v2
with:
scope: subscription
region: ${{ env.LOCATION }}
template: ./bicep-modules/micro-frontends-in-action-infrastructure.bicep
deploymentName: 'micro-frontends-in-action-05-iac'
parameters: 'resourceGroupName=${{ env.RESOURCE_GROUP }} resourceGroupLocation=${{ env.LOCATION }} managedIdentityName=${{ env.MANAGED_IDENTITY }} containerRegistryName=${{ env.CONTAINER_REGISTRY }} containerAppsEnvironmentName=${{ env.CONTAINERAPPS_ENVIRONMENT }}'
- name: Log Out From Azure
run: |
az logout
az cache purge
az account clear
deliver-images:
needs: [deploy-infrastructure]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Log in to Container Registry
run: az acr login -n ${CONTAINER_REGISTRY}
- name: Build Docker Images
run: |
docker build ${SAMPLE}/Demo.AspNetCore.MicroFrontendsInAction.Decide/ -t ${CONTAINER_REGISTRY}.azurecr.io/decide:${{ github.sha }}
docker build ${SAMPLE}/Demo.AspNetCore.MicroFrontendsInAction.Inspire/ -t ${CONTAINER_REGISTRY}.azurecr.io/inspire:${{ github.sha }}
docker build ${SAMPLE}/Demo.AspNetCore.MicroFrontendsInAction.Proxy/ -t ${CONTAINER_REGISTRY}.azurecr.io/proxy:${{ github.sha }}
- name: Push Docker Images to Container Registry
run: |
docker push ${CONTAINER_REGISTRY}.azurecr.io/decide:${{ github.sha }}
docker push ${CONTAINER_REGISTRY}.azurecr.io/inspire:${{ github.sha }}
docker push ${CONTAINER_REGISTRY}.azurecr.io/proxy:${{ github.sha }}
- name: Log Out From Azure
run: |
docker logout
az logout
az cache purge
az account clear
deploy-container-apps:
needs: [deploy-infrastructure, deliver-images]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Deploy Container Apps
uses: azure/arm-deploy@v2
with:
scope: resourcegroup
resourceGroupName: ${{ env.RESOURCE_GROUP }}
template: ./bicep-modules/micro-frontends-in-action-deployment.bicep
deploymentName: 'micro-frontends-in-action-05-cd'
parameters: 'location=${{ env.LOCATION }} managedIdentityName=${{ env.MANAGED_IDENTITY }} containerRegistryName=${{ env.CONTAINER_REGISTRY }} containerAppsEnvironmentName=${{ env.CONTAINERAPPS_ENVIRONMENT }} microFrontendsContainerAppsDetails="[{\"name\":\"${{ env.DECIDE_CONTAINERAPP }}\",\"imageName\":\"decide\",\"imageTag\":\"${{ github.sha }}\",\"port\":3001,\"urlVariableName\":\"DECIDE_SERVICE_URL\"},{\"name\":\"${{ env.INSPIRE_CONTAINERAPP }}\",\"imageName\":\"inspire\",\"imageTag\":\"${{ github.sha }}\",\"port\":3002,\"urlVariableName\":\"INSPIRE_SERVICE_URL\"}]" microFrontendsProxyContainerAppDetails="{\"name\":\"${{ env.PROXY_CONTAINERAPP }}\",\"imageName\":\"proxy\",\"imageTag\":\"${{ github.sha }}\",\"port\":3000}"'
- name: Log Out From Azure
run: |
az logout
az cache purge
az account clear

This file was deleted.

This file was deleted.

25 changes: 25 additions & 0 deletions 06-composition-via-yarp-and-esi/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>44dc8d10-b76f-423e-86c0-303c292b565e</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Demo.AspNetCore.MicroFrontendsInAction.Decide\Demo.AspNetCore.MicroFrontendsInAction.Decide.csproj" />
<ProjectReference Include="..\Demo.AspNetCore.MicroFrontendsInAction.Inspire\Demo.AspNetCore.MicroFrontendsInAction.Inspire.csproj" />
<ProjectReference Include="..\Demo.AspNetCore.MicroFrontendsInAction.Proxy\Demo.AspNetCore.MicroFrontendsInAction.Proxy.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var builder = DistributedApplication.CreateBuilder(args);

var decideApplication = builder.AddProject<Projects.Demo_AspNetCore_MicroFrontendsInAction_Decide>("ca-app-decide");
var inspireApplication = builder.AddProject<Projects.Demo_AspNetCore_MicroFrontendsInAction_Inspire>("ca-app-inspire");

builder.AddProject<Projects.Demo_AspNetCore_MicroFrontendsInAction_Proxy>("ca-app-proxy")
.WithEnvironment("DECIDE_SERVICE_URL", decideApplication.GetEndpoint("http"))
.WithEnvironment("INSPIRE_SERVICE_URL", inspireApplication.GetEndpoint("http"));

builder.Build().Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17060;http://localhost:15048",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21287",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22291"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15048",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19226",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20292"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Mvc;
using Demo.AspNetCore.MicroFrontendsInAction.Decide.Models;

namespace Demo.AspNetCore.MicroFrontendsInAction.Decide.Controllers
{
public class ProductsController : Controller
{
private static readonly IReadOnlyDictionary<string, ProductViewModel> _products = new Dictionary<string, ProductViewModel>
{
{ "eicher", new ProductViewModel("eicher", "Eicher Diesel 215/16") },
{ "fendt", new ProductViewModel("fendt", "Fendt F20 Dieselroß") },
{ "porsche", new ProductViewModel("porsche", "Porsche-Diesel Master 419") }
};

public IActionResult Product(string id)
{
return View(_products[id.ToLowerInvariant()]);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Demo.AspNetCore.MicroFrontendsInAction.Decide</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Content Update="wwwroot\decide\static\outlines.css">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\decide\static\page.css">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\decide\static\page.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
Loading

0 comments on commit f855dd9

Please sign in to comment.