Skip to content

About

An extension of the docker compose integration for deploying to a docker host via SSH

Resources

Stars

138 stars

Watchers

4 watching

Forks

Repository files navigation

Aspire Docker SSH Deployment Pipeline

feedz.io

Deploy Aspire applications to remote Docker hosts via SSH.

Overview

This package extends Aspire's Docker Compose support with a deployment pipeline that builds container images locally, pushes them to a registry, and deploys to a remote server via SSH. The pipeline handles SSH connection management, file transfers, and container orchestration with docker compose.

flowchart LR
    A[Dev Machine / CI<br/>aspire deploy] -->|SSH| B[Target Server<br/>docker compose up]
Loading

How It Works

The deployment pipeline executes in phases, with steps running in parallel where possible:

flowchart TD
    subgraph Configure
        A[Establish SSH] --> B[Configure Deployment]
        C[Process Parameters] --> D[Build Prerequisites]
    end

    subgraph Build & Push
        D --> E[Build Images]
        E --> F[Push to Registry]
    end

    subgraph Deploy
        F --> G[Prepare Compose Files]
        G --> H[Transfer Files via SCP]
        H --> I[docker compose up]
        I --> J[Health Checks]
    end

    J --> K[Done]
Loading

Phase breakdown:

  1. Configure - Establish SSH connection, gather parameters (registry, credentials, deploy path)
  2. Build - Build container images for each project in parallel
  3. Push - Push images to the configured container registry
  4. Deploy - Transfer compose files and .env to the remote server, run docker compose up
  5. Verify - Run health checks, extract dashboard token, cleanup SSH

Run aspire do diagnostics to see the full dependency graph for your application.

Quick Start

  1. Add the package feed:
dotnet nuget add source https://f.feedz.io/davidfowl/aspire/nuget/index.json --name davidfowl-aspire
  1. Install the package:
aspire add docker-sshdeploy

Or with the .NET CLI:

dotnet add package Aspire.Hosting.Docker.SshDeploy --prerelease
  1. Add SSH deployment support to your AppHost:
builder.AddDockerComposeEnvironment("env")
    .WithSshDeploySupport();

TypeScript AppHosts can reference the package from aspire.config.json, run aspire restore, and use the generated API:

import { createBuilder } from './.modules/aspire.js';

const builder = await createBuilder();

await builder.addDockerComposeEnvironment('env')
    .withSshDeploySupport();
  1. Deploy:
aspire deploy

The pipeline will prompt for SSH credentials, registry configuration, and deploy path.

Documentation

See the package README for:

  • Configuration options (appsettings.json, environment variables)
  • SSH authentication (key-based vs password)
  • Target host privacy settings
  • TypeScript AppHost setup

Sample Projects

See samples/DockerPipelinesSample for a complete C# AppHost example:

aspire run     # Run locally
aspire deploy  # Deploy to remote host

See samples/DockerPipelinesTypeScriptSample for a TypeScript AppHost sample that uses the generated Aspire.Hosting.Docker.SshDeploy APIs against the same API and web projects:

cd samples/DockerPipelinesTypeScriptSample
npm install
aspire restore
npm run build
aspire deploy

CI/CD with GitHub Actions

See .github/workflows/deploy.yml for a complete example using GitHub Container Registry with secrets for SSH credentials.

About

An extension of the docker compose integration for deploying to a docker host via SSH

Resources

Stars

138 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages