> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trypost.it/llms.txt
> Use this file to discover all available pages before exploring further.

# Docker

> Run TryPost in Docker with Laravel Sail

# Docker

TryPost ships with a working `compose.yaml` that uses [Laravel Sail](https://laravel.com/docs/sail) for a containerized dev environment. The compose file includes PostgreSQL 18, Redis, Mailpit (local SMTP UI), and Selenium for browser tests — no `sail:install` step needed.

## Requirements

* Docker Desktop (Mac, Windows) or Docker Engine (Linux)
* Docker Compose v2

## Quick start

### 1. Clone the repository

```bash theme={null}
git clone https://github.com/trypostit/trypost.git
cd trypost
```

### 2. Install Composer dependencies

If you have PHP 8.2+ on your host:

```bash theme={null}
composer install
```

Otherwise use a throwaway container — no PHP install required:

```bash theme={null}
docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v "$(pwd):/var/www/html" \
    -w /var/www/html \
    laravelsail/php85-composer:latest \
    composer install --ignore-platform-reqs
```

### 3. Configure environment

```bash theme={null}
cp .env.example .env
```

Update the database and Redis hosts so they point at the Sail containers:

```env theme={null}
APP_URL=http://localhost

DB_CONNECTION=pgsql
DB_HOST=pgsql
DB_PORT=5432
DB_DATABASE=trypost
DB_USERNAME=sail
DB_PASSWORD=password

REDIS_HOST=redis
```

### 4. Start the containers

```bash theme={null}
./vendor/bin/sail up -d
```

That brings up `laravel.test`, `pgsql`, `redis`, `mailpit`, and `selenium`.

### 5. Generate the app key

```bash theme={null}
./vendor/bin/sail artisan key:generate
```

Migrations run as part of the seed step below.

### 6. Seed default data and create the admin user

Self-hosted installs default to `SELF_HOSTED=true`, which closes `/register`. On a fresh database, run this once:

```bash theme={null}
./vendor/bin/sail artisan migrate:fresh --seed && ./vendor/bin/sail artisan db:seed --class=UserSeeder
```

This rebuilds the schema, runs the default `DatabaseSeeder` (Passport personal access client + plan rows), and creates the admin user.

<Warning>
  `migrate:fresh` **drops every table**. Only run it on a brand-new database. If you already have data, run `sail artisan db:seed && sail artisan db:seed --class=UserSeeder` instead.
</Warning>

Default credentials — **change the password on first login**:

| Field    | Value              |
| -------- | ------------------ |
| Email    | `admin@trypost.it` |
| Password | `password`         |

Additional accounts come from workspace invites (Settings → Members).

### 7. Install npm packages and build the front-end

```bash theme={null}
./vendor/bin/sail npm install
./vendor/bin/sail npm run build
```

For active development with hot reload, use `sail npm run dev` instead.

## Accessing TryPost

| Service                   | URL                     |
| ------------------------- | ----------------------- |
| TryPost dashboard         | `http://localhost`      |
| Mailpit (captured emails) | `http://localhost:8025` |
| Postgres                  | `localhost:5432`        |
| Redis                     | `localhost:6379`        |

## Common Commands

```bash theme={null}
# Start containers
./vendor/bin/sail up -d

# Stop containers
./vendor/bin/sail down

# View logs
./vendor/bin/sail logs

# Run Artisan commands
./vendor/bin/sail artisan <command>

# Run npm commands
./vendor/bin/sail npm <command>

# Access PostgreSQL
./vendor/bin/sail psql

# Access Redis CLI
./vendor/bin/sail redis
```

## Running the Queue Worker

For background job processing (publishing, notifications, token refresh):

```bash theme={null}
./vendor/bin/sail artisan horizon
```

Or run it detached alongside the rest of the stack:

```bash theme={null}
./vendor/bin/sail up -d
./vendor/bin/sail artisan horizon
```

## Shell alias

Add this alias to your shell profile (`~/.bashrc`, `~/.zshrc`) so you can drop the `./vendor/bin/` prefix:

```bash theme={null}
alias sail='./vendor/bin/sail'
```

Then:

```bash theme={null}
sail up -d
sail artisan migrate
sail npm run dev
```

## Production with Docker

The shipped `compose.yaml` is tuned for development (debug mode, Mailpit, Selenium). For production:

1. Use a slimmer compose file without Selenium/Mailpit and with persistent named volumes for `storage/app` and Postgres data
2. Set `APP_ENV=production`, `APP_DEBUG=false`
3. Terminate SSL at a reverse proxy (Nginx, Traefik, Caddy)
4. Configure long-running supervisors for Horizon, Reverb, and the Laravel scheduler — see [Production setup](/self-hosting/production)

## Troubleshooting

### Port conflicts

If port 80 is already in use, change `APP_PORT` in `.env`:

```env theme={null}
APP_PORT=8080
```

### Permission issues

On Linux you may need:

```bash theme={null}
sudo chown -R $USER: .
```

### Database connection refused

Make sure the database container is healthy:

```bash theme={null}
./vendor/bin/sail ps
```

Give Postgres a few seconds to initialize on first boot.
