# Installation with Docker Compose

The fastest way to a running instance is `docker compose`.

## Clone the repository

```bash
git clone https://github.com/lalabase/lalabase.git
cd lalabase
cp .env.example .env
```

## Start the stack

Adjust your `.env` (see [environment variables](https://lalabase.com/docs/en/self-hosting/configuration/environment))
and then start all services:

```bash
docker compose up -d
```

Verify that all containers are running:

```bash
docker compose ps
```

<div class="docs-callout docs-callout--info">
  <div class="docs-callout__title">Note</div>
  <p>The first migration may take a few minutes while the <code>vector</code> extension builds its indexes.</p>
</div>

## Prepare the database

On first start, migrations run automatically. Then load the seeds:

```bash
docker compose exec web bin/rails db:seed
```

On a server the seeds load reference data only, namely the global **chat personas**. They
create no accounts and delete nothing. Sample accounts exist only in the development
environment, never on a server.

<div class="docs-callout docs-callout--warning">
  <div class="docs-callout__title">Warning</div>
  <p>Running <code>db:seed</code> again resets the global chat personas to their shipped state. If you changed them in the admin area, leave the seeds alone afterwards.</p>
</div>

## Create the first admin

A fresh instance has no admin yet. Create the first one with this command:

```bash
docker compose exec web bin/rails lalabase:setup
```

The command asks for an email address and a password in the terminal. Without a terminal,
for example in a script, pass both as environment variables:

```bash
docker compose exec \
  -e LALABASE_ADMIN_EMAIL=admin@example.org \
  -e LALABASE_ADMIN_PASSWORD='a-long-password' \
  web bin/rails lalabase:setup
```

- The password needs at least 12 characters.
- If the values are missing and there is no terminal, the command stops with a message.
- If an admin exists already, the command refuses. You manage further admins in the admin
  area.

Then sign in at `/admin`. Create the first user account through the registration at
`/users/sign_up`. The command itself creates no organisation and no user account.
