Tugboat.Aspire.Hosting 0.2.1

dotnet add package Tugboat.Aspire.Hosting --version 0.2.1
                    
NuGet\Install-Package Tugboat.Aspire.Hosting -Version 0.2.1
                    
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.1" />
                    
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.1" />
                    
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.1
                    
#r "nuget: Tugboat.Aspire.Hosting, 0.2.1"
                    
#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.1
                    
#: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.1
                    
Install as a Cake Addin
#tool nuget:?package=Tugboat.Aspire.Hosting&version=0.2.1
                    
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:...";

Upgrading the shared proxy

A package update does not silently replace an existing proxy. Deploy reports the configured desired reference and the running container reference/ID, each with a typed native-platform image identity. On a supported containerd image store it compares the selected platform manifest, not the parent multi-platform index or configuration digest. Recognized classic stores use configuration IDs and actual platform metadata. Unknown identity or a mismatch stops deploy before release reservation, certificate installation, or application image transfer. The HTTPS capability label alone is not proof that the image matches.

Pause deploy, rollback, and manual proxy writes for all applications sharing the host, coordinate their package/image pins, and schedule an interruption:

aspire do tugboat-upgrade-proxy-Production

Use your Compose environment's suffix instead of Production. This independent step does not build or deploy an application, reserve a release, or install a certificate. It acquires the desired image before interrupting service. Registry images require SSH and Docker on the VPS, without a local Docker build/Compose prerequisite. Local development images use the existing native-image transfer checks. The remote host needs timeout and bash; containerd identity inspection needs Docker CLI/Engine API 1.49+ and image inspect --platform support.

A healthy matching image is a no-op that preserves the container ID. Otherwise, the step validates the standard Tugboat layout, retains the original container, disables its automatic restart, stops it, and creates the selected immutable image using the same named route and certificate volumes. It preserves supported published TCP bindings (including host IPs), restart policy/retry count, serve arguments, and configured bridge network. /run/tugboat receives a fresh anonymous volume. Extra mounts/networks, custom volume drivers/options, static addresses, custom environment/user/security/runtime/resource settings, and conflicting options are refused before stopping the old proxy. Unset/null or empty Docker stop signals are accepted; custom stop signals and nonempty per-device I/O throttle/weight settings are refused. Stopped matching containers are started in place during ordinary bootstrap; missing containers are created only during bootstrap. Neither path implicitly replaces a container.

Upgrade readiness checks the running image, normalized complete route state, and published HTTP/HTTPS listener reachability through the VPS. Listener checks are not a certificate-chain or end-to-end application test; verify public routes and TLS after maintenance. All apps can lose active connections during the swap.

If start or readiness fails conclusively, or readiness is canceled after all preceding mutations completed, independently bounded recovery stops and removes only the transaction-owned candidate, restores the original container name/restart policy, and verifies its original image, complete routes, and public listeners. The command still reports the original upgrade failure. Recovery supports the source-verified compatible 0.1.0 → current transition on unchanged named volumes. It is functional recovery, not a filesystem snapshot: compatible ACME renewal may update cache bytes. There is no promise to restore arbitrary future schemas, malicious image writes, or post-upgrade downgrades. No named volumes or images are deleted. After commit, failure to remove the retained old container is a cleanup warning, never a reason to undo the upgrade.

Current clients share /tmp/tugboat-proxy-lock-<proxy-container-name> across bootstrap, certificate, network, deploy, rollback, and upgrade critical sections. They do not hold it across app builds/transfers. Old clients and manual Docker commands do not honor this lock and must remain paused during maintenance. A private recovery.json records transaction ownership, original/candidate IDs, name, restart policy, and phase. A stale lock is never stolen based on age.

If a mutating operation times out, loses its SSH response, or is canceled, its Docker daemon request may still execute later. Automatic recovery is skipped; the original/candidate containers and private record/lock remain for manual reconciliation. A later snapshot showing original readiness or no candidate does not establish completion of that request. First establish that all outstanding remote/daemon operations have completed.

If recovery cannot be verified, the lock and record also remain and further operations fail closed. Use the reported container IDs to stop and verify the owned candidate first; restore the original name and restart policy, start the original container, and verify routes and TLS before reconciling the record and removing the lock. Never start both cache writers or remove the persistent volumes. Keep a committed candidate running when the record says committed; reconcile only the stopped retained container and lock.

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. Build-output platform compatibility is checked after builds, before application transfer. Doctor 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 preserve the original HTTP status or connection error. Before safe candidate cleanup, normal output reports validated service/container state, exit code, OOM status, running image and host platforms, and the last failed Docker health check's timestamps and exit code when available. Missing evidence is marked unavailable. Image platforms use Docker's running image manifest descriptor, or a validated config image ID on a positively identified classic image store. Containerd and unknown stores never infer the running platform from an index default. Application logs, health output, and engine error text are stored privately under the resolved absolute release path printed by Tugboat: RELEASE/diagnostics. They are not copied to normal or debug pipeline output.

Retrieve evidence without rebuilding or restarting the rejected candidate:

umask 077
mkdir -m 700 ./candidate-diagnostics
scp -r 'deploy@vps:/home/deploy/.tugboat/myapp/releases/RELEASE/diagnostics' ./candidate-diagnostics/

Replace the host and absolute release path with your deployment's values. Treat these files as secrets. The fresh remote directory has mode 0700 and files are 0600 from creation; an existing directory or symlink is rejected. Evidence lasts until ordinary release pruning removes that release, so copy it promptly.

Capture has a 10-second local budget (8 seconds remotely), at most 16 containers, 50 log lines and 64 KiB of combined stdout/stderr per container, 8 KiB of private health/error evidence per container, a separate 4 KiB safe health summary, and less than 2 MiB total. The summary preserves the last retained failed probe even after a later success or private health output truncation. status.txt starts as incomplete; each evidence file's .status records the producer exit code and byte count. Reaching a byte cap means possibly truncated, even if the producer exits successfully. Nonzero producer status means unavailable, partial, or timed out; an incomplete marker also covers interrupted capture. Unsupported logging drivers or absent health history can leave evidence unavailable. Full capture requires compatible optional remote timeout -k and head -c tools, which are probed without installing anything. Cleanup requires feature-probed Bash process groups (including Alpine with Bash). A supervisor owns the cleanup group until it kills the whole group at eight seconds or immediately after the Compose parent exits, including remaining plugins and the timer. Ordinary completion stays fast; no delayed watchdog remains. Hosts without supported Bash group signaling retain the candidate. Cleanup uses a separate 15-second budget, preserves volumes, and leaves candidates running when off-traffic status cannot be established (including ambiguous hashed aliases).

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.

Tugboat discovers the VPS Docker daemon's Linux platform and validates every local application image before any application transfer or transfer-session setup. Project and Dockerfile outputs follow the same check. Build and load images for that target (for example, docker buildx build --platform linux/amd64 --load on an ARM64 deployer). An explicit Compose platform must match the native target; it is also honored for registry dependency pulls. Baseline aliases such as x86_64/amd64, aarch64/arm64, amd64/v1 and arm64/v8 are normalized. Emulation and higher CPU ISA capabilities are not assumed. Proxy infrastructure may bootstrap before application builds; a locally transferred development proxy receives the same native platform validation.

For a local containerd image store, Tugboat requires Docker CLI platform support and negotiated client/server API 1.49+ (inspect --platform: 1.49, save --platform: 1.48, push --platform: 1.46). Upgrade Docker and remove a lower DOCKER_API_VERSION override if necessary. Positively identified classic image stores retain their single-image export path without this version increase. Unknown stores fail with an actionable error.

Tugboat pins the local parent image ID, validates its selected platform metadata, and transfers only that platform through both streamed and Unregistry transport. Other index platforms and attestations are not transferred. Pinning protects against changes to the original source tag after planning; concurrent external retagging of Tugboat's transfer tags is unsupported. Metadata validation cannot prove binary or CPU compatibility, and unusual indexes with duplicate matching platforms may still be rejected by Docker during export or push.

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 282 9/11/2026
0.2.0 403 9/10/2026
0.1.0 141 9/8/2026