Skip to content
Open
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
74 changes: 43 additions & 31 deletions .github/workflows/apphost-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,48 @@ permissions:

jobs:
build:
name: AppHost Build
name: ${{ matrix.apphost.name }} Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
apphost:
- name: AppHost
project_name: Aspire.Dev.AppHost
project_path: src/apphost/Aspire.Dev.AppHost
artifact_name: apphost-release
- name: Preview AppHost
project_name: Aspire.Dev.Preview.AppHost
project_path: src/apphost/Aspire.Dev.Preview.AppHost
artifact_name: preview-apphost-release
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
global-json-file: global.json

- name: Restore
run: cd src/apphost/Aspire.Dev.AppHost && dotnet restore

- name: Build
run: cd src/apphost/Aspire.Dev.AppHost && dotnet build --no-restore --configuration Release

- name: Verify output
run: |
APPHOST_DLL=$(ls -1 src/apphost/Aspire.Dev.AppHost/bin/Release/*/Aspire.Dev.AppHost.dll 2>/dev/null | head -n 1)
if [ -z "$APPHOST_DLL" ]; then
echo "AppHost build failed - output assembly not found"
ls -R src/apphost/Aspire.Dev.AppHost/bin/Release || true
exit 1
fi
echo "Found $APPHOST_DLL"

- name: Upload artifact
if: ${{ always() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: apphost-release
path: src/apphost/Aspire.Dev.AppHost/bin/Release/*/
if-no-files-found: warn
retention-days: 7
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
global-json-file: global.json

- name: Restore
run: cd ${{ matrix.apphost.project_path }} && dotnet restore

- name: Build
run: cd ${{ matrix.apphost.project_path }} && dotnet build --no-restore --configuration Release

- name: Verify output
run: |
APPHOST_DLL=$(ls -1 ${{ matrix.apphost.project_path }}/bin/Release/*/${{ matrix.apphost.project_name }}.dll 2>/dev/null | head -n 1)
if [ -z "$APPHOST_DLL" ]; then
echo "AppHost build failed - output assembly not found"
ls -R ${{ matrix.apphost.project_path }}/bin/Release || true
exit 1
fi
echo "Found $APPHOST_DLL"

- name: Upload artifact
if: ${{ always() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: ${{ matrix.apphost.artifact_name }}
path: ${{ matrix.apphost.project_path }}/bin/Release/*/
if-no-files-found: warn
retention-days: 7
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ jobs:
uses: ./.github/workflows/frontend-build.yml
with:
node_version: '24.x'
artifact_name: ${{ github.event_name == 'pull_request' && format('frontend-dist-pr-{0}', github.event.pull_request.number) || 'frontend-dist' }}
artifact_retention_days: ${{ github.event_name == 'pull_request' && 30 || 7 }}
site_base_path: ${{ github.event_name == 'pull_request' && format('/prs/{0}', github.event.pull_request.number) || '/' }}

apphost-build:
needs: changes
Expand All @@ -82,12 +85,14 @@ jobs:
- name: Verify CI results
shell: bash
env:
IS_PULL_REQUEST: ${{ github.event_name == 'pull_request' }}
CHANGES_RESULT: ${{ needs.changes.result }}
FRONTEND_CHANGED: ${{ needs.changes.outputs.frontend }}
APPHOST_CHANGED: ${{ needs.changes.outputs.apphost }}
FRONTEND_RESULT: ${{ needs['frontend-build'].result }}
APPHOST_RESULT: ${{ needs['apphost-build'].result }}
run: |
echo "is pull_request event: $IS_PULL_REQUEST"
echo "changes result: $CHANGES_RESULT"
echo "frontend changed: $FRONTEND_CHANGED"
echo "frontend-build result: $FRONTEND_RESULT"
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/frontend-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ on:
required: true
default: "24.x"
type: string
artifact_name:
description: Artifact name to publish
required: false
default: "frontend-dist"
type: string
artifact_retention_days:
description: Number of days to keep the uploaded artifact
required: false
default: 7
type: number
site_base_path:
description: Path base to use for the Astro build
required: false
default: "/"
type: string

permissions:
contents: read
Expand Down Expand Up @@ -41,6 +56,7 @@ jobs:
env:
MODE: production
ASTRO_TELEMETRY_DISABLED: 1
ASTRO_BASE_PATH: ${{ inputs.site_base_path }}
run: pnpm build:production

- name: Check dist
Expand All @@ -61,7 +77,7 @@ jobs:
if: ${{ always() }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: frontend-dist
name: ${{ inputs.artifact_name }}
path: src/frontend/dist
if-no-files-found: warn
retention-days: 7
retention-days: ${{ inputs.artifact_retention_days }}
2 changes: 2 additions & 0 deletions Aspire.Dev.slnx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<Solution>
<Folder Name="/apphost/">
<Project Path="src/apphost/Aspire.Dev.AppHost/Aspire.Dev.AppHost.csproj" />
<Project Path="src/apphost/Aspire.Dev.Preview.AppHost/Aspire.Dev.Preview.AppHost.csproj" />
</Folder>
<Folder Name="/statichost/">
<Project Path="src/statichost/StaticHost/StaticHost.csproj" />
<Project Path="src/statichost/PreviewHost/PreviewHost.csproj" />
</Folder>
<Project Path="src/frontend/frontend.esproj">
<Build />
Expand Down
43 changes: 43 additions & 0 deletions src/apphost/Aspire.Dev.Preview.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
var builder = DistributedApplication.CreateBuilder(args);

var extractionMode = builder.AddParameter("extraction-mode", value: "command-line");
var githubOAuthClientId = builder.AddParameter("github-oauth-client-id");
var githubOAuthClientSecret = builder.AddParameter("github-oauth-client-secret", secret: true);
var previewControlBaseUrl = builder.AddParameter("preview-control-base-url", value: string.Empty);
var previewContentBaseUrl = builder.AddParameter("preview-content-base-url", value: string.Empty);
var previewAuthCookieDomain = builder.AddParameter("preview-auth-cookie-domain", value: string.Empty);

var previewHost = builder.AddProject<Projects.PreviewHost>("previewhost")
.PublishAsDockerFile()
.WithExternalHttpEndpoints()
.WithEnvironment("PreviewHost__ExtractionMode", extractionMode)
.WithEnvironment("PreviewHost__GitHubOAuthClientId", githubOAuthClientId)
.WithEnvironment("PreviewHost__GitHubOAuthClientSecret", githubOAuthClientSecret)
.WithEnvironment("PreviewHost__ControlBaseUrl", previewControlBaseUrl)
.WithEnvironment("PreviewHost__ContentBaseUrl", previewContentBaseUrl)
.WithEnvironment("PreviewHost__AuthCookieDomain", previewAuthCookieDomain);

if (!string.IsNullOrWhiteSpace(builder.Configuration["PreviewHost:GitHubToken"]))
{
var githubToken = builder.AddParameterFromConfiguration("github-token", "PreviewHost:GitHubToken", secret: true);
previewHost.WithEnvironment("PreviewHost__GitHubToken", githubToken);
}
else
{
var githubAppId = builder.AddParameter("github-app-id");
var githubAppInstallationId = builder.AddParameter("github-app-installation-id");
var githubAppPrivateKey = builder.AddParameter("github-app-private-key", secret: true);

previewHost
.WithEnvironment("PreviewHost__GitHubAppId", githubAppId)
.WithEnvironment("PreviewHost__GitHubAppInstallationId", githubAppInstallationId)
.WithEnvironment("PreviewHost__GitHubAppPrivateKey", githubAppPrivateKey);
}

if (!builder.ExecutionContext.IsRunMode)
{
previewHost.WithEnvironment("PreviewHost__ContentRoot", "/tmp/pr-preview-data");
builder.AddAzureAppServiceEnvironment("preview");
}

builder.Build().Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Aspire.AppHost.Sdk/13.2.0">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>cde7765d-59fe-4ea8-a20a-c1eb1ced5cbf</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.Azure.AppService" Version="13.2.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\statichost\PreviewHost\PreviewHost.csproj" />
</ItemGroup>

</Project>
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:17156;http://localhost:15082",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21055",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22207"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15082",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19290",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20046"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions src/apphost/Aspire.Dev.Preview.AppHost/appsettings.json
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"
}
}
}
7 changes: 7 additions & 0 deletions src/frontend/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ import starlightSidebarTopics from 'starlight-sidebar-topics';
import starlightPageActions from 'starlight-page-actions';
import jopSoftwarecookieconsent from '@jop-software/astro-cookieconsent';

