diff --git a/auth-api/src/auth_api/config.py b/auth-api/src/auth_api/config.py index bd5a71c25..f5ea7f85d 100644 --- a/auth-api/src/auth_api/config.py +++ b/auth-api/src/auth_api/config.py @@ -74,7 +74,10 @@ class _Config: # pylint: disable=too-few-public-methods DB_NAME = os.getenv('DATABASE_NAME', '') DB_HOST = os.getenv('DATABASE_HOST', '') DB_PORT = os.getenv('DATABASE_PORT', '5432') - SQLALCHEMY_DATABASE_URI = f'postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{int(DB_PORT)}/{DB_NAME}' + if DB_UNIX_SOCKET := os.getenv('DATABASE_UNIX_SOCKET', None): + SQLALCHEMY_DATABASE_URI = f'postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@/{DB_NAME}?host={DB_UNIX_SOCKET}' + else: + SQLALCHEMY_DATABASE_URI = f'postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{int(DB_PORT)}/{DB_NAME}' SQLALCHEMY_ECHO = False SQLALCHEMY_TRACK_MODIFICATIONS = False diff --git a/auth-api/wsgi.py b/auth-api/wsgi.py index 612a6e370..d841635d2 100644 --- a/auth-api/wsgi.py +++ b/auth-api/wsgi.py @@ -13,6 +13,7 @@ # limitations under the License. """Provides the WSGI entry point for running the application """ +import os from auth_api import create_app @@ -20,4 +21,5 @@ app = create_app() # pylint: disable=invalid-name if __name__ == "__main__": - app.run() + server_port = os.environ.get('PORT', '8080') + app.run(debug=False, port=server_port, host='0.0.0.0')