# Self-host Flagsmith

> A feature flag and remote config service with a dashboard, environments, segments and an SDK API. Runs the API and dashboard in one container with a bundled Postgres database. On first open, the sign-up page creates the first organisation and admin.

- Page: https://levelrail.com/templates/flagsmith/
- JSON: https://levelrail.com/templates/flagsmith.json
- Category: Developer Tools
- Licence: BSD-3-Clause (Permissive license)
- Source: https://github.com/Flagsmith/flagsmith
- Upstream docs: https://docs.flagsmith.com/

## Requirements
- Memory: about 768 MiB
- amd64: published, arm64: published
- Needs configuration before start: no
- Pinned image tag: 16-alpine

## Services

| Service | Image | Tag | Ports | Volumes |
| --- | --- | --- | --- | --- |
| db | postgres | 16-alpine | none | pgdata -> /var/lib/postgresql/data |
| flagsmith | flagsmith/flagsmith | 2.288.2 | 8000 | none |

## Environment

| Service | Variable | Kind |
| --- | --- | --- |
| db | POSTGRES_DB | preset |
| db | POSTGRES_PASSWORD | generated |
| db | POSTGRES_USER | preset |
| flagsmith | DATABASE_URL | generated |
| flagsmith | DISABLE_INFLUXDB_FEATURES | preset |
| flagsmith | DJANGO_ALLOWED_HOSTS | preset |
| flagsmith | DJANGO_SECRET_KEY | generated |
| flagsmith | ENABLE_ADMIN_ACCESS_USER_PASS | preset |
| flagsmith | FLAGSMITH_DOMAIN | preset |
| flagsmith | TZ | preset |
| flagsmith | USE_X_FORWARDED_HOST | preset |

## Deploy

### CLI

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

Add --domain SERVICE=HOST to serve a service on your own domain, for example --domain db=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/flagsmith/install \
  -d '{
    "name": "my-flagsmith"
  }'
```

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

## First run
1. Open the app and sign up. The first account becomes the organisation admin.

## Questions

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

The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list has an entry with the id flagsmith for this app, so check that entry as well. Dokku deploys container images with its own commands, so the pinned image postgres:16-alpine, flagsmith/flagsmith:2.288.2 is what you deploy there.

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