API's start.sh doesn't honour DB_HOST/DB_PORT
hhharsha36 opened this issue · 6 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
.
This is because the db
container is hardcoded in the Dockerfile
You should be able to fix it with:
services:
api:
command: ["start.sh", "${DB_HOST}", "${DB_PORT}", "yarn", "start"]
Thanks for your quick response @XeR
I am getting the below error when I made the proposed change:
ctfnote_api | /app/start.sh:2
ctfnote_api | readonly MAX_RETRIES=5
ctfnote_api | ^^^^^^^^^^^
ctfnote_api |
ctfnote_api | SyntaxError: Unexpected identifier
ctfnote_api | at Object.compileFunction (node:vm:352:18)
ctfnote_api | at wrapSafe (node:internal/modules/cjs/loader:1033:15)
ctfnote_api | at Module._compile (node:internal/modules/cjs/loader:1069:27)
ctfnote_api | at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
ctfnote_api | at Module.load (node:internal/modules/cjs/loader:981:32)
ctfnote_api | at Function.Module._load (node:internal/modules/cjs/loader:822:12)
ctfnote_api | at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
ctfnote_api | at node:internal/main/run_main_module:17:47
Oops ! I meant ./start.sh
instead of start.sh
Changing it to ./start.sh
worked.
Below is the complete command if anyone else is facing the same issue:
services:
api:
command: ["./start.sh", "${DB_HOST}", "${DB_PORT}", "yarn", "start"]
Reopening this because this should be fixed