Tugboat.Aspire.Hosting 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Tugboat.Aspire.Hosting --version 0.2.0
                    
NuGet\Install-Package Tugboat.Aspire.Hosting -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tugboat.Aspire.Hosting" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tugboat.Aspire.Hosting" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Tugboat.Aspire.Hosting" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Tugboat.Aspire.Hosting --version 0.2.0
                    
#r "nuget: Tugboat.Aspire.Hosting, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Tugboat.Aspire.Hosting@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Tugboat.Aspire.Hosting&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Tugboat.Aspire.Hosting&version=0.2.0
                    
Install as a Cake Tool

Tugboat

Tugboat is a two-part deployment system for running Aspire applications on a single Docker VPS with health-gated, blue/green releases.

  • tugboat-proxy is the stable edge container. It owns public ports and swaps an application's host routes only after every target in a release is healthy.
  • Tugboat.Aspire.Hosting contributes an Aspire deployment pipeline through AddDockerComposeEnvironment("Production").AddTugboat(). Its types live in the Aspire.Hosting.Tugboat namespace, alongside the rest of Aspire.Hosting.

The intended deployment flow is documented in docs/architecture.md. The disposable Linux/OpenSSH/Docker end-to-end fixture is documented in docs/real-vps-e2e.md. How the two artifacts are versioned and published is documented in docs/releasing.md.

Installation

dotnet add package Tugboat.Aspire.Hosting

The package and the proxy image ship as one version, and the package starts the exact proxy image digest it was tested against. The VPS pulls that image itself on the first deployment, so docker and ssh remain the only local requirements. Override it — with a digest — only to run a proxy you build yourself:

options.ProxyImage = "ghcr.io/odumpling/tugboat-proxy@sha256:...";

Repository status

The proxy supports persistent routes, batch health checks, atomic cutover, request draining, and automatic HTTPS through ACME. The Aspire package wires proxy bootstrap, immutable image transfer, release upload, candidate startup, route activation, and previous-release shutdown into the deployment pipeline.

Proxy development

cd src/Tugboat.Proxy
go test ./...
cd integration/acme && go test -race ./...
go run ./cmd/tugboat-proxy serve --http-address :8080 --control-address ./tugboat.sock

AppHost shape

using Aspire.Hosting.Tugboat;

var production = builder.AddTugboatEnvironment("Production", options =>
{
    options.Host = "ovh-vps"; // An alias from ~/.ssh/config is recommended.
    options.ApplicationName = "my-app";
    // External endpoints become <resource-name>.example.com.
    options.RouteDomain = "example.com";
    options.AutomaticHttps = true;
    options.RedirectHttp = true;
    options.AcmeEmail = "operations@example.com";
});

builder.AddProject<Projects.Api>("api")
    .WithExternalHttpEndpoints()
    .WithTugboatHealthCheck("/health");

// Optional explicit override for apex/alternate hosts, health paths, and timeouts.
builder.AddProject<Projects.Web>("web")
    .WithTugboatHealthCheck("/health")
    .WithTugboatRoute("example.com");

AddTugboatEnvironment wraps AddDockerComposeEnvironment(...).WithDashboard(false).AddTugboat(...). Use the composed form when you need to customize the Compose environment. The Docker hosting package is already a transitive dependency. Tugboat preserves Aspire's Compose generation and image build steps and replaces local Compose startup with remote deployment.

Route arguments inherit their endpoint port and environment health/TLS defaults when omitted. Explicit values take precedence, including explicit false TLS flags. Conventional project HTTP endpoints without a target port use 8080 during publishing; ambiguous endpoint choices still require explicit configuration. Existing overloads remain available; newly compiled calls that omit health/TLS arguments now inherit defaults. Previously compiled calls may still pass the old baked-in /up default.

Options bind from the Tugboat configuration section before the callback runs. For example, configure a hostname for an external endpoint without writing it in code:

{
  "Tugboat": {
    "Host": "ovh-vps",
    "RouteHosts": { "api": "shipyard.example.com" },
    "HealthCheckPath": "/health"
  }
}

Explicit WithTugboatRoute hosts take precedence over RouteHosts, which takes precedence over <resource>.<RouteDomain>. RemoteRoot defaults to the SSH user's home directory; Tugboat resolves it to an absolute path before using SCP/SFTP.

First deployment and doctor

Install Docker and the Compose plugin on the VPS, and ensure the SSH user can run docker info without an interactive sudo prompt. Configure your SSH alias and host key first, then run:

aspire do tugboat-doctor-Production
aspire deploy

Doctor checks non-interactive SSH authentication, local and remote Docker/Compose access, the resolved remote root, origin TCP connectivity from the deploying machine, and route DNS. It validates existing generated Compose output when present. It does not build images, start a listener, change firewall rules, or obtain certificates. On a fresh VPS, an unreachable port can simply mean the proxy has not started yet. Run doctor again after deployment to check outside-in reachability. CDN-only origins may intentionally reject direct connections from the deploying machine.

Deploy always performs the required access checks before building, then validates generated Compose and every expected image before transfer. These correctness checks are mandatory. The selected .env.<environment> file (or .env fallback) is logged. Tugboat preserves existing env values and uploads a resolved Compose snapshot so the VPS cannot substitute different shell values. Do not delete publish output just to retry. When Compose reports an empty port, set targetPort on the corresponding endpoint; arbitrary container endpoints do not receive a guessed port.

Services publishing host ports are reported, including the Aspire dashboard. With the composed entry point, use .WithDashboard(false) unless you intend to expose and secure the dashboard separately. An expose entry is sufficient for private container networking. Fixed container_name values are rejected because separate releases need separate containers.

Health endpoints in Production

Aspire ServiceDefaults templates commonly map /health and /alive inside an app.Environment.IsDevelopment() condition. A container runs in Production, so move the health endpoint mapping outside that condition:

public static WebApplication MapDefaultEndpoints(this WebApplication app)
{
    app.MapHealthChecks("/health");
    // Keep other development-only endpoints inside their existing condition.
    return app;
}

WithTugboatHealthCheck("/health") declares the path for both Aspire and Tugboat. Aspire 13.4/13.5's ordinary WithHttpHealthCheck exposes a registration key rather than structured HTTP metadata, so Tugboat does not parse that key or reflect into Aspire internals. When keeping the ordinary helper, set Tugboat:HealthCheckPath or the route's healthCheckPath as well. Explicit route paths override the shared helper, which overrides the environment default. The final fallback remains /up for compatibility; it must be an endpoint your application actually serves.

Health failures include the last HTTP status or connection error and candidate container state. Debug pipeline logging adds the last 50 application log lines; those logs may contain application secrets, so treat debug transcripts accordingly.

Image transfer

Tugboat transfers the actual output of Aspire's local image build and writes a release-specific Compose image override. No WithRemoteImageTag("latest") workaround is needed for Aspire's generated aspire-deploy-* tag. Custom project build names and tags are respected. A missing expected build output fails before image transfer; registry dependencies, including Docker Hub shorthand such as redis:7, remain pullable dependencies. A zero-transfer deployment can therefore be valid. Summaries show transferred images, registry dependencies, transport method and duration.

Images move from the local Docker daemon into the VPS image store over SSH, with no external registry and no Docker CLI plugin. The pipeline starts a short-lived Unregistry container on the VPS, publishes it on the remote loopback interface only, tunnels a local port to it, and pushes the release images through that tunnel. Layers already on the VPS are skipped, so a redeploy transfers only what changed. One Unregistry container serves a whole release and is removed as soon as the transfer ends, including on failure.

The VPS pulls the Unregistry image itself, so docker and ssh remain the only local requirements. Both are configurable:

options.UnregistryImage = "ghcr.io/psviderski/unregistry:0.4.1";
// Set only when the VPS keeps its containerd socket somewhere unusual.
options.RemoteContainerdSocket = "/run/docker/containerd/containerd.sock";

Unregistry needs the local daemon to reach the tunnel on the host loopback. A daemon running inside a VM (Docker Desktop, Rancher Desktop, Colima) issues the registry request from the VM's own network namespace, where that port does not exist, and Docker trusts only 127.0.0.0/8 as an insecure registry — so there is no address that is both reachable and usable without host configuration. On those hosts Tugboat streams images instead, piping docker save into docker load over the same SSH connection. That is correct but transfers whole images, so unchanged layers are re-sent; the pipeline logs when it happens. Native Linux daemons and OrbStack share the host loopback and keep the deduplicated Unregistry path.

Automatic HTTPS prerequisites

Public TCP ports 80 and 443 must reach the proxy. Every HTTPS hostname needs a public A/AAAA record pointing at the VPS before its route is activated; port 80 must remain reachable for ACME HTTP-01 issuance and renewal even when the route redirects normal HTTP requests. Firewalls, load balancers, and NAT must preserve those paths.

Routes remain HTTP-only unless automaticHttps is enabled. redirectHttp is an independent per-route choice but is valid only with automatic HTTPS. Initial issuance runs asynchronously after atomic route activation, so existing HTTP and HTTPS traffic is never paused while the CA validates a new hostname. A requested HTTP redirect starts only after that hostname has a valid certificate. HTTPS for a new name fails closed until then; Tugboat never falls back to another hostname's certificate or performs issuance in a client handshake.

Routes persist in tugboat-proxy-state; ACME account keys and certificates persist separately in tugboat-proxy-certificates, whose contents are private to the proxy and created with restrictive permissions. A proxy restart immediately reloads still-valid cached certificates. Renewal begins before expiry; failures are logged without deleting or replacing the valid cached certificate and are retried by Go's ACME manager.

