diff --git a/.env.example b/.env.example index 38dbcdb..54a19a9 100644 --- a/.env.example +++ b/.env.example @@ -72,12 +72,10 @@ IDHUB_ENABLE_2FACTOR_AUTH=false IDHUB_ENABLE_DOMAIN_CHECKER=false IDHUB_PREDEFINED_TOKEN='27f944ce-3d58-4f48-b068-e4aa95f97c95' - - #POSTGRES VARS DB_NAME="devicehub" DB_USER="ereuse" DB_PASSWORD="ereuse" -DB_DOMAIN=localhost -DB_PORT=8000 +DB_HOST=localhost +DB_PORT=5432 diff --git a/dhub/settings.py b/dhub/settings.py index 3da04de..9ac673a 100644 --- a/dhub/settings.py +++ b/dhub/settings.py @@ -136,9 +136,9 @@ DATABASES = { 'default': { 'ENGINE': os.getenv('DB_ENGINE', 'django.db.backends.postgresql'), 'NAME': os.getenv('DB_NAME', 'devicehub'), - 'USER': os.getenv('DB_USER', 'devicehub'), - 'PASSWORD': os.getenv('DB_PASSWORD', 'devicehub'), - 'HOST': os.getenv('DB_HOST', 'postgres'), + 'USER': os.getenv('DB_USER', 'ereuse'), + 'PASSWORD': os.getenv('DB_PASSWORD', 'ereuse'), + 'HOST': os.getenv('DB_HOST', 'devicehub-postgres'), 'PORT': os.getenv('DB_PORT', '5432'), } } diff --git a/docker-compose.yml b/docker-compose.yml index 0d93468..c514b68 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,24 +21,18 @@ services: ports: - ${DEVICEHUB_PORT:-8000}:${DEVICEHUB_PORT:-8000} depends_on: - - postgres + - devicehub-postgres devicehub-postgres: image: postgres:17 environment: - - DB_NAME=${DB_NAME:-devicehub} - - db_USER=${DB_USER:-devicehub} - - db_PASSWORD=${DB_PASSWORD:-devicehub} + - POSTGRES_DB=${DB_NAME} + - POSTGRES_USER=${DB_USER} + - POSTGRES_PASSWORD=${DB_PASSWORD} volumes: - pg_data:/var/lib/postgresql/data - ports: - - ${DB_PORT}:${DB_PORT} - - - -volumes: - pg_data: - + #ports: + # - ${DB_PORT}:${DB_PORT} # TODO add database service for idhub, meanwhile sqlite @@ -76,3 +70,6 @@ volumes: - 9001:9001 # TODO add database service for idhub, meanwhile sqlite + +volumes: + pg_data: diff --git a/docker/devicehub-django.entrypoint.sh b/docker/devicehub-django.entrypoint.sh index ef3ac86..27aa7d0 100644 --- a/docker/devicehub-django.entrypoint.sh +++ b/docker/devicehub-django.entrypoint.sh @@ -6,6 +6,7 @@ set -u set -x program_dir='/opt/devicehub-django' +#source .env . "${program_dir}/.env" wait_for_postgres() { @@ -45,11 +46,11 @@ gen_env_vars() { ADMIN='True' PREDEFINED_TOKEN="${PREDEFINED_TOKEN:-}" - DB_NAME=${DB_NAME:-devicehub} - DB_USER=${DB_USER:-ereuse} - DB_PASSWORD=${DB_PASSWORD:-ereuse} - DB_HOST=${DB_HOST:-localhost} - DB_PORT=${DB_PORT:-5432} + DB_NAME="${DB_NAME:-devicehub}" + DB_USER="${DB_USER:-ereuse}" + DB_PASSWORD="${DB_PASSWORD:-ereuse}" + DB_HOST="${DB_HOST:-localhost}" + DB_PORT="${DB_PORT:-5432}" # specific dpp env vars if [ "${DPP:-}" = 'true' ]; then