Guides

Deploy a Docker image from GHCR to your own server

Build your image with GitHub Actions, push it to GitHub Container Registry, and run it on your own Linux server behind HTTPS, with zero-downtime deploys and one-click rollback.

Updated

GitHub Actions builds your image on every push to main and pushes it to GitHub Container Registry (GHCR), tagged with the commit's short SHA and latest. Echowa pulls it onto your server, pins it to its digest, and rolls it out behind Traefik with a Let's Encrypt certificate. The old version keeps serving until the new one passes its healthcheck.

One step is still a click: you start each deploy from Echowa's UI. A signed webhook, so CI can start the deploy itself, is specified but not built yet.

What you need

  • A GitHub repository with a Dockerfile at its root.
  • An app that listens on a port and answers a health check, such as GET /up returning 200.
  • A server running Ubuntu 24.04 or 26.04, or Debian 12 or 13, with a public IPv4 address and nothing on ports 80 and 443. Echowa runs on amd64 and arm64.
  • A domain whose DNS A record points at the server.
  • Echowa on that server. The installer sets up Docker, a single-node Swarm, Traefik and Echowa, then prints a link to create your admin account. The install guide covers firewalls and the other ways to reach the UI.
curl -fsSL https://get.echowa.dev/install.sh | sudo bash

1. Build and push the image from GitHub Actions

Add the following workflow to your repository. It builds the image on every push to main and pushes it to GHCR.

.github/workflows/image.yml
name: Image

on:
  push:
    branches: [main]

permissions:
  contents: read
  packages: write

jobs:
  image:
    runs-on: ubuntu-latest
    steps:
      - name: Image name and tags
        id: meta
        uses: docker/metadata-action@v6
        with:
          images: ghcr.io/${{ github.repository }}
          tags: |
            type=sha
            type=raw,value=latest,enable={{is_default_branch}}

      - name: Log in to GHCR
        uses: docker/login-action@v4
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - uses: docker/setup-buildx-action@v4

      - name: Build and push
        uses: docker/build-push-action@v7
        with:
          push: true
          platforms: linux/amd64
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          cache-from: type=gha
          cache-to: type=gha,mode=max

Here's what each part does:

  • permissions lets the workflow's built-in GITHUB_TOKEN push to GHCR, so there's no secret to create.
  • docker/metadata-action names the image ghcr.io/<owner>/<repo>, lowercased as GHCR requires. It tags each build sha- plus the commit's short SHA, such as sha-860c190, and adds latest on the default branch. It also adds the org.opencontainers.image.source label, which links the package to your repository.
  • platforms: linux/amd64 builds for an x86 server. For an arm64 server, change it to linux/arm64 and run the job on GitHub's arm64 runner, ubuntu-24.04-arm. Emulating arm64 on an x86 runner with docker/setup-qemu-action also works, but it's much slower.
  • cache-from and cache-to keep Docker's layer cache in GitHub Actions, so a build only redoes the layers that changed.
  • The build uses your repository at the pushed commit as its context, so the workflow needs no checkout step.

Push to main. When the run finishes, the image is listed under Packages on your repository's page.

2. Let your server pull the image

A new GHCR package is private. Either make it public, or give Echowa a token that can read it.

Make the package public

Do this only if anyone may download the image. Open the package on GitHub, choose Package settings, and under Danger Zone choose Change visibility, then Public. GitHub doesn't let you make a public package private again.

Keep it private and add a token

GHCR accepts classic personal access tokens only.

  1. On GitHub, open Settings, Developer settings, Personal access tokens, then Tokens (classic), and generate a classic token.
  2. Give it an expiry and only the read:packages scope. It can then pull images and nothing else.
  3. In Echowa, open Registries and choose Add registry. Set Name to ghcr, Host to ghcr.io, Username to your GitHub username, and Token to the new token.

Echowa encrypts the token and sends it only to ghcr.io, with each pull. It never stores it in Docker. When the token expires, edit the registry and paste a new one.

3. Create the app in Echowa

On the dashboard, choose New app, then Your own image, and fill in the form:

  • Name: lowercase letters, digits and hyphens, such as blog. It names the Swarm service, echowa-blog, and can't be changed later.
  • Image repository: ghcr.io/<owner>/<repo>, without a tag.
  • Default tag: latest.
  • Registry: None for a public package, or the ghcr registry from step 2.
  • Container port: the port your app listens on inside the container, such as 3000.
  • Healthcheck command: a command that succeeds only once the app can serve, such as wget -qO- http://localhost:3000/up || exit 1. It runs inside the container, so use a tool the image has: curl and wget aren't in every base image. Leave it empty to use the image's own HEALTHCHECK.
  • Domain: such as app.example.com, with HTTPS with a Let's Encrypt certificate ticked.

Choose Create app. Then add your app's variables in its Environment section, or paste a .env file. Values are encrypted at rest, and changes apply on the next deploy.

4. Deploy

Choose Deploy on the app's page. Tag or digest defaults to latest. Enter a tag such as sha-860c190 to deploy one particular build. Echowa then:

  1. Pulls the image and records its digest, so the deployment names exactly one image even after latest moves on.
  2. Creates or updates the Swarm service. On an update, the new container starts beside the old one and has to pass its healthcheck.
  3. Routes the domain to it through Traefik, which gets a Let's Encrypt certificate for it.

The deployment page streams each step as it happens, and ends in succeeded, failed or rolled back. Open the domain once it succeeds.

5. Ship the next version

Push to main, wait for the workflow, and choose Deploy again, with latest or the new sha- tag. Swarm starts the new version first, waits for its healthcheck, then stops the old one. If the new version never passes, the old one keeps running and the deployment is recorded as rolled back.

To go back to an earlier version, open Deployments and choose Redeploy on any earlier success. Echowa keeps each app's last five successful images on disk, so a rollback doesn't pull anything.

When something goes wrong

  • The pull is unauthorised or denied. The package is private and the app has no registry, or the token lacks read:packages or has expired.
  • The pull or the deploy mentions the platform, or "no matching manifest". The image was built for a different CPU. Compare platforms in the workflow with uname -m on the server: x86_64 is amd64 and aarch64 is arm64.
  • The deploy is rolled back. The new version never passed its healthcheck. Read that deploy's output in the Logs tab, and check that the healthcheck command exists in the image and uses the container port.
  • No certificate. The domain doesn't point at the server yet, or something blocks ports 80 and 443. The app's Domains tab shows where the domain resolves and which certificate Traefik serves.

Doing it without Echowa

The image runs anywhere Docker does. On a bare server, you'd log in to GHCR with the same classic token and run the image yourself:

echo "$GHCR_TOKEN" | docker login ghcr.io -u <github-username> --password-stdin
docker pull ghcr.io/<owner>/<repo>:latest
docker run -d --name app --restart unless-stopped -p 80:3000 ghcr.io/<owner>/<repo>:latest

That serves the app, but each update means stopping the old container before the new one can take its port, and there's no HTTPS, healthcheck gate, deploy history or rollback. Those are the parts Echowa adds, with Docker Swarm and Traefik doing the work underneath.