# Install with Docker Compose

> The recommended way to run Songstress. One compose file, a short .env and one command.

Page: https://songstress.app/docs/getting-started/install-docker-compose/

Songstress is one container. These steps start it on any machine with Docker, in a few minutes, and open it in a
browser. Check [what you need](/docs/getting-started/requirements/) first.

## Install [#install]

### 1. Make a folder for Songstress [#1-make-a-folder-for-songstress]

```sh title="Terminal"
mkdir -p ~/songstress && cd ~/songstress
```

Songstress keeps everything of its own in a `data` folder here: the database, everyone's settings and its caches.

### 2. Save the compose file [#2-save-the-compose-file]

Save this as `compose.yaml` in that folder. You don't need to change anything in it: your own values go in `.env`.

```yaml title="compose.yaml"
x-logging: &logging
  driver: json-file
  options:
    max-size: "50m"
    max-file: "10"

services:
  songstress:
    image: ghcr.io/pacholoamit/songstress:${SONGSTRESS_TAG:-edge}
    container_name: songstress
    environment:
      - TZ=${TZ:-UTC}
      - PUID=${PUID:-}
      - PGID=${PGID:-}
      - SONGSTRESS_ADMIN_EMAIL=${SONGSTRESS_ADMIN_EMAIL:-}
      - SONGSTRESS_ADMIN_PASSWORD=${SONGSTRESS_ADMIN_PASSWORD:-}
      - SONGSTRESS_PUBLIC_URL=${SONGSTRESS_PUBLIC_URL:-}
      - SONGSTRESS_SECRET_KEY=${SONGSTRESS_SECRET_KEY:-}
      - ENABLE_TELEMETRY=${ENABLE_TELEMETRY:-true}
      - UPDATE_CHECK=${UPDATE_CHECK:-on}
      - SONGSTRESS_PB_EGRESS=${SONGSTRESS_PB_EGRESS:-direct}
      - LOG_LEVEL=${LOG_LEVEL:-INFO}
      - WRAPPED_REEL_MODE=${WRAPPED_REEL_MODE:-motion}
      - TRANSCODE_LIVE_STREAM=${TRANSCODE_LIVE_STREAM:-1}
      - TRANSCODE_LIVE_MAX=${TRANSCODE_LIVE_MAX:-8}
      - TRANSCODE_EXACT=${TRANSCODE_EXACT:-0}
      - ARTWORK_CACHE_MB=${ARTWORK_CACHE_MB:-2048}
      - VOICE_PORT=${VOICE_PORT:-8093}
      - VOICE_STUN=${VOICE_STUN:-}
      - MUSIC_LIBRARIES=${MUSIC_LIBRARIES:-Main=/music}
      - SWEEP_CRON=${SWEEP_CRON:-0 */6 * * *}
      - WORKERS=${WORKERS:-5}
      - DURATION_TOLERANCE_S=${DURATION_TOLERANCE_S:-3}
      - SERVICE_ORDER=${SERVICE_ORDER:-}
      - SPOTIFLAC_SOURCES=${SPOTIFLAC_SOURCES:-}
      - UPGRADE_IMPORTED=${UPGRADE_IMPORTED:-true}
      - DISCOGRAPHY_OUTPUT_TEMPLATE=${DISCOGRAPHY_OUTPUT_TEMPLATE:-}
      - FILENAME_TEMPLATE=${FILENAME_TEMPLATE:-}
      - RETRY_TRANSIENT_HOURS=${RETRY_TRANSIENT_HOURS:-6}
      - RETRY_NOMATCH_DAYS=${RETRY_NOMATCH_DAYS:-30}
      - ROTATE_AFTER_FAILS=${ROTATE_AFTER_FAILS:-6}
      - MAX_ROTATIONS=${MAX_ROTATIONS:-50}
      - SPOTIFY_CLIENT_ID=${SPOTIFY_CLIENT_ID:-}
      - SPOTIFY_CLIENT_SECRET=${SPOTIFY_CLIENT_SECRET:-}
      - SPOTIFY_REDIRECT_URI=${SPOTIFY_REDIRECT_URI:-}
      - LASTFM_API_KEY=${LASTFM_API_KEY:-}
      - LASTFM_API_SECRET=${LASTFM_API_SECRET:-}
      - GLUETUN_URL=${GLUETUN_URL:-http://127.0.0.1:8000}
      - GLUETUN_API_KEY=${GLUETUN_API_KEY:-}
      - YTDLP_COOKIES_FILE=${YTDLP_COOKIES_FILE:-}
      - SONGSTRESS_COMMUNITY_API_KEY=${SONGSTRESS_COMMUNITY_API_KEY:-}
      - SONGSTRESS_QOBUZ_APP_ID=${SONGSTRESS_QOBUZ_APP_ID:-}
      - SONGSTRESS_QOBUZ_APP_SECRET=${SONGSTRESS_QOBUZ_APP_SECRET:-}
      - SONGSTRESS_PROVIDER_ENDPOINTS=${SONGSTRESS_PROVIDER_ENDPOINTS:-}
      - SONGSTRESS_PROVIDER_ENDPOINTS_REFRESH=${SONGSTRESS_PROVIDER_ENDPOINTS_REFRESH:-}
      - SMTP_HOST=${SMTP_HOST:-}
      - SMTP_PORT=${SMTP_PORT:-587}
      - SMTP_USERNAME=${SMTP_USERNAME:-}
      - SMTP_PASSWORD=${SMTP_PASSWORD:-}
      - SMTP_FROM=${SMTP_FROM:-}
      - SMTP_TO=${SMTP_TO:-}
      - SMTP_STARTTLS=${SMTP_STARTTLS:-true}
      - HISTORY_IMPORT_PATH=${HISTORY_IMPORT_PATH:-}
    ports:
      # The web app and every app's connection.
      - "${SONGSTRESS_PORT:-8090}:8090"
      # Talking in a Jam: the same port inside and out, UDP and TCP.
      - "${VOICE_PORT:-8093}:${VOICE_PORT:-8093}/udp"
      - "${VOICE_PORT:-8093}:${VOICE_PORT:-8093}/tcp"
    volumes:
      # Songstress's own data: keep this folder, and back it up.
      - ./data:/pb/pb_data
      # Your music.
      - ${MUSIC_DIR}:/music
    tmpfs:
      - /tmp:mode=1777,size=${SONGSTRESS_TMP_SIZE:-1536m}
    restart: unless-stopped
    logging: *logging
    mem_limit: ${SONGSTRESS_MEM_LIMIT:-4g}
    cpus: ${SONGSTRESS_CPUS:-0}
```

