wwebjs-api
wwebjs-api copied to clipboard
feat: allow host port to be configured via environment variable in Docker
Hi, this PR enhances the Docker setup to allow the host port to be configured dynamically.
The Problem
Currently, the docker-compose.yml file has the host port hardcoded as 3000 in the ports mapping ("3000:3000").
This becomes an issue in certain deployment environments (like Coolify, Dokploy, etc.) where the docker-compose.yml file is often read-only. In such cases, users cannot easily change the host port if 3000 is already in use, as they can only modify environment variables.
The Solution
This change updates the port mapping in docker-compose.yml to use an environment variable:
- ports:
- - "3000:3000"
+ ports:
+ - "${PORT:-3000}:3000"
This implementation:
- Uses the value of the
$PORTenvironment variable for the host port. - Falls back to
3000if the$PORTvariable is not set, ensuring backward compatibility for existing users.
This provides greater flexibility for deploying the application without introducing any breaking changes.