Skip to content

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

Notifications You must be signed in to change notification settings

shefat2002/aspire-ssh-deploy

 
 

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();
  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

Sample Project

See samples/DockerPipelinesSample for a complete example:

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

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

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%