# Choose object storage

Source: https://dropshelf.ai/docs/self-host/configure/storage

Connect dropshelf to an S3-compatible bucket, Google Cloud Storage, Azure Blob Storage or a local directory, with the credentials and permissions each needs.

dropshelf keeps every deployed file, uploaded asset and profile picture in one object store. This
page is for the operator who picks the store and gives dropshelf access to it.

You choose the store with `storage.driver`. There are four drivers:

| Driver | Store | Credentials | Use it for |
| --- | --- | --- | --- |
| `s3` | Amazon S3, MinIO or another S3-compatible store | The AWS default chain: IRSA, instance credentials or access keys | Any install. It is the default. |
| `gcs` | Google Cloud Storage | Application Default Credentials, such as GKE Workload Identity | Installs on Google Cloud |
| `azure` | Azure Blob Storage | The Azure default credential chain, such as AKS Workload Identity, or a connection string | Installs on Azure |
| `fs` | A directory on the server's own disk | None | One server on a single host |

An instance uses one driver, and the server reads only that driver's block. dropshelf never creates
the bucket or container, so create it first. The `s3`, `gcs` and `azure` blocks each take an optional
`prefix`, a path inside the bucket that every object goes under. With a prefix, the bucket can hold
other data too.

The server checks the store before it reports itself ready on `/readyz`. A store it cannot reach, or
a bucket that is missing, keeps it not ready.

The `storage` blocks on this page go in the server's configuration file. On a Helm install, put them
under `config:` in your values file. The `serviceAccount` and `podLabels` blocks are Helm values of
their own, outside `config:`.

## Prerequisites [#prerequisites]

- A bucket or container, created with your provider's console or command-line tool.
- Permission to create a cloud role or identity and grant it access to the bucket.
- Access to the server's configuration and its Secret, or to the Helm values.

## Amazon S3 and S3-compatible stores [#amazon-s3-and-s3-compatible-stores]

To use an S3 bucket:

1. Create a role for dropshelf with this policy, which grants `s3:ListBucket` on the bucket and
   `s3:GetObject`, `s3:PutObject` and `s3:DeleteObject` on its objects:

   ```json
   {
     "Version": "2012-10-17",
     "Statement": [
       {
         "Effect": "Allow",
         "Action": "s3:ListBucket",
         "Resource": "arn:aws:s3:::<bucket>"
       },
       {
         "Effect": "Allow",
         "Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"],
         "Resource": "arn:aws:s3:::<bucket>/*"
       }
     ]
   }
   ```

   Readiness runs `HeadBucket`, which needs `s3:ListBucket`. A role scoped to objects alone keeps the
   server not ready.

2. Give the pods the role. On EKS, annotate the ServiceAccount for IAM Roles for Service Accounts
   (IRSA) in your Helm values:

   ```yaml
   serviceAccount:
     annotations:
       eks.amazonaws.com/role-arn: arn:aws:iam::<account-id>:role/dropshelf
   ```

   Without IRSA or instance credentials, put `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` in the
   environment or the Secret instead.

3. Set the bucket and its region:

   ```yaml
   storage:
     driver: s3
     s3:
       bucket: example-dropshelf
       region: eu-north-1
   ```

`region` defaults to `eu-north-1`, so set it whenever your bucket is elsewhere.

### MinIO and other S3-compatible stores [#minio-and-other-s3-compatible-stores]

To use MinIO or another S3-compatible store, set `endpoint` to the store's URL. MinIO also needs
`forcePathStyle: true`, which names the bucket in the URL path rather than the hostname:

```yaml
storage:
  driver: s3
  s3:
    bucket: dropshelf
    region: us-east-1
    endpoint: https://minio.example.com
    forcePathStyle: true
```

Credentials come from `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. With `endpoint` set, the
default `checksums: auto` sends request checksums only where they are required, which keeps older
S3-compatible stores working.

## Google Cloud Storage [#google-cloud-storage]

To use a Cloud Storage bucket on GKE:

1. Grant a Google service account `roles/storage.objectAdmin` on the bucket:

   ```bash
   gcloud storage buckets add-iam-policy-binding gs://<bucket> \
     --member "serviceAccount:<gsa>@<project>.iam.gserviceaccount.com" \
     --role roles/storage.objectAdmin
   ```

2. Allow the Kubernetes ServiceAccount `dropshelf` to act as that service account:

   ```bash
   gcloud iam service-accounts add-iam-policy-binding <gsa>@<project>.iam.gserviceaccount.com \
     --role roles/iam.workloadIdentityUser \
     --member "serviceAccount:<project>.svc.id.goog[<namespace>/dropshelf]"
   ```

3. Annotate the ServiceAccount for Workload Identity in your Helm values:

   ```yaml
   serviceAccount:
     annotations:
       iam.gke.io/gcp-service-account: <gsa>@<project>.iam.gserviceaccount.com
   ```

4. Set the bucket:

   ```yaml
   storage:
     driver: gcs
     gcs:
       bucket: example-dropshelf
   ```

Outside GKE, the server finds its credentials through Application Default Credentials. Readiness
lists one object under the prefix, so it needs no `storage.buckets.get`. It passes on an empty bucket
and fails on a missing one. Leave `storage.gcs.endpoint` empty: it is for a storage emulator, and
setting it turns authentication off.

## Azure Blob Storage [#azure-blob-storage]

To use a Blob container on AKS:

1. Create a user-assigned managed identity with a federated credential for the Kubernetes
   ServiceAccount `dropshelf`.
2. Assign the identity the **Storage Blob Data Contributor** role on the container.
3. Annotate the ServiceAccount and label the pods for Workload Identity in your Helm values:

   ```yaml
   serviceAccount:
     annotations:
       azure.workload.identity/client-id: <client-id>
   podLabels:
     azure.workload.identity/use: "true"
   ```

4. Set the storage account and container:

   ```yaml
   storage:
     driver: azure
     azure:
       account: exampledropshelf
       container: drops
   ```

Outside Azure, put a connection string in the environment or the Secret as
`DROPSHELF_STORAGE_AZURE_CONNECTION_STRING`. It replaces the default credentials and names the
account, so `account` can stay empty. For a sovereign cloud, set `endpoint` to the full https service
URL, which also names the account.

Readiness lists one blob under the prefix. It passes on an empty container and fails on a missing
one.

## A directory on a single host [#a-directory-on-a-single-host]

The `fs` driver keeps objects in a directory, `storage.fs.root`, which defaults to `/data/blobs`. It
is for one server on one host, not for several replicas. To use it, put the directory on a disk you
back up:

```yaml
storage:
  driver: fs
  fs:
    root: /data/blobs
```

The server empties `server.spoolDir` and `cache.dir` at every startup. It refuses to start when
`storage.fs.root` sits inside the spool directory or overlaps the cache directory.

<Callout type="warn">
The Helm chart mounts no volume for `fs`. On Kubernetes, every deployed file is lost when its pod
goes. Use `s3`, `gcs` or `azure` there.
</Callout>

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

Ask the server whether it is ready:

```bash
curl -sS https://drop.example.com/readyz
```

A server that reaches its store answers:

```text
ready
```

Otherwise the answer starts with `not ready:` and gives the store's error, such as a missing bucket
or refused credentials. Publish a drop afterwards to check that writes work too.

## Next steps [#next-steps]

- [Set up domains and TLS](/docs/self-host/configure/domains-and-tls)
- [Back up and restore](/docs/self-host/operate/backup)
- [Run on a single host](/docs/self-host/install/single-host)
- [Example values files](/docs/reference/helm-values#example-values-files)
- [Configuration reference: storage](/docs/reference/configuration#storage)
