mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-08 07:03:02 -06:00
Optimise the Docker file to minimise the number of layers and maximise the chances that changes will be in the last layers built.
This commit is contained in:
parent
f552519ed6
commit
d8f9e3e87b
@ -22,13 +22,12 @@ RUN yarn install --cache-folder ./ycache --verbose && \
|
||||
FROM python:3.7-alpine3.9 as docs-builder
|
||||
|
||||
# Install only dependencies absolutely required for documentation building
|
||||
RUN apk add --no-cache make
|
||||
RUN pip install --no-cache-dir \
|
||||
sphinx flask_security flask_paranoid python-dateutil flask_sqlalchemy \
|
||||
flask_gravatar flask_migrate simplejson
|
||||
RUN apk add --no-cache make && \
|
||||
pip install --no-cache-dir sphinx flask_security flask_paranoid python-dateutil flask_sqlalchemy flask_gravatar flask_migrate simplejson
|
||||
|
||||
COPY ./pgadmin4/ /pgadmin4
|
||||
|
||||
# Build the docs
|
||||
RUN LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 make -C /pgadmin4/docs/en_US -f Makefile.sphinx html
|
||||
|
||||
# Get the PG binaries
|
||||
@ -41,37 +40,6 @@ FROM postgres:11-alpine as pg11-builder
|
||||
# Then install backend, copy static files and set up entrypoint
|
||||
FROM python:3.7-alpine3.9
|
||||
|
||||
RUN pip --no-cache-dir install gunicorn
|
||||
RUN apk add --no-cache postfix postgresql-client postgresql-libs
|
||||
|
||||
WORKDIR /pgadmin4
|
||||
ENV PYTHONPATH=/pgadmin4
|
||||
|
||||
# Install build-dependencies, build & install C extensions and purge deps in one RUN step
|
||||
# so that deps do not increase the size of resulting image by remaining in layers
|
||||
# NOTE: We're using PIP version 18.1 here because of this issue:
|
||||
# https://github.com/pypa/pip/issues/6197
|
||||
COPY ./pgadmin4/requirements.txt /pgadmin4
|
||||
RUN set -ex && \
|
||||
apk add --no-cache --virtual build-deps build-base postgresql-dev libffi-dev linux-headers && \
|
||||
pip install --upgrade pip==18.1 && \
|
||||
pip install --no-cache-dir -r requirements.txt && \
|
||||
apk del --no-cache build-deps
|
||||
|
||||
COPY --from=node-builder /pgadmin4/web/pgadmin/static/js/generated/ /pgadmin4/pgadmin/static/js/generated/
|
||||
COPY --from=docs-builder /pgadmin4/docs/en_US/_build/html/ /pgadmin4/docs/
|
||||
|
||||
COPY ./pgadmin4/web /pgadmin4
|
||||
COPY ./run_pgadmin.py /pgadmin4
|
||||
COPY ./config_distro.py /pgadmin4
|
||||
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Precompile and optimize python code to save time and space on startup
|
||||
RUN python -O -m compileall /pgadmin4
|
||||
|
||||
COPY ./entrypoint.sh /entrypoint.sh
|
||||
|
||||
# Copy the PG binaries
|
||||
COPY --from=pg94-builder /usr/local/bin/pg_dump /usr/local/pgsql-9.4/
|
||||
COPY --from=pg94-builder /usr/local/bin/pg_dumpall /usr/local/pgsql-9.4/
|
||||
@ -98,6 +66,32 @@ COPY --from=pg11-builder /usr/local/bin/pg_dumpall /usr/local/pgsql-11/
|
||||
COPY --from=pg11-builder /usr/local/bin/pg_restore /usr/local/pgsql-11/
|
||||
COPY --from=pg11-builder /usr/local/bin/psql /usr/local/pgsql-11/
|
||||
|
||||
WORKDIR /pgadmin4
|
||||
ENV PYTHONPATH=/pgadmin4
|
||||
|
||||
#Copy in the docs and JS/CSS bundles
|
||||
COPY --from=node-builder /pgadmin4/web/pgadmin/static/js/generated/ /pgadmin4/pgadmin/static/js/generated/
|
||||
COPY --from=docs-builder /pgadmin4/docs/en_US/_build/html/ /pgadmin4/docs/
|
||||
|
||||
# Install build-dependencies, build & install C extensions and purge deps in one RUN step
|
||||
# so that deps do not increase the size of resulting image by remaining in layers
|
||||
COPY ./pgadmin4/requirements.txt /pgadmin4
|
||||
RUN apk add --no-cache --virtual build-deps build-base postgresql-dev libffi-dev linux-headers && \
|
||||
apk add postfix postgresql-client postgresql-libs && \
|
||||
pip install --upgrade pip && \
|
||||
pip install --no-cache-dir -r requirements.txt && \
|
||||
pip install --no-cache-dir gunicorn && \
|
||||
apk del --no-cache build-deps
|
||||
|
||||
# Copy the code
|
||||
COPY ./pgadmin4/web /pgadmin4
|
||||
COPY ./run_pgadmin.py /pgadmin4
|
||||
COPY ./config_distro.py /pgadmin4
|
||||
COPY ./entrypoint.sh /entrypoint.sh
|
||||
|
||||
# Precompile and optimize python code to save time and space on startup
|
||||
RUN python -O -m compileall /pgadmin4
|
||||
|
||||
# Finish up
|
||||
VOLUME /var/lib/pgadmin
|
||||
EXPOSE 80 443
|
||||
|
Loading…
Reference in New Issue
Block a user