# Self-host YOURLS

> A self-hosted URL shortener with custom keywords, click statistics and a plugin system. Runs with a bundled MariaDB database. The admin login is the user and password you set in the install form.

- Page: https://levelrail.com/templates/yourls/
- JSON: https://levelrail.com/templates/yourls.json
- Category: Applications
- Licence: MIT (Permissive license)
- Source: https://github.com/YOURLS/YOURLS
- Upstream docs: https://yourls.org/docs/

## Requirements
- Memory: about 256 MiB
- amd64: published, arm64: published
- Needs configuration before start: yes
- Pinned image tag: 11.8.9

## Services

| Service | Image | Tag | Ports | Volumes |
| --- | --- | --- | --- | --- |
| db | mariadb | 11.8.9 | none | dbdata -> /var/lib/mysql |
| yourls | yourls | 1.10.6 | 8080 | none |

## Environment

| Service | Variable | Kind |
| --- | --- | --- |
| db | MARIADB_DATABASE | preset |
| db | MARIADB_PASSWORD | generated |
| db | MARIADB_ROOT_PASSWORD | generated |
| db | MARIADB_USER | preset |
| yourls | YOURLS_DB_HOST | preset |
| yourls | YOURLS_DB_NAME | preset |
| yourls | YOURLS_DB_PASS | generated |
| yourls | YOURLS_DB_USER | preset |
| yourls | YOURLS_PASS | required |
| yourls | YOURLS_SITE | preset |
| yourls | YOURLS_USER | preset |

## Deploy

### CLI

```bash
levelrail-cli templates install yourls --name my-yourls --env YOURLS_PASS=VALUE
```

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/yourls/install \
  -d '{
    "name": "my-yourls",
    "env": { "YOURLS_PASS": "VALUE" }
  }'
```

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

## First run
1. Open /admin/install.php on the app address and click Install YOURLS once.
2. Sign in at /admin/ with the user and password from the install form.

## Questions

### Can I deploy YOURLS 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 yourls for this app, so check that entry as well. Dokku deploys container images with its own commands, so the pinned image mariadb:11.8.9, yourls:1.10.6 is what you deploy there.

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