mirror of
https://github.com/sassanix/Warracker.git
synced 2026-01-04 04:29:43 -06:00
66 lines
2.2 KiB
YAML
66 lines
2.2 KiB
YAML
services:
|
|
warracker:
|
|
image: ghcr.io/sassanix/warracker/main:latest
|
|
ports:
|
|
- "8005:80"
|
|
volumes:
|
|
- warracker_uploads:/data/uploads
|
|
environment:
|
|
- DB_HOST=warrackerdb
|
|
- DB_NAME=warranty_db
|
|
- DB_USER=warranty_user
|
|
- DB_PASSWORD=${DB_PASSWORD:-warranty_password}
|
|
- SMTP_HOST=smtp.email.com
|
|
- SMTP_PORT=465
|
|
- SMTP_USERNAME=youremail@email.com
|
|
- SMTP_PASSWORD=password
|
|
depends_on:
|
|
- warrackerdb
|
|
restart: unless-stopped
|
|
|
|
# Using a standard PostgreSQL image with initialization
|
|
warrackerdb:
|
|
image: postgres:15-alpine
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
environment:
|
|
- POSTGRES_DB=warranty_db
|
|
- POSTGRES_USER=warranty_user
|
|
- POSTGRES_PASSWORD=${DB_PASSWORD:-warranty_password}
|
|
# This will create the init script directly
|
|
- POSTGRES_MULTIPLE_DATABASES=warranty_db
|
|
- PGUSER=warranty_user
|
|
restart: unless-stopped
|
|
# Simple initialization approach
|
|
command: >
|
|
sh -c '
|
|
# Create initialization script
|
|
mkdir -p /docker-entrypoint-initdb.d
|
|
echo "CREATE TABLE IF NOT EXISTS warranties (
|
|
id SERIAL PRIMARY KEY,
|
|
product_name VARCHAR(255) NOT NULL,
|
|
product_url TEXT,
|
|
purchase_date DATE NOT NULL,
|
|
warranty_years INTEGER NOT NULL,
|
|
expiration_date DATE NOT NULL,
|
|
invoice_path TEXT,
|
|
manual_path TEXT,
|
|
purchase_price DECIMAL(10, 2)
|
|
);" > /docker-entrypoint-initdb.d/01-tables.sql
|
|
|
|
echo "CREATE TABLE IF NOT EXISTS serial_numbers (
|
|
id SERIAL PRIMARY KEY,
|
|
warranty_id INTEGER REFERENCES warranties(id) ON DELETE CASCADE,
|
|
serial_number VARCHAR(255) NOT NULL
|
|
);" > /docker-entrypoint-initdb.d/02-serial-numbers.sql
|
|
|
|
echo "CREATE INDEX IF NOT EXISTS idx_warranty_id ON serial_numbers(warranty_id);
|
|
CREATE INDEX IF NOT EXISTS idx_expiration_date ON warranties(expiration_date);" > /docker-entrypoint-initdb.d/03-indexes.sql
|
|
|
|
# Run the standard PostgreSQL entrypoint script
|
|
docker-entrypoint.sh postgres
|
|
'
|
|
|
|
volumes:
|
|
postgres_data:
|
|
warracker_uploads: |