docs: update CasaOS deployment guide with PostgreSQL setup

This commit is contained in:
2026-03-31 10:14:51 -07:00
parent 478d81e1b1
commit 0f2228b9eb
+69 -16
View File
@@ -9,13 +9,22 @@ This guide explains how to deploy EuchreCamp on your CasaOS server.
3. **Port 3000** available for the web interface 3. **Port 3000** available for the web interface
4. **Port 5432** available for PostgreSQL (or use external database) 4. **Port 5432** available for PostgreSQL (or use external database)
## Prerequisites
**External PostgreSQL Database Required**
- PostgreSQL 15 or higher
- Database name: `euchre_camp`
- User: `euchre_camp`
- Privileges: ALL on database `euchre_camp`
## Quick Start ## Quick Start
### Option 1: Using CasaOS App Store (Recommended) ### Option 1: Using CasaOS App Store (Recommended)
1. Open CasaOS Dashboard 1. **Set up PostgreSQL database first** (see below)
2. Go to **App Store****Custom App** 2. Open CasaOS Dashboard
3. Click **Install** and configure the following: 3. Go to **App Store****Custom App**
4. Click **Install** and configure the following:
**Basic Settings:** **Basic Settings:**
- App Name: `EuchreCamp` - App Name: `EuchreCamp`
@@ -24,36 +33,78 @@ This guide explains how to deploy EuchreCamp on your CasaOS server.
**Environment Variables:** **Environment Variables:**
``` ```
DATABASE_URL=postgresql://euchre_camp:password@your-postgres-host:5432/euchre_camp
DATABASE_SHADOW_URL=postgresql://euchre_camp:password@your-postgres-host:5432/euchre_camp_shadow
BETTER_AUTH_SECRET=your-secret-key-here BETTER_AUTH_SECRET=your-secret-key-here
BETTER_AUTH_URL=http://your-casaos-ip:3000 BETTER_AUTH_URL=http://your-casaos-ip:3000
TRUSTED_ORIGINS=http://your-casaos-ip:3000 TRUSTED_ORIGINS=http://your-casaos-ip:3000
``` ```
4. Click **Install** 5. Click **Install**
### Option 2: Using Docker Compose ### Option 2: Using Docker Compose
1. **Build the Docker image:** 1. **Set up PostgreSQL database first** (see below)
2. **Build the Docker image:**
```bash ```bash
docker-compose -f docker-compose.casaos.yml build docker-compose -f docker-compose.casaos.yml build
``` ```
2. **Start the application:** 3. **Start the application:**
```bash ```bash
docker-compose -f docker-compose.casaos.yml up -d docker-compose -f docker-compose.casaos.yml up -d
``` ```
3. **Check logs:** 4. **Check logs:**
```bash ```bash
docker-compose -f docker-compose.casaos.yml logs -f docker-compose -f docker-compose.casaos.yml logs -f
``` ```
## PostgreSQL Database Setup
### Option A: External PostgreSQL Server
Connect to your PostgreSQL server and run:
```sql
-- Create database
CREATE DATABASE euchre_camp;
-- Create user
CREATE USER euchre_camp WITH PASSWORD 'your-strong-password';
-- Grant privileges
GRANT ALL PRIVILEGES ON DATABASE euchre_camp TO euchre_camp;
-- Connect to database
\c euchre_camp
-- Grant schema privileges
GRANT ALL ON SCHEMA public TO euchre_camp;
```
### Option B: CasaOS PostgreSQL Container
If you want to run PostgreSQL in CasaOS:
1. Install PostgreSQL from CasaOS App Store
2. Configure it with:
- Database: `euchre_camp`
- User: `euchre_camp`
- Password: `your-strong-password`
3. Use the connection string in your EuchreCamp configuration:
```
DATABASE_URL=postgresql://euchre_camp:your-strong-password@192.168.1.100:5432/euchre_camp
```
(Replace `192.168.1.100` with your CasaOS IP)
## Configuration ## Configuration
### Required Environment Variables ### Required Environment Variables
| Variable | Description | Example | | Variable | Description | Example |
|----------|-------------|---------| |----------|-------------|---------|
| `DATABASE_URL` | PostgreSQL connection string (REQUIRED) | `postgresql://euchre_camp:pass@host:5432/euchre_camp` |
| `BETTER_AUTH_SECRET` | Secret key for session encryption (generate with `openssl rand -base64 32`) | `your-generated-secret` | | `BETTER_AUTH_SECRET` | Secret key for session encryption (generate with `openssl rand -base64 32`) | `your-generated-secret` |
| `BETTER_AUTH_URL` | Public URL of your application | `http://192.168.1.100:3000` | | `BETTER_AUTH_URL` | Public URL of your application | `http://192.168.1.100:3000` |
| `TRUSTED_ORIGINS` | Comma-separated list of trusted origins | `http://192.168.1.100:3000` | | `TRUSTED_ORIGINS` | Comma-separated list of trusted origins | `http://192.168.1.100:3000` |
@@ -62,16 +113,18 @@ This guide explains how to deploy EuchreCamp on your CasaOS server.
| Variable | Description | Default | | Variable | Description | Default |
|----------|-------------|---------| |----------|-------------|---------|
| `POSTGRES_PASSWORD` | PostgreSQL password (change from default!) | `euchrepassword` | | `DATABASE_SHADOW_URL` | Shadow database for migrations | Same as DATABASE_URL with `_shadow` suffix |
## Database Management ## Database Management
### First-Time Setup ### First-Time Setup
1. The PostgreSQL container will automatically initialize on first run 1. **Create the database and user** (see PostgreSQL Setup above)
2. Database migrations will be applied automatically 2. **Run database migrations:**
3. Default admin user can be created via script: ```bash
docker exec -it euchre-camp npx prisma migrate deploy
```
3. **Create admin user:**
```bash ```bash
docker exec -it euchre-camp node scripts/create-admin-via-api.js docker exec -it euchre-camp node scripts/create-admin-via-api.js
``` ```
@@ -79,8 +132,8 @@ This guide explains how to deploy EuchreCamp on your CasaOS server.
### Accessing the Database ### Accessing the Database
```bash ```bash
# Connect to PostgreSQL container # Connect to external PostgreSQL server
docker exec -it euchre-camp-postgres psql -U euchre_camp -d euchre_camp psql -h your-postgres-host -U euchre_camp -d euchre_camp
# List tables # List tables
\dt \dt
@@ -92,8 +145,8 @@ docker exec -it euchre-camp-postgres psql -U euchre_camp -d euchre_camp
### Backing Up Data ### Backing Up Data
```bash ```bash
# Backup PostgreSQL data # Backup PostgreSQL data (run on your PostgreSQL server)
docker exec euchre-camp-postgres pg_dump -U euchre euchre_camp > backup.sql pg_dump -h your-postgres-host -U euchre_camp euchre_camp > backup.sql
# Backup uploaded files # Backup uploaded files
tar -czf euchre_camp_files.tar.gz /var/lib/docker/volumes/euchre_camp_app_data tar -czf euchre_camp_files.tar.gz /var/lib/docker/volumes/euchre_camp_app_data