CTFNote icon indicating copy to clipboard operation
CTFNote copied to clipboard

API's start.sh doesn't honour DB_HOST/DB_PORT

Open hhharsha36 opened this issue 11 months ago • 5 comments

Below is my docker-compose file

version: "3.7"
services:
  api:
    image: ghcr.io/tfns/ctfnote/api:latest
    container_name: ctfnote_api
    networks:
      - ctfnote
    restart: unless-stopped
    extra_hosts:
      - "host.docker.internal:host-gateway"
    env_file: .env
    environment:
      DB_HOST: ${DB_HOST}
      DB_PORT: ${DB_PORT}
      PAD_CREATE_URL: http://hedgedoc:3000/new
      PAD_SHOW_URL: /
      DB_DATABASE: ${DB_USERNAME}
      DB_ADMIN_LOGIN: ${DB_USERNAME}
      DB_ADMIN_PASSWORD: ${DB_PASSWORD}
      DB_USER_LOGIN: ${DB_USERNAME}
      DB_USER_PASSWORD: ${DB_PASSWORD}
      WEB_PORT: 3000
    volumes:
      - ./ctfnote-uploads:/app/uploads
    labels:
      - "diun.enable=true"
      - "diun.notify_on=new;update"

  front:
    image: ghcr.io/tfns/ctfnote/front:latest
    container_name: ctfnote_front
    networks:
      - ctfnote
    restart: unless-stopped
    depends_on:
      - hedgedoc
    ports:
      - 80:80
    labels:
      - "diun.enable=true"
      - "diun.notify_on=new;update"

  hedgedoc:
    image: quay.io/hedgedoc/hedgedoc:latest
    container_name: ctfnote_hedgedoc
    extra_hosts:
      - "host.docker.internal:host-gateway"
    env_file: .env
    environment:
      - CMD_DB_URL=${HEDGEDOC_DB_URI}
      - CMD_URL_PATH=pad
      - CMD_DOMAIN
      - CMD_PROTOCOL_USESSL
      - CMD_CSP_ENABLE=${CMD_CSP_ENABLE:-false}
      - CMD_IMAGE_UPLOAD_TYPE=${CMD_IMAGE_UPLOAD_TYPE:-imgur}
      - CMD_LOGLEVEL=warn
    restart: unless-stopped
    volumes:
      - ./pad-uploads:/hedgedoc/public/uploads
    networks:
      - ctfnote
    labels:
      - "diun.enable=true"
      - "diun.notify_on=new;update"

networks:
  ctfnote:
    external: false

When I start the stack, I am getting the following error from ctfnote_api

ctfnote_api | nc: bad address 'db'

The DB_HOST value is host.docker.internal and the host and port refers to Postgres deployed on a separate container. The ctfnote user has owner access to ctfnote db and I have cross-verified it manually as well.

Yet I do not know why I getting the bad address db error.

hhharsha36 avatar Mar 06 '24 02:03 hhharsha36