mirror of
https://gitlab.com/alemaire/buildx.git
synced 2025-01-17 13:58:19 +00:00
initial commit
This commit is contained in:
2
pgadmin4/.version
Normal file
2
pgadmin4/.version
Normal file
@ -0,0 +1,2 @@
|
||||
VERSION=4.24
|
||||
GUNICORN_VERSION=20.0.4
|
62
pgadmin4/Dockerfile
Normal file
62
pgadmin4/Dockerfile
Normal file
@ -0,0 +1,62 @@
|
||||
FROM postgres:9.5 as pg95-builder
|
||||
FROM postgres:9.6 as pg96-builder
|
||||
FROM postgres:10 as pg10-builder
|
||||
FROM postgres:11 as pg11-builder
|
||||
FROM postgres:12 as pg12-builder
|
||||
|
||||
FROM debian:stable-20200720-slim as tool-builder
|
||||
|
||||
# Copy the PG binaries
|
||||
COPY --from=pg95-builder /usr/lib/postgresql/9.5/bin/pg_dump /usr/local/pgsql/pgsql-9.5/
|
||||
COPY --from=pg95-builder /usr/lib/postgresql/9.5/bin/pg_dumpall /usr/local/pgsql/pgsql-9.5/
|
||||
COPY --from=pg95-builder /usr/lib/postgresql/9.5/bin/pg_restore /usr/local/pgsql/pgsql-9.5/
|
||||
COPY --from=pg95-builder /usr/lib/postgresql/9.5/bin/psql /usr/local/pgsql/pgsql-9.5/
|
||||
|
||||
COPY --from=pg96-builder /usr/lib/postgresql/9.6/bin/pg_dump /usr/local/pgsql/pgsql-9.6/
|
||||
COPY --from=pg96-builder /usr/lib/postgresql/9.6/bin/pg_dumpall /usr/local/pgsql/pgsql-9.6/
|
||||
COPY --from=pg96-builder /usr/lib/postgresql/9.6/bin/pg_restore /usr/local/pgsql/pgsql-9.6/
|
||||
COPY --from=pg96-builder /usr/lib/postgresql/9.6/bin/psql /usr/local/pgsql/pgsql-9.6/
|
||||
|
||||
COPY --from=pg10-builder /usr/lib/postgresql/10/bin/pg_dump /usr/local/pgsql/pgsql-10/
|
||||
COPY --from=pg10-builder /usr/lib/postgresql/10/bin/pg_dumpall /usr/local/pgsql/pgsql-10/
|
||||
COPY --from=pg10-builder /usr/lib/postgresql/10/bin/pg_restore /usr/local/pgsql/pgsql-10/
|
||||
COPY --from=pg10-builder /usr/lib/postgresql/10/bin/psql /usr/local/pgsql/pgsql-10/
|
||||
|
||||
COPY --from=pg11-builder /usr/lib/postgresql/11/bin/pg_dump /usr/local/pgsql/pgsql-11/
|
||||
COPY --from=pg11-builder /usr/lib/postgresql/11/bin/pg_dumpall /usr/local/pgsql/pgsql-11/
|
||||
COPY --from=pg11-builder /usr/lib/postgresql/11/bin/pg_restore /usr/local/pgsql/pgsql-11/
|
||||
COPY --from=pg11-builder /usr/lib/postgresql/11/bin/psql /usr/local/pgsql/pgsql-11/
|
||||
|
||||
COPY --from=pg12-builder /usr/lib/postgresql/12/bin/pg_dump /usr/local/pgsql/pgsql-12/
|
||||
COPY --from=pg12-builder /usr/lib/postgresql/12/bin/pg_dumpall /usr/local/pgsql/pgsql-12/
|
||||
COPY --from=pg12-builder /usr/lib/postgresql/12/bin/pg_restore /usr/local/pgsql/pgsql-12/
|
||||
COPY --from=pg12-builder /usr/lib/postgresql/12/bin/psql /usr/local/pgsql/pgsql-12/
|
||||
|
||||
|
||||
FROM debian:stable-20200720-slim
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
COPY --from=tool-builder /usr/local/pgsql /usr/local/
|
||||
|
||||
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 gcc && \
|
||||
pip3 install --no-cache-dir pgadmin4==${VERSION} gunicorn==${GUNICORN_VERSION} && \
|
||||
apt remove -qqy gcc python3-dev python3-pip && 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 && \
|
||||
useradd -r -u 5050 -g pgadmin pgadmin && \
|
||||
mkdir -p /var/lib/pgadmin && \
|
||||
chown pgadmin:pgadmin /var/lib/pgadmin && \
|
||||
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/
|
||||
WORKDIR /pgadmin4
|
||||
USER 5050
|
||||
VOLUME /var/lib/pgadmin
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
15
pgadmin4/Makefile
Normal file
15
pgadmin4/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
include pgadmin4/.version
|
||||
|
||||
pgadmin4-nopush:
|
||||
docker buildx build --platform linux/amd64 --load \
|
||||
--build-arg VERSION=$(VERSION) \
|
||||
--build-arg GUNICORN_VERSION=$(GUNICORN_VERSION) \
|
||||
--tag alemairebe/pgadmin4:$(VERSION) pgadmin4
|
||||
|
||||
pgadmin4:
|
||||
docker buildx build --platform linux/amd64,linux/arm64,linux/arm --push \
|
||||
--build-arg VERSION=$(VERSION) \
|
||||
--build-arg GUNICORN_VERSION=$(GUNICORN_VERSION) \
|
||||
--cache-from=type=registry,ref=alemairebe/pgadmin4:buildx \
|
||||
--cache-to=type=registry,ref=alemairebe/pgadmin4:buildx \
|
||||
--tag alemairebe/pgadmin4:$(VERSION) pgadmin4
|
61
pgadmin4/entrypoint.sh
Executable file
61
pgadmin4/entrypoint.sh
Executable file
@ -0,0 +1,61 @@
|
||||
#!/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
|
4
pgadmin4/run_pgadmin.py
Normal file
4
pgadmin4/run_pgadmin.py
Normal file
@ -0,0 +1,4 @@
|
||||
import builtins
|
||||
builtins.SERVER_MODE = True
|
||||
|
||||
from pgAdmin4 import app
|
Reference in New Issue
Block a user