2019-09-16 13:48:11 +01:00
|
|
|
########################################################################
|
|
|
|
|
#
|
|
|
|
|
# pgAdmin 4 - PostgreSQL Tools
|
|
|
|
|
#
|
2026-01-05 13:33:45 +05:30
|
|
|
# Copyright (C) 2013 - 2026, The pgAdmin Development Team
|
2019-09-16 13:48:11 +01:00
|
|
|
# This software is released under the PostgreSQL Licence
|
|
|
|
|
#
|
|
|
|
|
#########################################################################
|
|
|
|
|
|
|
|
|
|
#########################################################################
|
|
|
|
|
# Create a Node container which will be used to build the JS components
|
|
|
|
|
# and clean up the web/ source code
|
|
|
|
|
#########################################################################
|
|
|
|
|
|
2022-12-07 11:03:51 +00:00
|
|
|
FROM alpine:latest AS app-builder
|
2019-09-16 13:48:11 +01:00
|
|
|
|
|
|
|
|
RUN apk add --no-cache \
|
|
|
|
|
autoconf \
|
|
|
|
|
automake \
|
|
|
|
|
bash \
|
|
|
|
|
g++ \
|
2021-02-09 13:12:19 +00:00
|
|
|
git \
|
2019-09-16 13:48:11 +01:00
|
|
|
libc6-compat \
|
|
|
|
|
libjpeg-turbo-dev \
|
|
|
|
|
libpng-dev \
|
2021-02-10 10:21:06 +00:00
|
|
|
libtool \
|
2019-09-16 13:48:11 +01:00
|
|
|
make \
|
|
|
|
|
nasm \
|
2021-02-09 13:12:19 +00:00
|
|
|
nodejs \
|
2023-03-27 10:56:04 +01:00
|
|
|
npm \
|
2021-02-09 13:12:19 +00:00
|
|
|
yarn \
|
2019-09-16 13:48:11 +01:00
|
|
|
zlib-dev
|
|
|
|
|
|
2026-01-05 11:29:50 +04:00
|
|
|
# Create the /pgadmin4 directory and copy the source into it
|
2019-09-16 13:48:11 +01:00
|
|
|
COPY web /pgadmin4/web
|
|
|
|
|
WORKDIR /pgadmin4/web
|
|
|
|
|
|
|
|
|
|
# Build the JS vendor code in the app-builder, and then remove the vendor source.
|
2026-01-01 12:30:49 +04:00
|
|
|
RUN --mount=type=bind,source=.git,target=/pgadmin4/.git \
|
|
|
|
|
--mount=type=tmpfs,target=node_modules \
|
|
|
|
|
--mount=type=tmpfs,target=pgadmin/static/js/generated/.cache \
|
|
|
|
|
export CPPFLAGS="-DPNG_ARM_NEON_OPT=0" && \
|
2024-05-23 18:19:08 +05:30
|
|
|
npm install -g corepack && \
|
|
|
|
|
corepack enable && \
|
2023-10-26 15:17:41 +05:30
|
|
|
yarn set version berry && \
|
2026-07-23 07:36:29 +00:00
|
|
|
yarn set version "$(node -p "require('./package.json').packageManager.split('@')[1]")" && \
|
2021-02-23 16:12:55 +00:00
|
|
|
yarn install && \
|
2019-09-16 13:48:11 +01:00
|
|
|
yarn run bundle && \
|
2026-01-01 12:30:49 +04:00
|
|
|
rm -rf yarn.lock \
|
2019-09-16 13:48:11 +01:00
|
|
|
package.json \
|
|
|
|
|
.[^.]* \
|
|
|
|
|
babel.cfg \
|
|
|
|
|
webpack.* \
|
2023-10-23 17:43:17 +05:30
|
|
|
jest.config.js \
|
2026-01-01 12:30:49 +04:00
|
|
|
babel.*
|
2019-09-16 13:48:11 +01:00
|
|
|
|
|
|
|
|
#########################################################################
|
2021-02-09 13:12:19 +00:00
|
|
|
# Next, create the base environment for Python
|
2019-09-16 13:48:11 +01:00
|
|
|
#########################################################################
|
|
|
|
|
|
2025-11-19 09:29:27 +04:00
|
|
|
FROM python:3-alpine AS env-builder
|
2019-09-16 13:48:11 +01:00
|
|
|
|
2021-02-01 10:52:41 +00:00
|
|
|
# Install dependencies
|
2024-06-12 18:09:06 +05:30
|
|
|
RUN apk add --no-cache \
|
2025-11-19 09:29:27 +04:00
|
|
|
make && \
|
2021-02-09 13:12:19 +00:00
|
|
|
apk add --no-cache --virtual build-deps \
|
2019-09-16 13:48:11 +01:00
|
|
|
build-base \
|
|
|
|
|
openssl-dev \
|
2021-02-01 10:52:41 +00:00
|
|
|
libffi-dev \
|
|
|
|
|
postgresql-dev \
|
2021-02-08 11:00:41 +00:00
|
|
|
krb5-dev \
|
|
|
|
|
rust \
|
2021-02-09 13:12:19 +00:00
|
|
|
cargo \
|
2021-12-02 16:47:18 +05:30
|
|
|
zlib-dev \
|
|
|
|
|
libjpeg-turbo-dev \
|
2026-01-01 12:30:49 +04:00
|
|
|
libpng-dev
|
|
|
|
|
COPY requirements.txt /
|
|
|
|
|
RUN python3 -m venv --system-site-packages --without-pip /venv && \
|
2021-02-09 13:12:19 +00:00
|
|
|
/venv/bin/python3 -m pip install --no-cache-dir -r requirements.txt && \
|
|
|
|
|
apk del --no-cache build-deps
|
|
|
|
|
|
|
|
|
|
#########################################################################
|
|
|
|
|
# Now, create a documentation build container for the Sphinx docs
|
|
|
|
|
#########################################################################
|
|
|
|
|
|
2023-06-09 15:28:46 +05:30
|
|
|
FROM env-builder AS docs-builder
|
2021-02-09 13:12:19 +00:00
|
|
|
|
|
|
|
|
# Install Sphinx
|
2023-01-17 17:30:22 +05:30
|
|
|
RUN /venv/bin/python3 -m pip install --no-cache-dir sphinx
|
2022-12-19 11:59:21 +05:30
|
|
|
RUN /venv/bin/python3 -m pip install --no-cache-dir sphinxcontrib-youtube
|
2019-09-16 13:48:11 +01:00
|
|
|
|
|
|
|
|
# Copy the docs from the local tree. Explicitly remove any existing builds that
|
|
|
|
|
# may be present
|
|
|
|
|
COPY docs /pgadmin4/docs
|
|
|
|
|
COPY web /pgadmin4/web
|
|
|
|
|
RUN rm -rf /pgadmin4/docs/en_US/_build
|
|
|
|
|
|
|
|
|
|
# Build the docs
|
2021-02-09 13:12:19 +00:00
|
|
|
RUN LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 /venv/bin/sphinx-build /pgadmin4/docs/en_US /pgadmin4/docs/en_US/_build/html
|
2019-09-16 13:48:11 +01:00
|
|
|
|
2021-02-01 16:55:03 +00:00
|
|
|
# Cleanup unwanted files
|
2021-02-09 13:12:19 +00:00
|
|
|
RUN rm -rf /pgadmin4/docs/en_US/_build/html/.doctrees
|
2021-02-01 16:55:03 +00:00
|
|
|
RUN rm -rf /pgadmin4/docs/en_US/_build/html/_sources
|
|
|
|
|
RUN rm -rf /pgadmin4/docs/en_US/_build/html/_static/*.png
|
|
|
|
|
|
2019-09-16 13:48:11 +01:00
|
|
|
#########################################################################
|
|
|
|
|
# Create additional builders to get all of the PostgreSQL utilities
|
|
|
|
|
#########################################################################
|
|
|
|
|
|
2023-06-09 15:28:46 +05:30
|
|
|
FROM postgres:13-alpine AS pg13-builder
|
|
|
|
|
FROM postgres:14-alpine AS pg14-builder
|
|
|
|
|
FROM postgres:15-alpine AS pg15-builder
|
2023-09-21 11:05:44 +01:00
|
|
|
FROM postgres:16-alpine AS pg16-builder
|
2024-10-10 15:55:43 +05:30
|
|
|
FROM postgres:17-alpine AS pg17-builder
|
2025-09-29 13:40:03 +05:30
|
|
|
FROM postgres:18-alpine AS pg18-builder
|
2019-09-16 13:48:11 +01:00
|
|
|
|
2023-06-09 15:28:46 +05:30
|
|
|
FROM alpine:latest AS tool-builder
|
2019-09-16 13:48:11 +01:00
|
|
|
|
|
|
|
|
# Copy the PG binaries
|
2021-01-20 13:17:21 +00:00
|
|
|
COPY --from=pg13-builder /usr/local/bin/pg_dump /usr/local/pgsql/pgsql-13/
|
|
|
|
|
COPY --from=pg13-builder /usr/local/bin/pg_dumpall /usr/local/pgsql/pgsql-13/
|
|
|
|
|
COPY --from=pg13-builder /usr/local/bin/pg_restore /usr/local/pgsql/pgsql-13/
|
|
|
|
|
COPY --from=pg13-builder /usr/local/bin/psql /usr/local/pgsql/pgsql-13/
|
|
|
|
|
|
2021-10-04 16:12:45 +05:30
|
|
|
COPY --from=pg14-builder /usr/local/bin/pg_dump /usr/local/pgsql/pgsql-14/
|
|
|
|
|
COPY --from=pg14-builder /usr/local/bin/pg_dumpall /usr/local/pgsql/pgsql-14/
|
|
|
|
|
COPY --from=pg14-builder /usr/local/bin/pg_restore /usr/local/pgsql/pgsql-14/
|
|
|
|
|
COPY --from=pg14-builder /usr/local/bin/psql /usr/local/pgsql/pgsql-14/
|
2021-10-05 12:45:55 +01:00
|
|
|
|
2022-10-17 10:02:45 +01:00
|
|
|
COPY --from=pg15-builder /usr/local/bin/pg_dump /usr/local/pgsql/pgsql-15/
|
|
|
|
|
COPY --from=pg15-builder /usr/local/bin/pg_dumpall /usr/local/pgsql/pgsql-15/
|
|
|
|
|
COPY --from=pg15-builder /usr/local/bin/pg_restore /usr/local/pgsql/pgsql-15/
|
|
|
|
|
COPY --from=pg15-builder /usr/local/bin/psql /usr/local/pgsql/pgsql-15/
|
|
|
|
|
|
2023-09-21 11:05:44 +01:00
|
|
|
COPY --from=pg16-builder /usr/local/bin/pg_dump /usr/local/pgsql/pgsql-16/
|
|
|
|
|
COPY --from=pg16-builder /usr/local/bin/pg_dumpall /usr/local/pgsql/pgsql-16/
|
|
|
|
|
COPY --from=pg16-builder /usr/local/bin/pg_restore /usr/local/pgsql/pgsql-16/
|
|
|
|
|
COPY --from=pg16-builder /usr/local/bin/psql /usr/local/pgsql/pgsql-16/
|
|
|
|
|
|
2024-10-10 15:55:43 +05:30
|
|
|
COPY --from=pg17-builder /usr/local/bin/pg_dump /usr/local/pgsql/pgsql-17/
|
|
|
|
|
COPY --from=pg17-builder /usr/local/bin/pg_dumpall /usr/local/pgsql/pgsql-17/
|
|
|
|
|
COPY --from=pg17-builder /usr/local/bin/pg_restore /usr/local/pgsql/pgsql-17/
|
|
|
|
|
COPY --from=pg17-builder /usr/local/bin/psql /usr/local/pgsql/pgsql-17/
|
|
|
|
|
|
2025-09-29 13:40:03 +05:30
|
|
|
COPY --from=pg18-builder /usr/local/bin/pg_dump /usr/local/pgsql/pgsql-18/
|
|
|
|
|
COPY --from=pg18-builder /usr/local/bin/pg_dumpall /usr/local/pgsql/pgsql-18/
|
|
|
|
|
COPY --from=pg18-builder /usr/local/bin/pg_restore /usr/local/pgsql/pgsql-18/
|
|
|
|
|
COPY --from=pg18-builder /usr/local/bin/psql /usr/local/pgsql/pgsql-18/
|
|
|
|
|
|
2019-09-16 13:48:11 +01:00
|
|
|
#########################################################################
|
|
|
|
|
# Assemble everything into the final container.
|
|
|
|
|
#########################################################################
|
|
|
|
|
|
2025-11-19 09:29:27 +04:00
|
|
|
FROM python:3-alpine
|
2021-02-09 13:12:19 +00:00
|
|
|
|
2025-11-26 12:50:06 +04:00
|
|
|
# Install runtime dependencies
|
|
|
|
|
RUN apk update && apk upgrade && \
|
|
|
|
|
apk add \
|
|
|
|
|
bash \
|
|
|
|
|
postfix \
|
|
|
|
|
krb5-libs \
|
2026-05-20 00:09:42 -07:00
|
|
|
libcurl \
|
2025-11-26 12:50:06 +04:00
|
|
|
libjpeg-turbo \
|
|
|
|
|
shadow \
|
|
|
|
|
sudo \
|
|
|
|
|
tzdata \
|
|
|
|
|
libedit \
|
|
|
|
|
libldap \
|
2026-04-13 14:34:18 +05:30
|
|
|
libcap \
|
|
|
|
|
su-exec && \
|
2025-11-26 12:50:06 +04:00
|
|
|
rm -rf /var/cache/apk/*
|
|
|
|
|
|
2021-02-09 13:12:19 +00:00
|
|
|
# Copy in the Python packages
|
|
|
|
|
COPY --from=env-builder /venv /venv
|
2019-09-16 13:48:11 +01:00
|
|
|
|
2021-02-09 13:12:19 +00:00
|
|
|
# Copy in the tools
|
2019-09-16 13:48:11 +01:00
|
|
|
COPY --from=tool-builder /usr/local/pgsql /usr/local/
|
2026-05-20 00:09:42 -07:00
|
|
|
COPY --from=pg18-builder /usr/local/lib/libpq.so.5.18 /usr/local/lib/libpq-oauth-18.so /usr/lib/liblz4.so.1.10.0 /usr/lib/
|
2023-09-27 17:09:49 +05:30
|
|
|
|
2025-09-29 13:40:03 +05:30
|
|
|
RUN ln -s libpq.so.5.18 /usr/lib/libpq.so.5 && \
|
|
|
|
|
ln -s libpq.so.5.18 /usr/lib/libpq.so && \
|
2024-12-16 14:58:47 +05:30
|
|
|
ln -s liblz4.so.1.10.0 /usr/lib/liblz4.so.1
|
2019-09-16 13:48:11 +01:00
|
|
|
|
|
|
|
|
WORKDIR /pgadmin4
|
|
|
|
|
ENV PYTHONPATH=/pgadmin4
|
|
|
|
|
|
|
|
|
|
# Copy in the code and docs
|
|
|
|
|
COPY --from=app-builder /pgadmin4/web /pgadmin4
|
|
|
|
|
COPY --from=docs-builder /pgadmin4/docs/en_US/_build/html/ /pgadmin4/docs
|
2025-11-26 12:50:06 +04:00
|
|
|
COPY pkg/docker/run_pgadmin.py pkg/docker/gunicorn_config.py /pgadmin4/
|
2021-02-09 13:12:19 +00:00
|
|
|
COPY pkg/docker/entrypoint.sh /entrypoint.sh
|
2019-09-16 13:48:11 +01:00
|
|
|
|
2020-07-17 17:06:16 +01:00
|
|
|
# License files
|
|
|
|
|
COPY LICENSE /pgadmin4/LICENSE
|
|
|
|
|
|
2025-11-26 12:50:06 +04:00
|
|
|
# Configure everything in one RUN step
|
|
|
|
|
RUN /venv/bin/python3 -m pip install --no-cache-dir gunicorn==23.0.0 && \
|
2021-02-09 13:12:19 +00:00
|
|
|
find / -type d -name '__pycache__' -exec rm -rf {} + && \
|
2022-03-21 11:19:33 +00:00
|
|
|
useradd -r -u 5050 -g root -s /sbin/nologin pgadmin && \
|
2024-03-26 13:52:29 +01:00
|
|
|
mkdir -p /run/pgadmin /var/lib/pgadmin && \
|
|
|
|
|
chown pgadmin:root /run/pgadmin /var/lib/pgadmin && \
|
2026-04-13 14:34:18 +05:30
|
|
|
chmod g=u /run/pgadmin /var/lib/pgadmin && \
|
2019-12-09 11:09:46 +05:30
|
|
|
touch /pgadmin4/config_distro.py && \
|
2022-03-21 11:19:33 +00:00
|
|
|
chown pgadmin:root /pgadmin4/config_distro.py && \
|
|
|
|
|
chmod g=u /pgadmin4/config_distro.py && \
|
|
|
|
|
chmod g=u /etc/passwd && \
|
2026-05-28 19:31:55 +05:30
|
|
|
PYBIN="$(ls /usr/local/bin/python3.[0-9][0-9] 2>/dev/null | head -n1)" && \
|
|
|
|
|
cp "$PYBIN" /usr/local/bin/python3-cap && \
|
|
|
|
|
setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/python3-cap && \
|
|
|
|
|
ln -s /usr/local/bin/python3-cap /venv/bin/python3-cap && \
|
2022-03-21 11:19:33 +00:00
|
|
|
echo "pgadmin ALL = NOPASSWD: /usr/sbin/postfix start" > /etc/sudoers.d/postfix && \
|
|
|
|
|
echo "pgadminr ALL = NOPASSWD: /usr/sbin/postfix start" >> /etc/sudoers.d/postfix
|
2021-02-09 13:12:19 +00:00
|
|
|
|
2026-03-02 18:05:26 +05:30
|
|
|
USER 5050
|
|
|
|
|
|
2019-09-16 13:48:11 +01:00
|
|
|
# Finish up
|
|
|
|
|
VOLUME /var/lib/pgadmin
|
|
|
|
|
EXPOSE 80 443
|
|
|
|
|
|
|
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|