Leave Tugboat:AcmeDirectory unset for Let's Encrypt production. For staging or CI, set it to an HTTP(S) ACME directory such as Pebble and point test DNS/challenge routing at the proxy. The repository's local ACME integration test uses an in-process authority and never contacts public DNS or a production CA.

Behind a CDN or another reverse proxy

Without automatic HTTPS or a supplied certificate, the origin serves HTTP only. An HTTPS connection from Cloudflare Full/Full (strict) then fails with error 525. Cloudflare Flexible uses plaintext HTTP to the origin; it is a workaround, not encrypted origin transport. Prefer Full (strict) with a valid origin certificate. Cloudflare Full matches the incoming request protocol, so proxied DNS does not inherently prevent ACME HTTP-01. Ensure redirects, WAF rules and caching preserve the challenge URL. A temporary DNS-only record is another way to bootstrap ACME.

Supply a PEM certificate chain and matching unencrypted PEM private key, including a Cloudflare Origin CA certificate, without enabling ACME:

options.AutomaticHttps = false;
options.RedirectHttp = true;
options.OriginCertificatePath = "/secure/origin-chain.pem";
options.OriginKeyPath = "/secure/origin-key.pem";

These paths are on the deploying machine. Tugboat verifies the key pair, validity period and coverage of every route hostname, then installs the material through SSH into the proxy's private certificate volume. Routes contain only a content hash. Unknown SNI names fail closed. Rotation installs a new version; retained releases keep their original certificate selection for rollback. Certificate files are retained independently of release pruning, and supplied certificates are not automatically renewed. Keep them available and valid for as long as rollback is required. This support requires a proxy built from the matching Tugboat release.

For a smoke test before DNS exists, preserve the intended hostname:

curl --resolve shipyard.example.com:80:203.0.113.10 http://shipyard.example.com/

With ufw-docker, Docker-published ports are filtered as forwarded traffic. If the corresponding forward rules are absent, the operator can allow them with:

sudo ufw route allow proto tcp from any to any port 80
sudo ufw route allow proto tcp from any to any port 443

Apply these only to that firewall setup and adjust the ports/source restrictions for your origin policy. Plain Docker/UFW can instead bypass UFW's INPUT rules. A successful curl from the VPS to its own public IP does not prove outside-in reachability. Provider firewalls and NAT are separate from host firewall rules.

Coding standard

C# style and analyzer rules are Aspire's, adopted verbatim in .editorconfig. EnforceCodeStyleInBuild and TreatWarningsAsErrors make them build errors, so dotnet build is the gate for everything the analyzers see. dotnet format Tugboat.slnx --verify-no-changes covers what they do not — whitespace and import ordering — and runs in tests/e2e/RealVps/static-checks.sh.

Three deliberate deviations from Aspire:

  • the file header carries this repository's own attribution, because Tugboat is not a .NET Foundation project;
  • shell scripts stay 2-space indented, matching the scripts already here; and
  • Aspire's Arcade SDK, public API analyzers, and central package management are not adopted, since they are repository infrastructure rather than coding style.

Reformat with dotnet format Tugboat.slnx.

Rollback

Each deployment gets a unique ID, even when the Git commit has not changed. The commit and dirty-tree status are recorded separately in private release.json metadata. GITHUB_SHA/CI_COMMIT_SHA are provenance, not deployment IDs. This keeps new Compose projects and image tags separate from the active release until cutover. For deterministic CI naming, set Tugboat:ReleaseId to a unique run ID. Reusing an existing release directory or Compose project fails before build/transfer; retries should use a new ID. Existing retained releases from 0.1.0 remain valid rollback targets.

Reactivate the release immediately preceding the current release with the environment-specific rollback step:

aspire do rollback-Production

To select another retained release, set Tugboat:RollbackRelease. Environment variables use .NET configuration's double-underscore form:

Tugboat__RollbackRelease=a1b2c3d aspire do rollback-Production

The value is a release ID, not a path; it may contain only lowercase letters, digits, underscores, and hyphens. Rollback uses the retained Compose, environment, immutable image override, and route manifest. It does not build, pull, transfer, or retag images. All saved routes are health-checked and cut over as one proxy operation. The current link changes only after that operation succeeds, and the replaced release is then stopped.

Release retention

Tugboat:ReleasesToKeep defaults to five. Cleanup always retains at least two complete releases even if a lower value is configured. The current and previous links, every release referenced by the proxy, and every running Compose project are additional protections and can make the retained set larger.

Cleanup runs after a successful cutover. It removes old immutable :tugboat-<release> image tags and then their explicit release directories. Incomplete uploads are eligible for the same idempotent cleanup. Invalid release names are never used in remote commands. Cleanup failures are emitted as warnings and leave retry state in place; they do not fail or roll back a release that is already serving traffic.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.1 283 9/11/2026
0.2.0 404 9/10/2026
0.1.0 142 9/8/2026