Tinyauth

PostgreSQL

Tinyauthドラゴン PostgreSQL データベースの構成

PostgreSQLは、強力でスケーラブルなオープンソースのリレーショナルデータベース管理システムです。 tinyauthは PostgreSQLをデータベースとしてサポートし、中大規模展開や高性能が要求される環境に適しています。特に Kubernetesなどの環境で複数のインスタンスを運用するには PostgreSQLこれが必要です。

# config.yaml
database:
  type: postgres
  host: ${DATABASE_HOST:-localhost}
  port: ${DATABASE_PORT:-5432}
  name: ${DATABASE_NAME:-tinyauth}
  user: ${DATABASE_USER:-tinyauth}
  password: ${DATABASE_PASSWORD}
  • type: postgresで指定します。
  • host: PostgreSQL サーバーのホスト名です。デフォルトは localhostはい。
  • port: PostgreSQL サーバーのポートです。デフォルトは 5432はい。
  • name:使用するデータベース名です。
  • user:データベース接続ユーザーです。
  • password:データベース接続パスワードです。
Note

PostgreSQL 接続は基本的に SSLこれがアクティブになっています。ローカル開発環境で SSL なしで接続するには PostgreSQL サーバー設定を確認してください。


Docker Composeの例

tinyauthと PostgreSQL一緒に Docker Composeで運営する例です。

# docker-compose.yml
services:
  tinyauth:
    image: ghcr.io/tinyrack-net/tinyauth:latest
    ports:
      - "8080:8080"
    volumes:
      - ./config.yaml:/opt/config.yaml:ro
    depends_on:
      postgres:
        condition: service_healthy
    restart: unless-stopped

  postgres:
    image: postgres:17-alpine
    environment:
      POSTGRES_DB: tinyauth
      POSTGRES_USER: tinyauth
      POSTGRES_PASSWORD: your-strong-password
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U tinyauth"]
      interval: 5s
      timeout: 5s
      retries: 5
    restart: unless-stopped

volumes:
  postgres_data:

この場合 config.yamlは次のように設定します。

# config.yaml
server:
  public_origin: https://auth.example.com

security:
  session_secret: your-session-secret
  hash_secret: your-base64url-hash-secret

database:
  type: postgres
  host: postgres
  port: 5432
  name: tinyauth
  user: tinyauth
  password: your-strong-password
Caution

本番環境では、データベースパスワード config.yamlに直接記入する代わりに 環境変数を使用することをお勧めします。