const configuredBasePath = process.env.ASTRO_BASE_PATH ?? '/';
const normalizedBasePath =
configuredBasePath === '/'
? '/'
: `/${configuredBasePath.replace(/^\/+|\/+$/g, '')}`;

// https://astro.build/config
export default defineConfig({
prefetch: true,
base: normalizedBasePath,
site: 'https://aspire.dev',
trailingSlash: 'always',
redirects: redirects,
Expand Down
2 changes: 2 additions & 0 deletions src/statichost/PreviewHost/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin/
obj/
25 changes: 25 additions & 0 deletions src/statichost/PreviewHost/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# syntax=docker/dockerfile:1.7

FROM mcr.microsoft.com/dotnet/sdk:10.0-noble AS build
WORKDIR /src

COPY . ./

RUN dotnet publish ./PreviewHost.csproj -c Release -o /app/publish /p:UseAppHost=false

FROM mcr.microsoft.com/dotnet/aspnet:10.0-noble AS unzip-tools
RUN apt-get update \
&& apt-get install -y --no-install-recommends unzip \
&& rm -rf /var/lib/apt/lists/*

FROM mcr.microsoft.com/dotnet/aspnet:10.0-noble-chiseled AS final
WORKDIR /app

COPY --from=unzip-tools /usr/bin/unzip /usr/bin/unzip
COPY --from=unzip-tools /lib/x86_64-linux-gnu/libbz2.so.1.0* /lib/x86_64-linux-gnu/
COPY --from=build /app/publish/ ./

ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080

ENTRYPOINT ["dotnet", "PreviewHost.dll"]
15 changes: 15 additions & 0 deletions src/statichost/PreviewHost/PreviewHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<SelfContained>false</SelfContained>
<PublishAot>false</PublishAot>
<InvariantGlobalization>true</InvariantGlobalization>
<ContainerFamily>noble-chiseled</ContainerFamily>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GitHubJwt" Version="0.0.6" />
<PackageReference Include="Octokit" Version="14.0.0" />
</ItemGroup>
</Project>
Loading
Loading