# Run on a single host

Source: https://dropshelf.ai/docs/self-host/install/single-host

Run dropshelf as one Docker container beside Postgres, on local files or a bucket, without Kubernetes.

Run dropshelf as one container on a single host, without Kubernetes. Use this for a small team or a
trial on a server you already run.

## What you give up [#what-you-give-up]

A single host trades these against a [Helm install](/docs/self-host/install/helm):

- **One replica.** A restart or an upgrade takes the instance down until the container is back.
- **No shared store** with the `fs` driver. Every drop's files sit on this host's disk, so the
  instance cannot grow past one container.
- **Backups are yours.** Back up Postgres and the files directory together, on your own schedule.

## Prerequisites [#prerequisites]

- A Linux host with Docker.
- Postgres 14 or later that the host can reach, with an empty database.
- An OIDC client at your identity provider, with `https://drop.example.com/auth/callback` as its
  redirect URI.
- A reverse proxy or load balancer in front of the host that holds the wildcard certificate for
  `drop.example.com` and `*.drop.example.com`. The container speaks plain HTTP.

[Requirements](/docs/self-host/install/requirements) has the detail on each.

## What the image expects [#what-the-image-expects]

The image `ghcr.io/dropshelf/dropshelf` is distroless: it has no shell and runs as UID 65532. It is
built to run with a read-only root filesystem. It writes to these directories:

| Directory | Setting | Holds | Survives a restart |
| --- | --- | --- | --- |
| `/tmp/dropshelf` | `server.spoolDir` | Uploads until they are stored | No, emptied at startup |
| `/var/cache/dropshelf` | `cache.dir` | Files the server serves, refilled from storage | No, emptied at startup |
| `/data/blobs` | `storage.fs.root` | Every drop's files, with the `fs` driver | Yes |

It listens on two ports: 8080 for the dashboard, the API and every drop, and 9090 for `/metrics`.
Publish 8080 to your proxy only, and keep 9090 for your metrics scraper.

<Callout type="warn">
The server empties the spool and the cache directory at every startup. Never put the files
directory inside either one, and never let the two overlap: the server refuses to start if they do.
</Callout>

## Run on Postgres and local files [#run-on-postgres-and-local-files]

This shape keeps every drop's files in a directory on the host, with `storage.driver: fs`.

1. Create the three directories, owned by the container's user:

   ```bash
   sudo mkdir -p /srv/dropshelf/spool /srv/dropshelf/cache /srv/dropshelf/blobs
   sudo chown 65532:65532 /srv/dropshelf/spool /srv/dropshelf/cache /srv/dropshelf/blobs
   ```

   Give the cache directory more space than `cache.maxBytes`, which is 1GB by default, with at least
   20 percent to spare.

2. Save the configuration file as `/srv/dropshelf/config.yaml`:

   ```yaml
   server:
     baseDomain: drop.example.com
     publicBaseURL: https://drop.example.com
     trustedProxies: ["<proxy-address>/32"]
   storage:
     driver: fs
   auth:
     provider: oidc
     oidc:
       issuer: <issuer-url>
       clientId: <client-id>
     admins:
       emails: [admin@example.com]
   ```

   `<proxy-address>` is the address your reverse proxy connects from, so the logs record client
   addresses. The directories keep their defaults, which do not overlap. Every key is in the
   [configuration reference](/docs/reference/configuration).

3. Save the secrets as `/srv/dropshelf/secrets.env`, readable by root only:

   ```text
   DROPSHELF_DATABASE_URL=postgres://dropshelf:<password>@<postgres-host>:5432/dropshelf?sslmode=require
   DROPSHELF_AUTH_OIDC_CLIENT_SECRET=<client-secret>
   DROPSHELF_AUTH_SESSION_SECRETS=<session-secret>
   ```

   For `<session-secret>`, use the output of `openssl rand -hex 32`. Each session secret must be at
   least 32 bytes.

4. Start the container, replacing `<version>` with a release such as `0.1.0`:

   ```bash
   docker run -d --name dropshelf --restart unless-stopped --read-only \
     -v /srv/dropshelf/config.yaml:/etc/dropshelf/config.yaml:ro \
     -v /srv/dropshelf/spool:/tmp/dropshelf \
     -v /srv/dropshelf/cache:/var/cache/dropshelf \
     -v /srv/dropshelf/blobs:/data/blobs \
     -e DROPSHELF_CONFIG=/etc/dropshelf/config.yaml \
     --env-file /srv/dropshelf/secrets.env \
     -p 127.0.0.1:8080:8080 -p 127.0.0.1:9090:9090 \
     ghcr.io/dropshelf/dropshelf:v<version>
   ```

   The container migrates the database at startup and serves on port 8080.

5. Point your reverse proxy at `127.0.0.1:8080` for both names. Keep request bodies up to at least
   110 MB and timeouts at 15 minutes, so the largest deploys get through.

To keep files in a bucket instead, set `storage.driver` to `s3`, `gcs` or `azure` and leave out the
`/data/blobs` mount. [Object storage](/docs/self-host/configure/storage) covers each driver.

## Start from the Compose stack [#start-from-the-compose-stack]

The repository's `deploy/compose/docker-compose.yaml` runs MinIO, Postgres and one dropshelf
container. It is a development stack, and also a working single host once you change these:

- **The image.** Remove the `build` stanza and name a release, `ghcr.io/dropshelf/dropshelf:v<version>`.
- **The addresses.** Set `server.baseDomain` and `server.publicBaseURL` in `deploy/compose/config.yaml`.
- **Sign-in.** The default profile runs with `auth.provider: none`, which is open access. Use
  `deploy/compose/config.dex.yaml` as the shape of an OIDC configuration.
- **Every credential.** The MinIO, Postgres and session secrets in the file are development values.
- **The cache.** The stack mounts a 128 MB `tmpfs` for a laptop. Give `cache.dir` a disk directory.
- **TLS.** Put a reverse proxy in front, and set `server.trustedProxies` to its address.

MinIO and Postgres keep their data in named volumes with no backup. For anything that matters, point
the instance at a managed database and a real bucket.

## Confirm it worked [#confirm-it-worked]

Ask the container for readiness:

```bash
curl http://127.0.0.1:8080/readyz
```

```text
ready
```

Then open `https://drop.example.com` and sign in as an address from `auth.admins.emails`.

## Next steps [#next-steps]

- [Production checklist](/docs/self-host/install/production-checklist)
- [Identity provider](/docs/self-host/configure/identity-provider)
- [Back up and restore](/docs/self-host/operate/backup)
- [Upgrade](/docs/self-host/operate/upgrade)
