Dokploy on Your Own Server. Part 3: Deploying a .NET application with GitHub Actions and Dokploy
All parts of the series “Dokploy on Your Own Server”In the previous part, we prepared the panel, GitHub access, and a private registry. Now we will connect them: a new tag in the application repository triggers checks, an image build, and deployment through the Dokploy API.
A small website is enough. It displays its version and whether a secret setting exists; /health returns the same information as JSON. All application messages are English. A database would distract from the deployment process here.
Two repositories, one release
Source code lives in leschenko-by/dokploy-dotnet-demo; Compose lives in leschenko-by/dokploy-dotnet-deploy. Both repositories are private and use master. To reproduce this without access to my organization, create your own repositories. The main files are shown below; complete source, the smoke check, and deployment script tests are available in the archives.
dokploy-dotnet-demo.zip · dokploy-dotnet-deploy.zip
git tag v1.1.0 in the application repository
↓
GitHub Actions: build → smoke → deployment script tests
↓
publish ghcr.io/<owner>/dokploy-dotnet-demo:v1.1.0
↓
Dokploy API: change TAG_ID → deploy Compose → wait for deployment
↓
check public HTTPS /health for version 1.1.0
CI builds the image once. The server does not compile source. Compose substitutes the selected tag while configuration remains in the second repository. The example uses unique version tags; do not republish a released tag. Digests provide stricter artifact pinning, but a version number keeps this example easier to follow.
The application
Create a project targeting .NET 10 LTS:
dotnet new web -n DokployDemo -f net10.0
cd DokployDemo
Remove unused template configuration and use this project file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.1.0</Version>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
</Project>
Program.cs:
using System.Net;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
var version = Assembly.GetExecutingAssembly().GetName().Version?.ToString(3) ?? "unknown";
var configured = !string.IsNullOrWhiteSpace(app.Configuration["APP_SECRET"]);
app.Logger.LogInformation("Starting Dokploy demo version {Version}; secret configured: {Configured}", version, configured);
app.MapGet("/health", () => Results.Ok(new { status = "healthy", version, secretConfigured = configured }));
app.MapGet("/", () => Results.Content($$"""
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dokploy .NET Demo</title>
<style>
* { box-sizing: border-box; } body { margin: 0; background: #10151d; color: #eef4fb; font: 18px/1.6 system-ui, sans-serif; }
main { max-width: 880px; margin: 110px auto; padding: 48px; border: 1px solid #314054; border-radius: 20px; background: #18212d; }
.eyebrow { color: #7bd7c2; text-transform: uppercase; letter-spacing: .16em; font-size: 14px; }
h1 { font-size: 44px; line-height: 1.2; margin: 16px 0; } p { color: #bdcad9; }
dl { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 36px; } dt { color: #94a7bd; } dd { margin: 0; text-align: right; font-weight: 600; }
a { color: #7bd7c2; } @media (max-width: 700px) { main { margin: 24px; padding: 28px; } h1 { font-size: 32px; } }
</style>
</head>
<body><main>
<div class="eyebrow">GitHub Actions → GHCR → Dokploy</div>
<h1>Your application is running.</h1>
<p>A small ASP.NET Core application deployed from a private container registry. Application code and deployment configuration live in separate repositories.</p>
<dl><dt>Application version</dt><dd>{{WebUtility.HtmlEncode(version)}}</dd>
<dt>Secret configured</dt><dd>{{(configured ? "Yes" : "No")}}</dd>
<dt>Runtime</dt><dd>.NET {{Environment.Version.Major}}</dd></dl>
<p><a href="/health">Check application health</a></p>
</main></body></html>
""", "text/html; charset=utf-8"));
app.Run();
ASP.NET Core configuration reads APP_SECRET. The application only reports whether a nonempty value exists. This is a teaching setting, not an authorization system; the value is never sent to the browser or written to logs. /health checks the running process, not external dependencies, because this application has none.
Build Release locally and run the smoke check from the archive:
dotnet build -c Release
python tools/smoke.py
python -m unittest discover -s tools/tests -p 'test_*.py'
The smoke check starts the real process on a free loopback port, supplies a random secret, and checks HTML and JSON before stopping it. It also verifies that neither response contains the secret value.
The container
The Dockerfile has separate build and runtime stages:
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY DokployDemo.csproj ./
RUN dotnet restore
COPY Program.cs ./
ARG VERSION=1.0.0
RUN dotnet publish -c Release --no-restore -p:Version=${VERSION#v} -o /out
FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
COPY --from=build /out ./
USER $APP_UID
ENV ASPNETCORE_HTTP_PORTS=8080
EXPOSE 8080
ENTRYPOINT ["dotnet", "DokployDemo.dll"]
The SDK stays in the build image. Only the publish output reaches the runtime image; the process uses the image's non-root user and listens on 8080. Exclude .git, .github, bin, obj, and tools in .dockerignore.
The version comes from a build argument. ${VERSION#v} removes the leading v, so image tag v1.1.0 produces assembly version 1.1.0. Both the page and health response show that version.
Compose in the second repository
Place docker-compose.yml at the root of dokploy-dotnet-deploy:
services:
web:
image: ghcr.io/leschenko-by/dokploy-dotnet-demo:${TAG_ID:?Set TAG_ID in Dokploy Environment}
restart: unless-stopped
environment:
APP_SECRET: ${APP_SECRET:?Set APP_SECRET in Dokploy Environment}
networks:
- dokploy-network
labels:
traefik.enable: "true"
traefik.docker.network: dokploy-network
traefik.http.routers.dotnet-demo.rule: Host(`${APP_HOST:?Set APP_HOST in Dokploy Environment}`)
traefik.http.routers.dotnet-demo.entrypoints: websecure
traefik.http.routers.dotnet-demo.tls.certresolver: letsencrypt
traefik.http.services.dotnet-demo.loadbalancer.server.port: "8080"
networks:
dokploy-network:
external: true
Replace the image owner with your own. APP_HOST comes from Environment rather than a hardcoded domain. The service joins the external dokploy-network shared with Traefik. No application port is published on the host; the proxy connects to container port 8080.
Entrypoint and certificate resolver names must match the server configuration from part two. Labels own the route, so do not create a second one in Domains UI. If the server already has a router named dotnet-demo, choose unique router and service names.
In Dokploy, create a project and a Compose service, select GitHub, the configuration repository, branch master, and path ./docker-compose.yml. Disable Auto Deploy: the application workflow is the only release initiator in this example. A new Compose commit takes effect at the next explicit deployment. If you later enable push deployments for configuration changes, coordinate them with the release process separately.
Set Environment to:
TAG_ID=v1.0.0
APP_HOST=app.example.com
APP_SECRET=<generate-a-random-secret>
The last line marks where your own random value belongs; it is not a ready-to-use secret. Enable Create Environment File. A variable appearing in the panel does not automatically reach a container: the Compose environment mapping does that. GHCR credentials are already configured separately in Registry.

API permissions
Create a technical user with the Member role. Allow API access and service configuration operations, then grant access to this project, environment, and Compose service. Docker, Traefik, SSH administration, and deletion are unnecessary. Verify access boundaries with actual API requests, rather than relying on the role's name.
In the technical user's Profile, create an API key. Use a polling-compatible limit, such as 120 requests per minute. Polling every five seconds already makes about 12 requests a minute; a limit of ten requests per day is insufficient.
Under the application repository's Settings → Secrets and variables → Actions, add secret DOKPLOY_API_KEY and these variables:
DOKPLOY_URL=https://panel.example.com
DOKPLOY_COMPOSE_ID=<ID of the Compose service>
DOKPLOY_APP_URL=https://app.example.com
CI does not need a separate PAT to build and publish to GHCR: it uses temporary GITHUB_TOKEN. The server's pull token and the panel's API key do not replace it.
The workflow
.github/workflows/release.yml:
name: Verify and release
on:
push:
branches: [master]
tags: ['v*']
pull_request:
branches: [master]
permissions:
contents: read
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: dotnet build -c Release
- run: python tools/smoke.py
- run: python -m unittest discover -s tools/tests -p 'test_*.py'
image:
if: startsWith(github.ref, 'refs/tags/v')
needs: verify
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Validate release tag
env:
RELEASE_TAG: ${{ github.ref_name }}
run: '[[ "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]'
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ghcr.io/leschenko-by/dokploy-dotnet-demo:${{ github.ref_name }}
build-args: VERSION=${{ github.ref_name }}
labels: org.opencontainers.image.source=https://github.com/leschenko-by/dokploy-dotnet-demo
deploy:
needs: image
runs-on: ubuntu-latest
concurrency:
group: dokploy-demo-production
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Deploy and wait
env:
DOKPLOY_API_KEY: ${{ secrets.DOKPLOY_API_KEY }}
DOKPLOY_URL: ${{ vars.DOKPLOY_URL }}
DOKPLOY_COMPOSE_ID: ${{ vars.DOKPLOY_COMPOSE_ID }}
run: python tools/deploy_dokploy.py --tag "$GITHUB_REF_NAME"
- name: Verify public HTTPS release
env:
DOKPLOY_APP_URL: ${{ vars.DOKPLOY_APP_URL }}
run: python tools/verify_release.py
Pushes to master and pull requests run verification. A vMAJOR.MINOR.PATCH tag also publishes and deploys after those checks. needs prevents image publication after a failed build and deployment after failed publication.
Concurrency does not cancel a running deployment. GitHub can replace an older pending job with a newer one, though: this avoids overlapping operations but does not guarantee a queue containing every release. The script also refuses automatic downgrades between ordinary semantic versions.

The deployment script
The complete tools/deploy_dokploy.py is included in the archive. It uses Python's standard library and follows this request sequence:
GET /api/compose.one?composeId=...
GET /api/deployment.allByCompose?composeId=...
POST /api/compose.update {composeId, env}
POST /api/compose.deploy {composeId, title, description}
GET /api/deployment.allByCompose?composeId=... until done/error/timeout
Requests authenticate with x-api-key. Before changing anything, the script reads Environment and snapshots deployment IDs. It replaces only the actual TAG_ID assignment, preserving the remaining lines, including multiline values. Duplicate TAG_ID assignments are a configuration error.
The operation title contains the tag, run ID, and attempt, but titles are insufficient: Dokploy 0.31.4 can replace one with the Git commit message. The script therefore tracks the deployment ID. If the title changes before the first poll, it only accepts a single new record relative to the snapshot. Several candidates cause an ambiguity error.
It polls every five seconds, with a 20-minute deadline. It never automatically retries a POST because the response could be lost after the job was queued. A network error, deployment failure, or timeout fails the job. The selected TAG_ID remains changed; there is no automatic rollback. Inspect the actual Dokploy state before deciding whether to retry.
After done, the workflow runs tools/verify_release.py:
"""Verify the deployed release over public HTTPS without returning response bodies."""
import json
import os
import sys
import time
import urllib.error
import urllib.parse
import urllib.request
url = os.environ.get('DOKPLOY_APP_URL', '').rstrip('/')
parsed = urllib.parse.urlsplit(url)
if parsed.scheme != 'https' or not parsed.hostname or parsed.username or parsed.password or parsed.query or parsed.fragment:
sys.exit('DOKPLOY_APP_URL must be an HTTPS origin.')
expected = os.environ['GITHUB_REF_NAME'].removeprefix('v')
deadline = time.monotonic() + 90
while time.monotonic() < deadline:
try:
with urllib.request.urlopen(url + '/health', timeout=10) as response:
body = json.load(response)
if body.get('status') == 'healthy' and body.get('version') == expected and body.get('secretConfigured') is True:
print(f'Public HTTPS health check passed for version {expected}.')
break
except (OSError, ValueError):
pass
time.sleep(3)
else:
sys.exit('Public HTTPS health check failed or the expected version is not running.')
This is a separate gate: it waits up to 90 seconds for public HTTPS to return the expected version and secretConfigured: true. It does not print secret values or error response bodies.
Release two versions
The first release:
git add .
git commit -m "Add the application and release workflow"
git push origin master
git tag v1.0.0
git push origin v1.0.0
The first publication creates the package. Check that it is private, the workflow can publish, and the pull-token account can download it. If the first deployment fails because of GHCR access, correct permissions, inspect deployment history, and rerun only the necessary job.
For the next release, change the application, push the commit, and tag it v1.1.0. No Compose commit is required: CI updates TAG_ID through the API.

Expected response:
{"status":"healthy","version":"1.1.0","secretConfigured":true}
After updating, separately verify that Environment still contains the original APP_SECRET. secretConfigured: true establishes that a value exists, not that it is unchanged.

This is one container deployed with regular Compose. Replacement can cause a brief interruption. We verify the update's result without promising zero-downtime deployment.
On November 19, 2026, the lab completed releases v1.0.0 and v1.1.0, 13 deployment-script tests, and the application smoke check. The second release passed public HTTPS verification in CI and retained the original secret. A separate v0.0.0 tag with an intentional compilation error failed at verify: image and deploy were skipped, leaving version 1.1.0 running. The CI key was also denied access to an unrelated Compose service.
Next, we will look at the additional questions raised by one of my pet projects.
Only registered users can leave a comment.
Sign in or register to leave a comment.