Skip to content

How to git push deploy to your own server

Nick Potts, who builds Ployz. Published , updated .

TL;DR: The cheapest way to git push deploy to your own server is a 10-line git hook on a $7 server, and the other four options run on the same server for the same price. What you're choosing is what happens around the push: whether a failed build takes the site down, whether you can roll back, and whether every pull request gets a preview.

  • Pick a git hook if you have one static site or hobby app and a few seconds of downtime per deploy is fine.
  • Pick GitHub Actions over SSH if you want deploy logs, secrets and approvals in GitHub without a new tool.
  • Pick Dokku if you want Heroku's exact workflow on one server, from the terminal.
  • Pick Kamal if you want kamal rollback and several servers from a CLI, and you're fine running a registry.
  • Pick Coolify or Dokploy if you need a UI, PR previews and rollbacks, or your code isn't on GitHub.
  • Pick Ployz if your code is on GitHub and you want push-to-deploy, a preview per pull request and zero-downtime deploys on one or more servers, run by your coding agent.

Git push deploy means your server builds and runs a new version of your app every time you push to a branch, with no manual step in between. It's the workflow Heroku made famous, and you can have it on a server you rent.

What does each option handle?

All five deploy when you push. They differ on zero-downtime deploys, rollbacks and per-PR previews.

Git hookGitHub Actions + SSHDokkuKamalCoolify / Dokploy / Ployz
Triggergit push to your serverPush to GitHubgit push to your serverYou run kamal deploy (or CI does)Push to your Git host
Builds the appYour scriptYour workflowBuildpacks, Dockerfile or imageDocker build, pushed to a registryYes
Zero downtimeOnly if you script itOnly if you script itYes, by defaultYes, via kamal-proxyYes (see each below)
RollbacksScript itRe-run an old workflowForce-push an old commitkamal rollbackCoolify, Dokploy: yes
PR previewsNoScript itVia the GitHub ActionNoYes
SecretsFiles on the serverGitHub secretsdokku config.kamal/secretsDashboard
Git hostsAnyGitHubAnyAnyCoolify, Dokploy: several. Ployz: GitHub only

The server under all five is the same:

ServerSpecsMonthly price
Netcup VPS 5002 vCPU, 4 GB RAM€8.26 incl. VAT
Hetzner CX23 (Europe only)2 vCPU, 4 GB RAM$6.49 + $0.60 IPv4

For what platforms charge for the same app, start at the PaaS pricing hub. I moved off platforms because my first month on Laravel Cloud was about $600 and Railway was $500+ a month and climbing. Today one €80 dedicated server runs everything, and the thing I missed most was git push and walking away.

Option 1: a git hook

Create a bare repository on the server, add a post-receive hook that checks out the pushed branch and restarts the app, then add the server as a git remote. Git runs the hook after every successful push. It's free, works with any Git host and takes ten minutes.

  1. On the server, create the repository and app directory:

    git init --bare /srv/git/app.git
    mkdir -p /srv/app
  2. Save this as /srv/git/app.git/hooks/post-receive and chmod +x it:

    #!/bin/sh
    # Git passes one line per updated ref: <old-oid> <new-oid> <ref-name>
    while read oldrev newrev ref; do
      if [ "$ref" = "refs/heads/main" ]; then
        git --work-tree=/srv/app --git-dir=/srv/git/app.git checkout -f main
        cd /srv/app && docker compose up -d --build
      fi
    done
  3. On your laptop, add the remote and push:

    git remote add production deploy@your-server:/srv/git/app.git
    git push production main

The line format and timing come from Git's githooks docs: the hook runs after all refs are updated and "cannot affect the outcome" of the push. The Pro Git book warns that the client "doesn't disconnect until it has completed", so a slow build holds your terminal open. To refuse a bad push instead, use pre-receive, which rejects the whole push when it exits non-zero.

What's left to you:

  • Downtime. docker compose up -d --build stops the old container and starts the new one. If the new one crashes on boot, the site is down until you fix it, because there's no health check.
  • Rollbacks. None. You push an older commit, or keep old release directories and switch a symlink yourself.
  • Secrets. A .env file on the server that you edit by hand and never commit.
  • Builds on the server. Building on a 4 GB box while it serves traffic works for small apps, and starts to hurt once builds need more memory than your app does.

I think this is the right answer for a single static site or a hobby app. For anything with paying users, you'll end up rebuilding half of Dokku in shell.

Option 2: GitHub Actions over SSH

Add a workflow that runs on push to main, loads an SSH key from a GitHub secret, copies your code with rsync and restarts the app over SSH. Logs and secrets live in GitHub. Private repos get 2,000 free minutes a month on GitHub Free.

