opf / opf/openproject-docker-compose

At the first start up it fails at connecting with the db

Open
#79 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
342
Forks
315
PR merge metrics
No merged PRs in 30d

Description

Hello everyone,

I recently tried to use openproject community I followed to guide but it keeps saying it is unable to connect to the DB and I didnt change much this is my docker-compose.yml:

networks:
  frontend:
  backend:
  proxy:
    external: true

volumes:
  pgdata:
  opdata:
  assets:

x-op-restart-policy: &restart_policy
  restart: unless-stopped
x-op-image: &image
  image: openproject/openproject:14
x-op-app: &app
  <<: [*image, *restart_policy]
  environment:
    OPENPROJECT_HTTPS: "${OPENPROJECT_HTTPS:-true}"
    OPENPROJECT_HOST__NAME: "${OPENPROJECT_HOST__NAME:-localhost:8080}"
    OPENPROJECT_HSTS: "${OPENPROJECT_HSTS:-true}"
    RAILS_CACHE_STORE: "memcache"
    OPENPROJECT_CACHE__MEMCACHE__SERVER: "cache:11211"
    OPENPROJECT_RAILS__RELATIVE__URL__ROOT: "${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}"
    DATABASE_URL: "${DATABASE_URL:-postgres://postgres:p4ssw0rd@db/openproject?pool=20&encoding=unicode&reconnect=true}"
    RAILS_MIN_THREADS: ${RAILS_MIN_THREADS:-4}
    RAILS_MAX_THREADS: ${RAILS_MAX_THREADS:-16}
    # set to true to enable the email receiving feature. See ./docker/cron for more options
    IMAP_ENABLED: "${IMAP_ENABLED:-false}"

services:
  db:
    image: postgres:13
    <<: *restart_policy
    stop_grace_period: "3s"
    volumes:
      - "${PGDATA:-pgdata}:/var/lib/postgresql/data"
    environment:
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-p4ssw0rd}
      POSTGRES_DB: openproject
    networks:
      - backend

  cache:
    image: memcached
    <<: *restart_policy
    networks:
      - backend

  proxy:
    image: caddy:2
    <<: *restart_policy
    command: "/usr/local/bin/proxy-entrypoint.sh"
    #ports:
    #  - "${PORT:-8080}:80"
    environment:
      APP_HOST: web
    depends_on:
      - web
    networks:
      - frontend
      - proxy
    volumes:
      - ./Caddyfile.template:/etc/caddy/Caddyfile.template:ro
      - ./proxy-entrypoint.sh:/usr/local/bin/proxy-entrypoint.sh:ro
      - assets:/public:ro
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.project.entrypoints=https"
      - "traefik.http.routers.project.rule=(Host(`project.MYDOMAINHERE`))"
      - "traefik.http.routers.project.tls=true"
      - "traefik.http.routers.project.tls.certresolver=http"
      - "traefik.http.routers.project.service=project"
      - "traefik.http.services.project.loadbalancer.server.port=8080"
      - "traefik.docker.network=proxy"
      - "traefik.http.routers.project.middlewares=default@file"

  web:
    <<: *app
    command: "./docker/prod/web"
    networks:
      - frontend
      - backend
    depends_on:
      - db
      - cache
      - seeder
    labels:
      - autoheal=true
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}/health_checks/default"]
      interval: 10s
      timeout: 3s
      retries: 3
      start_period: 30s
    volumes:
      - "${OPDATA:-opdata}:/var/openproject/assets"
      - assets:/app/public

  autoheal:
    image: willfarrell/autoheal:1.2.0
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    environment:
      AUTOHEAL_CONTAINER_LABEL: autoheal
      AUTOHEAL_START_PERIOD: 600
      AUTOHEAL_INTERVAL: 30

  worker:
    <<: *app
    command: "./docker/prod/worker"
    networks:
      - backend
    depends_on:
      - db
      - cache
      - seeder
    volumes:
      - "${OPDATA:-opdata}:/var/openproject/assets"

  cron:
    <<: *app
    command: "./docker/prod/cron"
    networks:
      - backend
    depends_on:
      - db
      - cache
      - seeder
    volumes:
      - "${OPDATA:-opdata}:/var/openproject/assets"

  seeder:
    <<: *app
    command: "./docker/prod/seeder"
    restart: on-failure
    networks:
      - backend
    volumes:
      - "${OPDATA:-opdata}:/var/openproject/assets"

The ERROR I keep on getting:

/app/vendor/bundle/ruby/3.3.0/gems/pg-1.5.6/lib/pg/connection.rb:701:in `async_connect_or_reset': connection to server at "192.168.160.2", port 5432 failed: FATAL:  password authentication failed for user "postgres" (PG::ConnectionBad)

Thanks for all the help in advance!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the posted docker-compose.yml, comparing DATABASE_URL with POSTGRES_PASSWORD and checking how the existing pgdata volume affects the database credentials. Reproduce the first startup and inspect the database and seeder logs; done means the services initialize without the reported PG::ConnectionBad password error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker-compose, postgres
Domain
database, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.