mirror of
https://github.com/frappe/gunicorn.git
synced 2026-07-01 10:11:30 +08:00
- Add docker/Dockerfile with non-root user and configurable environment - Add GitHub Actions workflow to build multi-platform images (amd64/arm64) - Publish to ghcr.io/benoitc/gunicorn on version tags - Update documentation with official image usage examples
34 lines
1.2 KiB
Bash
34 lines
1.2 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
# Allow running other commands (e.g., bash for debugging)
|
|
if [ "${1:0:1}" = '-' ] || [ -z "${1##*:*}" ]; then
|
|
# First arg is a flag or contains ':' (app:callable), run gunicorn
|
|
|
|
# Build bind address from GUNICORN_HOST and GUNICORN_PORT, or use GUNICORN_BIND
|
|
# Default: listen on both IPv4 and IPv6
|
|
PORT="${GUNICORN_PORT:-8000}"
|
|
BIND="${GUNICORN_BIND:-${GUNICORN_HOST:-[::]}:${PORT}}"
|
|
|
|
# Add bind if not specified in args or GUNICORN_ARGS
|
|
if [[ ! " $* $GUNICORN_ARGS " =~ " --bind " ]] && [[ ! " $* $GUNICORN_ARGS " =~ " -b " ]] && [[ ! "$* $GUNICORN_ARGS" =~ --bind= ]] && [[ ! "$* $GUNICORN_ARGS" =~ -b= ]]; then
|
|
set -- --bind "$BIND" "$@"
|
|
fi
|
|
|
|
# Add workers if not specified - default to number of CPUs
|
|
if [[ ! " $* $GUNICORN_ARGS " =~ " --workers " ]] && [[ ! " $* $GUNICORN_ARGS " =~ " -w " ]] && [[ ! "$* $GUNICORN_ARGS" =~ --workers= ]] && [[ ! "$* $GUNICORN_ARGS" =~ -w= ]]; then
|
|
WORKERS="${GUNICORN_WORKERS:-$(nproc)}"
|
|
set -- --workers "$WORKERS" "$@"
|
|
fi
|
|
|
|
# Append GUNICORN_ARGS if set
|
|
if [ -n "$GUNICORN_ARGS" ]; then
|
|
exec gunicorn $GUNICORN_ARGS "$@"
|
|
fi
|
|
|
|
exec gunicorn "$@"
|
|
fi
|
|
|
|
# Otherwise, run the command as-is (e.g., bash, sh, python)
|
|
exec "$@"
|