English
Get started
← All templates

Deploy ntfy on Pethost in one click

Push notifications to your phone and desktop from scripts, over HTTP

What happens

  1. You sign in to Pethost or make an account, with a passkey, GitHub or Google.
  2. No machine yet? You pick a plan, and we prepare one for you. The link waits in your browser until it is ready.
  3. New project opens at the app. You fill in what it asks for and click Create project: Admin password.
  4. In a minute or two the app is live at its own address with HTTPS. Its secrets are made for it at random, and its data is in the nightly backup.
  5. It is a project like any other: its compose.yaml, its .env, its logs and a terminal are in the panel, and your agent can change it, roll it back or restore it.

First steps

Sign in as admin with the admin password you gave. Topics are closed to everyone else: give a phone or a script its own user in the ntfy service’s terminal, with ntfy user add and ntfy access. In the ntfy app, add https://ntfy.sam.pethost.app as the server. Messages are kept in /var/lib/ntfy.

What it runs

The template is this compose.yaml and the variables it writes into the project’s .env. Pethost runs the file as it is written.

services:
  ntfy:
    image: binwiederhier/ntfy:v2.30.0
    restart: unless-stopped
    environment:
      NTFY_BASE_URL: ${URL}
      NTFY_LISTEN_HTTP: ":80"
      NTFY_BEHIND_PROXY: "true"
      NTFY_CACHE_FILE: /var/lib/ntfy/cache.db
      NTFY_AUTH_FILE: /var/lib/ntfy/user.db
      # Without a user nobody reads or sends: the address alone does not open a topic.
      NTFY_AUTH_DEFAULT_ACCESS: deny-all
      NTFY_ENABLE_LOGIN: "true"
      NTFY_REQUIRE_LOGIN: "true"
      ADMIN_PASSWORD: ${ADMIN_PASSWORD}
    # ntfy makes its user database at the first start, and only then takes a user: it is started
    # once on a port nobody reaches, the admin is added, and the server proper starts.
    entrypoint:
      - sh
      - -c
      - |
        set -e
        if [ ! -f /var/lib/ntfy/user.db ]; then
          ntfy serve --listen-http 127.0.0.1:81 &
          until wget -q -O /dev/null http://127.0.0.1:81/v1/health; do sleep 1; done
          kill $$!
          wait $$! || true
          NTFY_PASSWORD="$$ADMIN_PASSWORD" ntfy user add --role=admin admin
        fi
        exec ntfy serve
    volumes:
      - data:/var/lib/ntfy
volumes:
  data: