Parameterize for use of environment variables and docker-compose
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 37.4k
- Forks
- 3k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 73
Description
What problem will this feature address?
My Infra setup: in my docker-compose.yaml for my Ubuntu 24.04 VPS server, using dokploy (the Docker container and this repo)
I face the error below , essentially about dokploy-postgres service. I already have teleport-postgresdb, so I don't want to have to rename my container/service, I want to use my teleport-postgresdb container - see my docker-compose.yaml
sudo docker logs -f dokploy
[dokploy@v0.24.8](vscode-file://vscode-app/Applications/Visual%20Studio%20Code%207.17.56%20PM.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html) start /app
node -r dotenv/config dist/server.mjs
Directory created: /etc/dokploy
Directory created: /etc/dokploy/traefik
Directory created: /etc/dokploy/traefik/dynamic
Directory created: /etc/dokploy/logs
Directory created: /etc/dokploy/applications
Directory created: /etc/dokploy/ssh
Directory created: /etc/dokploy/traefik/dynamic/certificates
Directory created: /etc/dokploy/monitoring
Directory created: /etc/dokploy/schedules
Directory created: /etc/dokploy/volume-backups
Network was initilized
Migration failed [Error: getaddrinfo EAI_AGAIN dokploy-postgres] {
errno: -3001,
code: 'EAI_AGAIN',
syscall: 'getaddrinfo',
hostname: 'dokploy-postgres'
}
Setting up cron jobs....
Main Server Error [Error: getaddrinfo EAI_AGAIN dokploy-postgres] {
errno: -3001,
code: 'EAI_AGAIN',
syscall: 'getaddrinfo',
hostname: 'dokploy-postgres'
}
#docker-compose.yaml
# Dokploy service
dokploy:
image: dokploy/dokploy:latest
container_name: dokploy
restart: unless-stopped
networks:
- infra_net
environment:
- DOKPLOY_PORT=3000
- DOKPLOY_TRAEFIK_ENABLED=false
- DOKPLOY_ROOT_DOMAIN=${APPS_DOMAIN}
- DOKPLOY_ADMIN_EMAIL=${EMAIL}
- DOKPLOY_ADMIN_PASSWORD=${CAPROVER_PASSWORD}
- DOKPLOY_SERVER_IP=${VPS_SERVER_IP}
# --- Add these lines for PostgreSQL connection ---
# - DOKPLOY_DATABASE_HOST=teleport-postgresdb
# - DOKPLOY_DATABASE_PORT=5432
# - DOKPLOY_DATABASE_USER=${TP_POSTGRES_DBUSER}
# - DOKPLOY_DATABASE_PASSWORD=${TP_POSTGRES_DBPASSWORD}
# - DOKPLOY_DATABASE_NAME=${TP_POSTGRES_DB}
- DATABASE_URL=postgres://${TP_POSTGRES_DBUSER}:${TP_POSTGRES_DBPASSWORD}@dokploy-postgres:5432/dokploy?sslmode=disable
# ------------------------------------------------
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- dokploy_data:/data
cap_add:
- NET_ADMIN
healthcheck:
test: ["CMD-SHELL", "curl -f [http://localhost:3000/health] || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "3"
depends_on:
teleport-postgresdb:
condition: service_healthy
For some reasons, dokploy seems to be very finicky and requiring the container's name to be exactly: dokploy-postgres. I had the container teleport-postgresdb in my docker-compose.yaml and tried adding network alias:
teleport-postgresdb:
build:
context: .
dockerfile: Dockerfile.postgres
env_file:
- /etc/infra.env
container_name: teleport-postgresdb
networks:
infra_net:
aliases:
- dokploy-postgres
but that didn't work, dokploy-postgres alias wasn't created, and I couldn't have been able to make the dokploy container request teleport-postgresdb
- DATABASE_URL=postgres://dokploy:${TP_POSTGRES_DBPASSWORD}@teleport-postgresdb:5432/dokploy?sslmode=disable
Also, when I use a different user for TP_POSTGRES_DBUSER, e.g. teleportPostgresdbUser, it didn't work either. It keeps confusing the username with the database name, error log says:
Main Server Error [Error [PostgresError]: database "teleportPostgresdbUser" does not exist] {
severity_local: 'FATAL',
severity: 'FATAL',
code: '3D000',
file: 'postinit.c',
line: '1032',
routine: 'InitPostgres'
}
In order for everything to work, I have to have exactly everything the same as in the repo code, container name: dokploy-postgres, postgres db user: dokploy, database: dokploy, and even db password must be the same.
I tried my own TP_POSTGRES_DBPASSWORD but it didn't work.
I carefully verified all my environment variables with docker exec -it dokploy env to ensure it is there, and yet, as long as the psql db password for dokploy user is different from the hardcoded password in the repo code, then I will still get this error:
Migration complete
Setting up cron jobs....
Main Server Error [Error [PostgresError]: password authentication failed for user "dokploy"] {
severity_local: 'FATAL',
severity: 'FATAL',
code: '28P01',
file: 'auth.c',
line: '321',
routine: 'auth_failed'
}
Describe the solution you'd like
I think the app is poorly written to require and restrict that for setup and launch, everything must be the same as in the repo code, container name: dokploy-postgres, postgres db user: dokploy, database: dokploy, and even db password must be the same. Or at least, it wasn't anticipated for deploying/launching along with other services/apps in docker-compose.yaml setup. Hence, parameterized attempt was done very poorly or lacks thereof.
I highly suggest reviewing the use of .env file, fix the jacked-up code to allow consuming of docker environment variables or (best to also accommodate) the use of mounted volume custom .env file. Especially, don't use the same word: dokploy for db username and database name in your code. Don't mandate the database container to be exactly named as dokploy-postgres
Describe alternatives you've considered
Parameterize to allow referencing to the user-choice's database container name that is other than dokploy-postgres
Parameterize to allow consuming of docker environment variables or (best to also accommodate) the use of mounted volume custom .env file
Additional context
No response
Will you send a PR to implement it?
Probably
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the repository's docker-compose.yaml and Dockerfile.postgres with the reported deployment configuration, then trace how the application consumes DATABASE_URL and related environment variables. The work is done when database host, user, name, password, and service naming can be configured without matching the repository's hardcoded Dokploy values, with the relevant Docker setup verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, docker-compose, postgresql, typescript
- Domain
- databases, devops
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100