### 3. Write your .env [#3-write-your-env]

Save this as `.env` beside it, with your own music folder and time zone.

```sh title=".env"
MUSIC_DIR=/srv/music
SONGSTRESS_TAG=latest
TZ=Europe/Berlin
```

- **`MUSIC_DIR`** is the folder that holds your music, on this machine. If it is new, make it first with
  `mkdir -p`, as the user who owns your music.
- **`SONGSTRESS_TAG`** picks the release. `latest` is the newest release. Left empty, you get `edge`, the newest
  build, which changes often. To stay on one version, use its number from the
  [releases page](https://github.com/pacholoamit/songstress-releases/releases), like `v0.49.0`.
- **`TZ`** is your time zone.

### 4. Start Songstress [#4-start-songstress]

```sh title="Terminal"
docker compose up -d
```

The first start downloads the image, a few gigabytes. Then check on it:

```sh title="Terminal"
docker compose ps
```

After about a minute it shows `healthy`. To watch it start:

```sh title="Terminal"
docker compose logs -f songstress
```

### 5. Create your admin account [#5-create-your-admin-account]

Open `http://your-server:8090` in a browser, using your machine's address, like `http://192.168.1.20:8090`. The
first screen is **Create your admin account**. Carry on with [Set up your server](/docs/getting-started/first-run/).

<Callout type="warn" title="Do this step now">
Until the admin account exists, anyone who can open the page can create it.
</Callout>

## Who Songstress runs as [#who-songstress-runs-as]

Songstress saves the music it adds for you into `MUSIC_DIR`, so the user it runs as must be able to write there.

- Left unset, it runs as the owner of your music folder, or as `1000:1000` when the folder belongs to root.
- To choose, set `PUID` and `PGID` in `.env`. Your own account's are what `id -u` and `id -g` print.
- If Docker had to create the music folder, it belongs to root. On its first start Songstress gives that empty
  folder to the user it runs as. It never changes the owner of a folder that already holds music.
- If Songstress can't write there, the app says why and how to fix it, in a notice and in
  **Settings ▸ About ▸ Diagnostics**.

## Settings you can add before the first start [#settings-you-can-add-before-the-first-start]

These are optional. Put any of them in `.env`, then run `docker compose up -d` again.

- **`SONGSTRESS_ADMIN_EMAIL`** and **`SONGSTRESS_ADMIN_PASSWORD`** make your admin account at the first start, so
  the first screen is the sign-in page instead.
- **`SONGSTRESS_PUBLIC_URL`** is the address people use, like `https://music.example.com`. Invite and
  password-reset links point there.
- **`SMTP_HOST`** and the other `SMTP_` settings let Songstress send email. See
  [Email and notifications](/docs/admin/email/).

Every setting is in [Environment variables](/docs/reference/configuration/).

## Update [#update]

```sh title="Terminal"
docker compose pull && docker compose up -d
```

Your data stays in `./data`. Before an update changes the database, Songstress keeps a copy of it, so you can go
back. See [Update and roll back](/docs/admin/update/).