A minimal .github/workflows/deploy.yml:

name: deploy
on:
  push:
    branches: [main]
concurrency: production
jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: production
    steps:
      - uses: actions/checkout@v7
      - name: Set up SSH
        env:
          SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
          KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
        run: |
          mkdir -p ~/.ssh
          printf '%s\n' "$SSH_KEY" > ~/.ssh/id_ed25519
          chmod 600 ~/.ssh/id_ed25519
          printf '%s\n' "$KNOWN_HOSTS" > ~/.ssh/known_hosts
      - name: Copy and restart
        run: |
          rsync -az --delete --exclude .git ./ deploy@203.0.113.10:/srv/app/
          ssh deploy@203.0.113.10 'cd /srv/app && docker compose up -d --build'

The concurrency line stops two pushes from deploying over each other. environment: production lets you add environment-scoped secrets and a required reviewer in the repo settings.

How to handle the secrets safely:

  • Pass secrets through env:, not on the command line. GitHub's secrets docs warn that command-line arguments can be visible via ps or captured in audit events. That's why the key goes through $SSH_KEY above.
  • Pin the host key. Store the output of ssh-keyscan your-server in DEPLOY_KNOWN_HOSTS once, after checking it, instead of turning off host key checking.
  • Use a deploy user with limited rights, not root, so a leaked key can only do that user's damage.
  • Forks don't get your secrets. Apart from GITHUB_TOKEN, "secrets are not passed to the runner when a workflow is triggered from a forked repository" (same page). That's good for safety, and it's why PR previews from forks need extra thought.
  • Log redaction covers GitHub secrets only. Anything else sensitive needs ::add-mask::.

You can also build a Docker image in Actions, push it to a registry and have the server pull it, which moves the build off a small server. GitHub's Actions billing page says standard hosted runners are free in public repos and self-hosted runners are free.

What's left to you: the same list as the git hook. The restart is still a stop-and-start, so a failed boot still means downtime. Rollback means re-running an older workflow run and hoping nothing else changed. It's GitHub only; GitLab has its own CI with the same shape.

Option 3: Dokku

Dokku gives you Heroku's workflow on your own server: create an app, add a git remote, push. It builds with Heroku buildpacks by default, runs the app in Docker, and waits for the new container before stopping the old one. It's free and open source.

From Dokku's deployment docs:

# on the server
dokku apps:create ruby-getting-started

# on your laptop
git remote add dokku dokku@dokku.me:ruby-getting-started
git push dokku main

What it handles:

  • Builds. Heroku buildpacks via Herokuish by default, plus Dockerfiles and Docker images (same page). Your app has to listen on $PORT.
  • Zero downtime. On by default. Per the zero-downtime docs, Dokku waits 10 seconds after starting each new container before treating it as up, then another 60 seconds before stopping the old ones. You can define proper health checks in app.json. Turning checks off "will stop old containers before new ones start".
  • Previews. Not built into Dokku itself. The official Dokku GitHub Action has a review-apps:create command that makes a review app with dokku apps:clone, and a matching review-apps:destroy.
  • Secrets. Environment variables per app, set with dokku config:set.

What's left to you: rollbacks are a force-push of an older commit (git push --force dokku <sha>:main), which rebuilds it. That's a community recipe, not a documented button. Dokku runs everything on the one server it's installed on; more servers means its k3s scheduler, which is Kubernetes. The free version is CLI only. Railway alternatives covers how it stacks up against hosted options.

Option 4: Kamal

Kamal isn't git push by itself: you run kamal deploy, or a CI job runs it on push. It builds a Docker image, pushes it to a registry, pulls it on every server you list, and switches traffic once the new container answers 200 OK on /up. It has a real kamal rollback command.

From the Kamal docs: gem install kamal, then kamal init to create config/deploy.yml, kamal setup for the first deploy and kamal deploy after that. A minimal config, from the configuration overview, with the secret part from the environment variables page:

service: myapp
image: my-user/myapp
servers:
  web:
    hosts:
      - 192.168.1.1
registry:
  username: my-user
  password:
    - KAMAL_REGISTRY_PASSWORD
env:
  secret:
    - DATABASE_PASSWORD
proxy:
  ssl: true

What it handles:

  • Zero downtime. kamal-proxy starts the new container, routes traffic to it once GET /up returns 200, then stops the old one.
  • Rollbacks. kamal rollback <version> starts a previous image that's still on the hosts, so "nothing needs to be downloaded from the registry". The rollback docs note that old containers are pruned after 3 days by default when you deploy.
  • Several servers. List more hosts and Kamal deploys to all of them.
  • Secrets. .kamal/secrets maps names to values, usually pulled from your environment or a password manager. Kamal's docs say not to commit that file if you put secret values directly in it.

What's left to you: a container registry and its credentials, a CI job if you want push-to-deploy, any preview setup, and databases. Kamal runs databases as "accessories", but backups are yours. It's the most solid option here that's still a plain CLI, and it came out of the Rails world, so Rails apps fit it best.

Option 5: a platform on your server

Coolify, Dokploy and Ployz are platforms you install on your own servers, with a web UI. Connect GitHub and every push deploys, and every pull request gets a preview.

Coolify. Its CI/CD docs list GitHub, GitLab, Bitbucket and Gitea. The GitHub App is the recommended route and sets up webhooks for you; public repos and deploy keys need manual webhooks. Preview deployments get their own URL per PR and are deleted when the PR is merged or closed. Rollbacks redeploy "an older application image retained on the server". An image removed by cleanup can't be rolled back to, and rollbacks don't reverse migrations.

Dokploy. Per its auto deploy docs, GitHub auto-deploys "without any configuration", and GitLab, Bitbucket and Gitea use a webhook URL. The branch in Dokploy has to match the branch you push, or you get a "Branch Not Match" error. You can also trigger a deploy through its API from CI. Preview deployments are off by default and GitHub only, with an option to require a PR label. Rollbacks come in two kinds: automatic on failed health checks under Docker Swarm, and manual ones that need a registry configured.

Ployz. Connect GitHub, and every push builds on your own servers, or in your own GitHub Actions, and deploys. No registry is involved either way. Every pull request gets a preview environment at its own HTTPS address on your servers. With a health check set, the new version has to pass it before the old one stops. Deploy from GitHub in the docs covers Wait for CI, watch paths and monorepos. More under "Where Ployz fits" below.

What's left to you with all three: updating the platform, and a copy of your databases off the server. On Ployz each database has a restore point on its own server; copies on another server are coming.

Can git push deploy have zero downtime?

Yes, if something starts the new version, checks it's healthy, moves traffic and only then stops the old one. A plain git hook or SSH workflow running docker compose up doesn't do that; it stops and starts. Dokku, Kamal, Coolify, Dokploy and Ployz all do the health-check-then-switch step for stateless apps.

To do it from a hook, you need two copies of the app and a reverse proxy you can repoint. Start the new one on another port, poll its health endpoint, reload the proxy, then stop the old one. That's roughly what kamal-proxy does for you. Databases are different everywhere: a service with a single volume can't run two copies at once, so it restarts.

Which option should you pick?

If you want…Pick
Zero moving parts for one small appGit hook
Logs, secrets and approvals in GitHubGitHub Actions + SSH
Heroku's workflow on one serverDokku
kamal rollback and several servers from a CLIKamal
A UI, previews and rollbacks, or GitLab, Bitbucket or GiteaCoolify or Dokploy
Previews and zero-downtime deploys across several servers, no registryPloyz

All five run on the same $7 server, which is the real point: the platform markup is optional. If you're comparing against hosted platforms instead, Vercel alternatives and Railway vs Vercel cover those bills.

Where Ployz fits

I built Ployz to get back the git push and walk away workflow on servers I rent. Connect GitHub and every push builds on your server. Node, Python, Ruby, PHP, Go, Rust, Java and Elixir need no Dockerfile. Every pull request gets a preview at its own HTTPS address.

To try it from your laptop first:

ployz up --server root@your-server

That installs Ployz and deploys the current directory. Your coding agent can run the rest through ployz mcp. Every deploy, restart or delete your agent asks for waits for you to approve. Ployz is free on any number of servers. Set up git push deploy on your own server with Ployz.

FAQ

Is git push deploy secure?

It's as secure as the key that can push. Use a deploy user with limited rights, pin the server's host key, and keep secrets out of the repository.

Can I git push deploy without Docker?

Yes. The git hook can run any command, so npm ci && systemctl restart app works as well as docker compose up. Dokku, Kamal and the platforms all run apps in containers.

How do I roll back a git push deploy?

It depends on the tool. Kamal has kamal rollback, Coolify and Dokploy have rollback buttons, Dokku takes a force-push of an older commit, and everywhere else you git revert and push again.

Do I need a container registry?

Only for Kamal, Dokploy's manual rollbacks, or a GitHub Actions workflow that builds images. The git hook, Dokku, Coolify and Ployz build without one.

How I checked

I checked every fact on 2026-10-01 against Git's, GitHub's, Dokku's, Kamal's, Coolify's and Dokploy's own docs, linked next to each claim. The examples are short versions of what the official docs show. I haven't benchmarked these tools for this article.

Deploy on git push to your own server with Ployz: get started.

Run your apps and databases on your own servers with Ployz.

Deploy your app