Skip to content

Docker 部署,使用PG 数据库环境变量错误 #54

@fevrax

Description

@fevrax

发现两个问题:

  1. 会把 POSTGRES_USER 识别为数据库
  2. 配置了 .env 端口变量,但还是会使用默认的 5432

root 是超级用户

辛苦大佬们看下

.env

POSTGRES_HOST=xxxx
POSTGRES_PORT=15432
POSTGRES_USER=root
POSTGRES_PASSWORD=111111
POSTGRES_DATABASE=openwebui_monitor
services:
  app:
    image: docker.io/variantconst/openwebui-monitor:latest
    container_name: openwebui-monitor
    ports:
      - "27878:3000"
    env_file:
      - .env
    environment:
      - POSTGRES_HOST=${POSTGRES_HOST:-db}
      - POSTGRES_PORT=${POSTGRES_PORT:-5432}
      - POSTGRES_USER=${POSTGRES_USER:-postgres}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-openwebui}
      - POSTGRES_DATABASE=${POSTGRES_DATABASE:-openwebui_monitor}
    restart: always

log 日志:

Waiting for PostgreSQL to start...
PostgreSQL is up!
Creating database if not exists...
Connection to xxxxxx 15432 port [tcp/*] succeeded!
psql: error: connection to server at "xxxxxx, port 15432 failed: FATAL:  database "root" does not exist
psql: error: connection to server at xxxxxx, port 15432 failed: FATAL:  database "root" does not exist
Database setup completed!
Initializing database tables...

> openwebui-usage-monitor@0.3.4 db:push /app
> tsx scripts/init-db.ts

Database connection/initialization error: Error: connect ETIMEDOUT xxxxxx:5432
    at /app/node_modules/.pnpm/pg-pool@3.7.0_pg@8.13.1/node_modules/pg-pool/index.js:45:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at ensureTablesExist (/app/lib/db.ts:65:14)
    at init (/app/scripts/init-db.ts:5:5) {
  errno: -110,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: 'xxxxx',
  port: 5432
}
Database initialization failed: Error: connect ETIMEDOUT xxxxx:5432
    at /app/node_modules/.pnpm/pg-pool@3.7.0_pg@8.13.1/node_modules/pg-pool/index.js:45:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at ensureTablesExist (/app/lib/db.ts:65:14)
    at init (/app/scripts/init-db.ts:5:5) {
  errno: -110,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: 'xxxxxxx',
  port: 5432
}
 ELIFECYCLECommand failed with exit code 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions