Example app lifecycle workflow
This guide is a worked example of one CI/CD workflow for Aspire. It uses GitHub Actions to build and publish release artifacts, GitHub Container Registry to store container images, and Docker Compose to run the published output later.
Use this page when you want a concrete end-to-end example. For workflow guidance that applies across CI systems and deployment targets, see CI/CD overview.
For workflow-first guidance, see CI/CD overview. For Docker Compose deployment details, see Deploy to Docker Compose.
Example workflow
Section titled “Example workflow”This example moves through four phases:
- Inner-loop development - Local development and debugging with
aspire run - Local deployment validation - Containerized deployment to your defined compute environment(s) with
aspire deploy - Publish release artifacts - Automated build and publish steps in GitHub Actions
- Deploy the published artifacts - Runtime deployment with Docker Compose
Each phase uses the same AppHost configuration, but each phase answers a different question: local correctness, containerized validation, release automation, or runtime deployment.
Example application
Section titled “Example application”The following example uses a C# AppHost, but the same workflow shape applies to TypeScript AppHosts.
Consider this example. You have a distributed application that consists of a Blazor web project that relies on a SQL Server database with a persistent data volume as well as a persistent writable file volume to capture user file uploads. You want to distribute your Blazor app as a Docker container image via the GitHub Container Registry. You need the Aspire.Hosting.Docker and Aspire.Hosting.SqlServer integrations.
var builder = DistributedApplication.CreateBuilder(args);
// Add Docker Compose environmentvar compose = builder.AddDockerComposeEnvironment("volumemount-env") .WithProperties(env => { env.DashboardEnabled = true; }) .ConfigureComposeFile(composeFile => { // Add the blazor file volume to the top-level volumes section composeFile.AddVolume(new Volume { Name = "volumemount-blazor-uploads", Driver = "local" }); });
// Add container registryvar endpoint = builder.AddParameter("registry-endpoint");var repository = builder.AddParameter("registry-repository");builder.AddContainerRegistry("container-registry", endpoint, repository);
//Add SQL Server with data volumevar sqlPassword = builder.AddParameter("sqlserver-password", secret: true);var sqlserver = builder.AddSqlServer("sqlserver", password: sqlPassword) .WithDataVolume("volumemount-sqlserver-data") .WithLifetime(ContainerLifetime.Persistent);
var sqlDatabase = sqlserver.AddDatabase("sqldb");
//Add the Blazor web app with reference to the database//Deploy as a docker image with a volume mount for user upload filesvar blazorweb = builder.AddProject<Projects.VolumeMount_BlazorWeb>("blazorweb") .WithExternalHttpEndpoints() .WithReference(sqlDatabase) .WaitFor(sqlDatabase) //Deploy the Web project as a Docker Compose service with a volume mount for files .PublishAsDockerComposeService((resource, service) => { service.AddVolume(new Volume { Name = "volumemount-blazor-uploads", Source = "volumemount-blazor-uploads", Target = "/app/wwwroot/uploads", Type = "volume", ReadOnly = false });
// Override the entrypoint to allow write permissions to the volume // then run the default entrypoint as app user service.User = "root"; service.Command = new List<string> { "/bin/sh", "-c", "chown -R app:app /app/wwwroot/uploads && chmod -R 755 /app/wwwroot/uploads && exec su app -c 'dotnet /app/VolumeMount.BlazorWeb.dll'" };
});
builder.Build().Run();Phase 1: Develop locally
Section titled “Phase 1: Develop locally”Run the app locally
Section titled “Run the app locally”The aspire run command starts your Aspire application in development mode. This is the inner-loop development experience where you write code, test changes, and debug your application locally.
When you run aspire run:
- Aspire dashboard launches - A web-based dashboard starts, and its URL (often an HTTPS login URL like
https://localhost:<port>/login?...) is printed to the console. - Resources start - All resources defined in your AppHost are orchestrated.
- Live debugging - You can attach debuggers, set breakpoints, and modify code with hot reload.
- Telemetry & logs - Dashboard provides real-time logs, metrics, and distributed traces.
This command searches the current directory structure for AppHost projects to build and run:
aspire runThe console will display the dashboard URL with a login token:
Dashboard: https://localhost:17244/login?t=9db79f2885dae24ee06c6ef10290b8b2
Logs: /home/vscode/.aspire/cli/logs/apphost-5932-2025-08-25-18-37-31.log
Press CTRL+C to stop the apphost and exit.In the example above, when resources start with the run command:
- SQL Server container starts in Docker with persistent volume
- Web project runs as a local process (not containerized)
- Database is automatically created and migrated (containerized)
Phase 2: Validate a containerized deployment
Section titled “Phase 2: Validate a containerized deployment”Deploy the example locally
Section titled “Deploy the example locally”The aspire deploy command creates a fully containerized deployment of your application in the compute environment(s) you define. This simulates a production-like environment on your local machine. In this example, local containers and volumes are created on Docker Desktop using the Docker Integration. It requires all parameters to be set.
When you run aspire deploy Aspire will:
- Build and push container images for projects
- Generate
docker-compose.yamlin./aspire-output/directory - Start all containers using Docker Compose
- Create and mount persistent volumes
In this example, the following gets deployed:
Containers:
aspire-volumemount-env- Docker Compose stacksqlserver- SQL Server with persistent data volumeblazorweb- Blazor Web app with persistent file uploads volumevolumemount-env-dashboard- Monitoring dashboard
Volumes:
volumemount-sqlserver-data- Stores database files (.mdf,.ldf)volumemount-blazor-uploads- Stores user-uploaded images
You can login to your GitHub Container Registry before deploying.
export GITHUB_TOKEN=<YOUR PERSONAL ACCESS TOKEN>echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
aspire deployPhase 3: Publish release artifacts in GitHub Actions
Section titled “Phase 3: Publish release artifacts in GitHub Actions”You can create a workflow that automates the process of building and pushing the image, and publishing deployment artifacts using the Aspire CLI in a CI/CD pipeline. The Aspire CLI can build your app, push images, and emit deployment artifacts as a one-way handoff. This allows you to deploy the app later via standard Docker Compose.
In this example, the workflow runs on every push to main, does a checkout, and then performs these steps:
- Setup Environment - Install required SDKs
- Install Aspire CLI - Install the Aspire CLI
- Build and Push Container Images - Build app and push image to GitHub Container Registry with
aspire do push - Publish Docker Compose Artifacts - Generate deployment files with
aspire publish - Upload Artifacts - Store deployment files for download
Step 1: Setup Environment
Section titled “Step 1: Setup Environment”# Required for C# AppHost projects- name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: '10.0.x'Step 2: Install Aspire CLI
Section titled “Step 2: Install Aspire CLI”- name: Install Aspire CLI run: | echo "Installing Aspire CLI from install script..." curl -sSL https://aspire.dev/install.sh | bash echo "$HOME/.aspire/bin" >> $GITHUB_PATHStep 3. Build App, Create & Push Image to GHCR
Section titled “Step 3. Build App, Create & Push Image to GHCR”- name: Login to GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push images with Aspire env: Parameters__registry_endpoint: ghcr.io Parameters__registry_repository: your-org/your-repo run: aspire do pushThe aspire do push command does the following:
- Analyzes your AppHost configuration
- Restores dependencies and builds the project
- Builds Docker container images for project resources
- Tags images with configured registry endpoint and repository
- Pushes images to GitHub Container Registry (ghcr.io)
- Uses parameters defined in
AppHost.cs:- Environment
Parameters__registry_endpointmaps toregistry-endpointparameter - Environment
Parameters__registry_repositorymaps toregistry-repositoryparameter
- Environment
Step 4: Publish Docker Compose Artifacts
Section titled “Step 4: Publish Docker Compose Artifacts”- name: Prepare Docker Compose with Aspire run: | aspire publish \ --project VolumeMount.AppHost/VolumeMount.AppHost.csproj \ --output-path ./aspire-outputThe aspire publish command does the following:
- Analyzes your AppHost configuration
- Generates
docker-compose.yamlfile with all service definitions - Creates
.envtemplate file for environment variables - Packages configuration needed for deployment
- Outputs artifacts to
./aspire-output/directory
Directoryaspire-output/
- docker-compose.yaml Service definitions for all containers
- .env Template for required environment variables
Step 5: Upload Deployment Artifacts
Section titled “Step 5: Upload Deployment Artifacts”- name: Upload Aspire artifacts uses: actions/upload-artifact@v4 with: name: aspire-deployment-files path: ./aspire-output/ retention-days: 30 include-hidden-files: trueIn this example, artifacts are available for download from the Actions workflow run for 30 days. Hidden files are included so that the .env file is also available in the artifacts.
Phase 4: Deploy the published artifacts
Section titled “Phase 4: Deploy the published artifacts”After the workflow completes, you have everything needed for production deployment:
-
Download Artifacts from GitHub Actions workflow run:
docker-compose.yaml- Complete service definitions.env- Environment variable template
-
Configure Environment Variables in
.env. For example:Terminal window BLAZORWEB_IMAGE=ghcr.io/bethmassi/volumemount/blazorweb:latestBLAZORWEB_PORT=8080SQLSERVER_PASSWORD=YourSecurePassword -
Deploy with Docker Compose:
Terminal window docker compose up -d -
Verify Deployment:
Terminal window docker compose psdocker compose logs -f
Workflow summary
Section titled “Workflow summary”| Phase | Command | Purpose | Environment | App | Database |
|---|---|---|---|---|---|
| Development | aspire run | Inner-loop coding & debugging | Local machine | Local process | Container |
| Local Deploy | aspire deploy | Test containerized app locally | Registered compute environment (i.e. Docker Desktop) | Container | Container |
| Release | CI/CD workflow (i.e. GitHub Actions) | Publish to staging/ production | Cloud/Server | Container | Container |
The AppHost is the single source of truth for your application architecture. Each phase above uses the exact same AppHost configuration. This eliminates configuration drift between development and deployment. It defines things your distributed application needs like:
- Services & Dependencies - Projects, containers, and their relationships
- Configuration - Connection strings, secrets, and parameters
- Volumes - Persistent storage for databases and files
- Networking - Endpoints, ports, and service communication
- Deployment - Container registry, image tags, and publish settings
For more information, see AppHost configuration.
Next steps
Section titled “Next steps”- Learn more about Service discovery
- Explore Telemetry options
- Understand Health checks