Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose UNIX socket in entrypoint.sh for Docker implementation #7221

Closed
DJviolin opened this issue Feb 17, 2024 · 3 comments
Closed

Expose UNIX socket in entrypoint.sh for Docker implementation #7221

DJviolin opened this issue Feb 17, 2024 · 3 comments
Assignees
Milestone

Comments

@DJviolin
Copy link
Contributor

DJviolin commented Feb 17, 2024

Describe the solution you'd like

Can you implement in entrypoint.sh to expose UNIX socket for a reverse proxy like Nginx, maybe defined with an environment variable like PGADMIN_SOCK or your liking? It will automatically take presence over listen address and port. In a Docker Compose stack, where most of the communication managed with UNIX sockets between containers, current pgAdmin container not supporting such deployment.

The official server deployment docs giving examples such Gunicorn setup: https://www.pgadmin.org/docs/pgadmin4/latest/server_deployment.html

@DJviolin
Copy link
Contributor Author

DJviolin commented Feb 17, 2024

I use this possible implementation at the end of my monkey patched entrypoint.sh:

if [ -n "${PGADMIN_SOCK}" ]; then
	BIND_ADDRESS="unix:${PGADMIN_SOCK}"
else
	if [ -n "${PGADMIN_ENABLE_TLS}" ]; then
		BIND_ADDRESS="${PGADMIN_LISTEN_ADDRESS:-[::]}:${PGADMIN_LISTEN_PORT:-443}"
	else
		BIND_ADDRESS="${PGADMIN_LISTEN_ADDRESS:-[::]}:${PGADMIN_LISTEN_PORT:-80}"
	fi
fi

if [ -n "${PGADMIN_ENABLE_TLS}" ]; then
	exec /venv/bin/gunicorn --limit-request-line "${GUNICORN_LIMIT_REQUEST_LINE:-8190}" --timeout "${TIMEOUT}" --bind "${BIND_ADDRESS}" -w 1 --threads "${GUNICORN_THREADS:-25}" --access-logfile "${GUNICORN_ACCESS_LOGFILE:--}" --keyfile /certs/server.key --certfile /certs/server.cert -c gunicorn_config.py run_pgadmin:app
else
	exec /venv/bin/gunicorn --limit-request-line "${GUNICORN_LIMIT_REQUEST_LINE:-8190}" --timeout "${TIMEOUT}" --bind "${BIND_ADDRESS}" -w 1 --threads "${GUNICORN_THREADS:-25}" --access-logfile "${GUNICORN_ACCESS_LOGFILE:--}" -c gunicorn_config.py run_pgadmin:app
fi

Where PGADMIN_SOCK is /run/pgadmin/pgadmin.sock. I use separate folders for sockets in Docker Compose for convenience with volumes.

Of course, the folder also has to exist with needed rights:

mkdir -p /run/pgadmin
chown pgadmin:root /run/pgadmin

@khushboovashi
Copy link
Contributor

@DJviolin, Please raise a PR @ https://github.com/pgadmin-org/pgadmin4/pulls for the same.

@DJviolin
Copy link
Contributor Author

PR opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants