DevOps

Shipping .NET with Docker and GitHub Actions

Maya Sharma August 15, 2026 1 min read 1 view (1 unique)
Shipping .NET with Docker and GitHub Actions

A small, honest pipeline: build once, test the artefact you built, and promote the same image to production.

Build once, promote everywhere

The cardinal rule of a deployment pipeline is that the artefact you tested is the artefact you ship. Everything below follows from it.

The Dockerfile

FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY . .
RUN dotnet publish source/TechieBlog/TechieBlog.csproj -c Release -o /app

FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "TechieBlog.dll"]

The workflow

name: build
on:
  push:
    branches: [ main ]

jobs:
  container:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: docker build -t techieblog:${{ github.sha }} .
      - run: docker run --rm techieblog:${{ github.sha }} --version

Things worth doing early

  1. Tag images with the commit SHA, never with latest.
  2. Run migrations from the application at startup, so a rollback of the image is a rollback of the schema expectation too.
  3. Keep secrets in the platform's secret store; a connection string in an environment file will eventually be committed.
  4. Fail the build on a failing smoke test, not on a warning count.

A pipeline nobody trusts gets bypassed. Make it fast enough that bypassing it is never tempting.

Rate this article
4.5 · 2 ratings One rating per email — no sign-in needed
MS
Maya Sharma Author of this post.

More Posts

Comments (0)

No comments yet

Be the first to share your thoughts on this post.

Leave a comment

No account needed — just your name and email.

Your email is never published — it is used only for confirmation and moderation.
Generated and checked by this site — no third-party service.
Comments appear after email confirmation and moderation.
An unhandled error has occurred. Reload ×