-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
Is your feature request related to a problem? Please describe.
Currently, there are multiple environment variables for each type of database connection. So if several environment variables are passed, for example from Postgres
and MySQL
/MariaDB
, which one will actually be used as the connection?
Describe the solution you'd like
This should be easier when specifying the database engine, configuring fewer environment variables, and knowing where they will be set based on the DB_ENGINE
environment variable.
Replace the environment variables and unify them as follows:
DB_MYSQL_HOST
andDB_POSTGRES_HOST
, withDB_HOST
.DB_MYSQL_PORT
andDB_POSTGRES_PORT
, withDB_HOST
.DB_MYSQL_USER
andDB_POSTGRES_USER
withDB_USER
.DB_MYSQL_PASSWORD
andDB_POSTGRES_PASSWORD
withDB_PASSWORD
.DB_MYSQL_NAME
andDB_POSTGRES_NAME
withDB_NAME
.
Describe alternatives you've considered
MySQL/MariaDB stack:
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
restart: unless-stopped
ports:
# These ports are in format <host-port>:<container-port>
- '80:80' # Public HTTP Port
- '443:443' # Public HTTPS Port
- '81:81' # Admin Web Port
# Add any other Stream port you want to expose
# - '21:21' # FTP
environment:
# MySQL/MariaDB connection parameters:
DB_ENGINE: 'mysql'
DB_HOST: "db"
DB_PORT: 3306
DB_NAME: "npm"
DB_USER: "npm"
DB_PASSWORD: "npm"
# Uncomment this if IPv6 is not enabled on your host
# DISABLE_IPV6: 'true'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
depends_on:
- db
db:
image: 'jc21/mariadb-aria:latest'
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: 'npm'
MYSQL_DATABASE: 'npm'
MYSQL_USER: 'npm'
MYSQL_PASSWORD: 'npm'
MARIADB_AUTO_UPGRADE: '1'
volumes:
- ./mysql:/var/lib/mysql
Postgres stack:
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
restart: unless-stopped
ports:
# These ports are in format <host-port>:<container-port>
- '80:80' # Public HTTP Port
- '443:443' # Public HTTPS Port
- '81:81' # Admin Web Port
# Add any other Stream port you want to expose
# - '21:21' # FTP
environment:
# PostgreSQL parameters:
DB_ENGINE: 'postgres'
DB_HOST: 'db'
DB_PORT: '5432'
DB_NAME: 'npm'
DB_USER: 'npm'
DB_PASSWORD: 'npmpass'
# Uncomment this if IPv6 is not enabled on your host
# DISABLE_IPV6: 'true'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
depends_on:
- db
db:
image: postgres:latest
environment:
POSTGRES_USER: 'npm'
POSTGRES_PASSWORD: 'npmpass'
POSTGRES_DB: 'npm'
volumes:
- ./postgres:/var/lib/postgresql/data
Additional context
The same could work for other SQL databases such as Firebird, Microsoft SQL Server, Oracle, or Amazon Relational Database Service.