diff --git a/pgadmin4/Dockerfile b/pgadmin4/Dockerfile index 49a34a5..92d1c83 100644 --- a/pgadmin4/Dockerfile +++ b/pgadmin4/Dockerfile @@ -44,9 +44,10 @@ ARG TARGETARCH ARG VERSION=4.24 ARG GUNICORN_VERSION=20.0.4 -RUN apt update -qq && apt install -qqy --no-install-recommends python3-pip python3-dev python3-setuptools libpq-dev gcc && \ +RUN export GH_VERSION=$(echo ${VERSION} | tr '.' '_') && \ + apt update -qq && \ + apt install -qqy --no-install-recommends curl python3-pip python3-dev python3-setuptools libpq-dev build-essential libffi-dev && \ pip3 install --no-cache-dir pgadmin4==${VERSION} gunicorn==${GUNICORN_VERSION} && \ - apt remove -qqy gcc python3-dev python3-pip libpq-dev&& apt autoremove -qqy && rm -rf /var/lib/apt/lists/* && \ ln -s /usr/local/lib/python3.7/dist-packages/pgadmin4 /pgadmin4 && \ ln -s /usr/bin/python3 /usr/bin/python && \ groupadd -g 5050 pgadmin && \ @@ -56,9 +57,12 @@ RUN apt update -qq && apt install -qqy --no-install-recommends python3-pip pytho mkdir -p /var/log/pgadmin && \ chown pgadmin:pgadmin /var/log/pgadmin && \ touch /pgadmin4/config_distro.py && \ - chown pgadmin:pgadmin /pgadmin4/config_distro.py -COPY entrypoint.sh /entrypoint.sh -COPY run_pgadmin.py /pgadmin4/ + chown pgadmin:pgadmin /pgadmin4/config_distro.py && \ + curl -o /pgadmin4/run_pgadmin.py https://raw.githubusercontent.com/postgres/pgadmin4/REL-${GH_VERSION}/pkg/docker/run_pgadmin.py && \ + curl -o /entrypoint.sh https://raw.githubusercontent.com/postgres/pgadmin4/REL-${GH_VERSION}/pkg/docker/entrypoint.sh && \ + chmod +x /entrypoint.sh && \ + apt remove -qqy python3-dev python3-pip libpq-dev build-essential libffi-dev curl && \ + apt autoremove -qqy && rm -rf /var/lib/apt/lists/* WORKDIR /pgadmin4 USER 5050 VOLUME /var/lib/pgadmin diff --git a/pgadmin4/entrypoint.sh b/pgadmin4/entrypoint.sh deleted file mode 100755 index 42a2570..0000000 --- a/pgadmin4/entrypoint.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh - -# Populate config_distro.py. This has some default config, as well as anything -# provided by the user through the PGADMIN_CONFIG_* environment variables. -# Only update the file on first launch. The empty file is created during the -# container build so it can have the required ownership. -if [ `wc -m /pgadmin4/config_distro.py | awk '{ print $1 }'` = "0" ]; then - cat << EOF > /pgadmin4/config_distro.py -HELP_PATH = '../../docs' -DEFAULT_BINARY_PATHS = { - 'pg': '/usr/local/pgsql-12' -} -EOF - - # This is a bit kludgy, but necessary as the container uses BusyBox/ash as - # it's shell and not bash which would allow a much cleaner implementation - for var in $(env | grep PGADMIN_CONFIG_ | cut -d "=" -f 1); do - echo ${var#PGADMIN_CONFIG_} = $(eval "echo \$$var") >> /pgadmin4/config_distro.py - done -fi - -if [ ! -f /var/lib/pgadmin/pgadmin4.db ]; then - if [ -z "${PGADMIN_DEFAULT_EMAIL}" -o -z "${PGADMIN_DEFAULT_PASSWORD}" ]; then - echo 'You need to specify PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD environment variables' - exit 1 - fi - - # Set the default username and password in a - # backwards compatible way - export PGADMIN_SETUP_EMAIL=${PGADMIN_DEFAULT_EMAIL} - export PGADMIN_SETUP_PASSWORD=${PGADMIN_DEFAULT_PASSWORD} - - # Initialize DB before starting Gunicorn - # Importing pgadmin4 (from this script) is enough - python run_pgadmin.py - - export PGADMIN_SERVER_JSON_FILE=${PGADMIN_SERVER_JSON_FILE:-/pgadmin4/servers.json} - # Pre-load any required servers - if [ -f "${PGADMIN_SERVER_JSON_FILE}" ]; then - # When running in Desktop mode, no user is created - # so we have to import servers anonymously - if [ "${PGADMIN_CONFIG_SERVER_MODE}" = "False" ]; then - /usr/local/bin/python /pgadmin4/setup.py --load-servers "${PGADMIN_SERVER_JSON_FILE}" - else - /usr/local/bin/python /pgadmin4/setup.py --load-servers "${PGADMIN_SERVER_JSON_FILE}" --user ${PGADMIN_DEFAULT_EMAIL} - fi - fi -fi - -# Get the session timeout from the pgAdmin config. We'll use this (in seconds) -# to define the Gunicorn worker timeout -TIMEOUT=$(cd /pgadmin4 && python -c 'import config; print(config.SESSION_EXPIRATION_TIME * 60 * 60 * 24)') - -# NOTE: currently pgadmin can run only with 1 worker due to sessions implementation -# Using --threads to have multi-threaded single-process worker - -if [ ! -z ${PGADMIN_ENABLE_TLS} ]; then - exec gunicorn --timeout ${TIMEOUT} --bind ${PGADMIN_LISTEN_ADDRESS:-[::]}:${PGADMIN_LISTEN_PORT:-8443} -w 1 --threads ${GUNICORN_THREADS:-25} --access-logfile ${GUNICORN_ACCESS_LOGFILE:--} --keyfile /certs/server.key --certfile /certs/server.cert run_pgadmin:app -else - exec gunicorn --timeout ${TIMEOUT} --bind ${PGADMIN_LISTEN_ADDRESS:-[::]}:${PGADMIN_LISTEN_PORT:-8080} -w 1 --threads ${GUNICORN_THREADS:-25} --access-logfile ${GUNICORN_ACCESS_LOGFILE:--} run_pgadmin:app -fi diff --git a/pgadmin4/run_pgadmin.py b/pgadmin4/run_pgadmin.py deleted file mode 100644 index 48b1773..0000000 --- a/pgadmin4/run_pgadmin.py +++ /dev/null @@ -1,4 +0,0 @@ -import builtins -builtins.SERVER_MODE = True - -from pgAdmin4 import app diff --git a/readme.adoc b/readme.adoc index 7c2093d..598752f 100644 --- a/readme.adoc +++ b/readme.adoc @@ -5,7 +5,7 @@ On debian : ``` install docker CE from docker as packaged version is not egal or higher than 19.03 -apt install binfmt-support +apt install qemu-user-static +docker buildx create --use --platform linux/amd64,linux/arm64,linux/arm,linux/ppc64le -docker buildx create --use ```