# Self-host Pgweb

> A small web client for browsing and querying PostgreSQL databases, with a table browser, query editor and export. Runs as one container with no storage of its own. Sign in with the username and password from the install form, then enter the connection details of your database.

- Page: https://levelrail.com/templates/pgweb/
- JSON: https://levelrail.com/templates/pgweb.json
- Category: Developer Tools
- Licence: MIT (Permissive license)
- Source: https://github.com/sosedoff/pgweb
- Upstream docs: https://github.com/sosedoff/pgweb/wiki

## Requirements
- Memory: about 64 MiB
- amd64: published, arm64: published
- Needs configuration before start: no
- Pinned image tag: 0.17.0

## Services

| Service | Image | Tag | Ports | Volumes |
| --- | --- | --- | --- | --- |
| pgweb | sosedoff/pgweb | 0.17.0 | 8081 | none |

## Environment

| Service | Variable | Kind |
| --- | --- | --- |
| pgweb | PGWEB_AUTH_PASS | generated |
| pgweb | PGWEB_AUTH_USER | preset |

## Deploy

### CLI

```bash
levelrail-cli templates install pgweb --name my-pgweb
```

Add --domain SERVICE=HOST to serve a service on your own domain, for example --domain pgweb=app.example.com.

### API

```bash
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  https://levelrail.example.com/api/v1/service-templates/pgweb/install \
  -d '{
    "name": "my-pgweb"
  }'
```

Create a token in the dashboard first. Name, env and domains are the request fields.

## First run
1. Sign in with the username and password from the install form.
2. Enter the host, user, password and database of the Postgres server you want to browse.

## Questions

### Can I deploy Pgweb on Dokploy or Dokku?

The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list we compared does not have an entry with the same id for Pgweb, so on Dokploy you would use a Docker Compose application with the file from this page. Dokku deploys container images with its own commands, so the pinned image sosedoff/pgweb:0.17.0 is what you deploy there.

Self-host Pgweb, Pgweb docker compose file, deploy Pgweb on a VPS: this page lists the pinned image, ports, volumes and the commands for each.
