2022-03-14 05:53:03 +00:00
|
|
|
# syntax=docker/dockerfile:1.3
|
|
|
|
|
|
|
|
ARG PYTHON_VERSION
|
|
|
|
FROM python:${PYTHON_VERSION}-slim-bullseye as base
|
|
|
|
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install --no-install-recommends -y \
|
|
|
|
# Postgres
|
|
|
|
libpq-dev \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
RUN useradd -ms /bin/bash frappe
|
|
|
|
USER frappe
|
|
|
|
RUN mkdir -p /home/frappe/frappe-bench/apps /home/frappe/frappe-bench/logs /home/frappe/frappe-bench/sites
|
|
|
|
WORKDIR /home/frappe/frappe-bench
|
|
|
|
|
2022-03-23 08:43:47 +00:00
|
|
|
USER root
|
|
|
|
RUN pip install -U pip wheel \
|
2022-03-14 05:53:03 +00:00
|
|
|
&& python -m venv env \
|
|
|
|
&& env/bin/pip install -U pip wheel
|
|
|
|
|
2022-03-24 07:38:45 +00:00
|
|
|
COPY install-app.sh /usr/local/bin/install-app
|
|
|
|
|
2022-03-14 05:53:03 +00:00
|
|
|
|
|
|
|
FROM base as build_deps
|
|
|
|
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install --no-install-recommends -y \
|
|
|
|
# Install git here because it is not required in production
|
|
|
|
git \
|
|
|
|
# gcc and g++ are required for building different packages across different versions
|
|
|
|
# of Frappe and ERPNext and also on different platforms (for example, linux/arm64).
|
|
|
|
# It is safe to install build deps even if they are not required
|
|
|
|
# because they won't be included in final images.
|
|
|
|
gcc \
|
|
|
|
g++ \
|
|
|
|
# Make is required to build wheels of ERPNext deps in develop branch for linux/arm64
|
|
|
|
make \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
|
|
FROM build_deps as frappe_builder
|
|
|
|
|
|
|
|
ARG FRAPPE_VERSION
|
2022-04-11 05:00:16 +00:00
|
|
|
ARG FRAPPE_REPO=https://github.com/frappe/frappe
|
2022-03-23 08:43:47 +00:00
|
|
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
2022-04-11 05:00:16 +00:00
|
|
|
git clone --depth 1 -b ${FRAPPE_VERSION} ${FRAPPE_REPO} apps/frappe \
|
2022-03-30 09:09:09 +00:00
|
|
|
&& install-app frappe \
|
2022-03-14 05:53:03 +00:00
|
|
|
&& env/bin/pip install -U gevent \
|
2022-03-16 10:39:16 +00:00
|
|
|
# Link Frappe's node_modules/ to make Website Theme work
|
|
|
|
&& mkdir -p /home/frappe/frappe-bench/sites/assets/frappe/node_modules \
|
|
|
|
&& ln -s /home/frappe/frappe-bench/sites/assets/frappe/node_modules /home/frappe/frappe-bench/apps/frappe/node_modules
|
2022-03-14 05:53:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
FROM frappe_builder as erpnext_builder
|
|
|
|
|
2022-03-23 08:43:47 +00:00
|
|
|
ARG ERPNEXT_VERSION
|
2022-04-11 05:00:16 +00:00
|
|
|
ARG ERPNEXT_REPO=https://github.com/frappe/erpnext
|
2022-03-23 08:43:47 +00:00
|
|
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
2022-04-11 05:00:16 +00:00
|
|
|
git clone --depth 1 -b ${ERPNEXT_VERSION} ${ERPNEXT_REPO} apps/erpnext \
|
2022-03-30 09:09:09 +00:00
|
|
|
&& install-app erpnext
|
2022-03-14 05:53:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
FROM base as configured_base
|
|
|
|
|
2022-03-18 10:50:39 +00:00
|
|
|
ARG WKHTMLTOPDF_VERSION=0.12.6-1
|
|
|
|
|
2022-03-14 05:53:03 +00:00
|
|
|
RUN apt-get update \
|
2022-03-18 10:50:39 +00:00
|
|
|
# Setup Node lists
|
2022-03-14 05:53:03 +00:00
|
|
|
&& apt-get install --no-install-recommends -y curl \
|
|
|
|
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
|
2022-03-18 10:50:39 +00:00
|
|
|
# Install wkhtmltopdf with patched qt
|
|
|
|
&& if [ "$(uname -m)" = "aarch64" ]; then export ARCH=arm64; fi \
|
|
|
|
&& if [ "$(uname -m)" = "x86_64" ]; then export ARCH=amd64; fi \
|
|
|
|
&& downloaded_file=wkhtmltox_$WKHTMLTOPDF_VERSION.buster_${ARCH}.deb \
|
|
|
|
&& curl -sLO https://github.com/wkhtmltopdf/packaging/releases/download/$WKHTMLTOPDF_VERSION/$downloaded_file \
|
|
|
|
&& apt-get install -y ./$downloaded_file \
|
|
|
|
&& rm $downloaded_file \
|
|
|
|
# Cleanup
|
2022-03-14 05:53:03 +00:00
|
|
|
&& apt-get purge -y --auto-remove curl \
|
|
|
|
&& apt-get update \
|
|
|
|
&& apt-get install --no-install-recommends -y \
|
|
|
|
# MariaDB
|
|
|
|
mariadb-client \
|
|
|
|
# Postgres
|
|
|
|
postgresql-client \
|
|
|
|
# For healthcheck
|
|
|
|
wait-for-it \
|
|
|
|
jq \
|
|
|
|
# other
|
|
|
|
nodejs \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2022-03-18 10:50:39 +00:00
|
|
|
|
2022-03-14 05:53:03 +00:00
|
|
|
COPY pretend-bench.sh /usr/local/bin/bench
|
|
|
|
COPY push_backup.py /usr/local/bin/push-backup
|
|
|
|
COPY configure.py patched_bench_helper.py /usr/local/bin/
|
|
|
|
COPY gevent_patch.py /opt/patches/
|
|
|
|
|
|
|
|
WORKDIR /home/frappe/frappe-bench/sites
|
|
|
|
|
2022-04-03 12:45:39 +00:00
|
|
|
CMD [ "/home/frappe/frappe-bench/env/bin/gunicorn", \
|
|
|
|
"--bind=0.0.0.0:8000", \
|
|
|
|
"--threads=4", \
|
|
|
|
"--workers=2", \
|
|
|
|
"--worker-class=gthread", \
|
|
|
|
"--worker-tmp-dir=/dev/shm", \
|
|
|
|
"--timeout=120", \
|
|
|
|
"--preload", \
|
|
|
|
"frappe.app:application" \
|
|
|
|
]
|
2022-03-14 05:53:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
FROM configured_base as frappe
|
|
|
|
|
|
|
|
COPY --from=frappe_builder /home/frappe/frappe-bench/apps/frappe /home/frappe/frappe-bench/apps/frappe
|
|
|
|
COPY --from=frappe_builder /home/frappe/frappe-bench/env /home/frappe/frappe-bench/env
|
2022-03-23 08:43:47 +00:00
|
|
|
COPY --from=frappe_builder /home/frappe/frappe-bench/sites/apps.txt /home/frappe/frappe-bench/sites/
|
|
|
|
|
|
|
|
USER frappe
|
2022-03-14 05:53:03 +00:00
|
|
|
|
|
|
|
|
2022-03-23 08:43:47 +00:00
|
|
|
# Split frappe and erpnext to reduce image size (because of frappe-bench/env/ directory)
|
2022-03-14 05:53:03 +00:00
|
|
|
FROM configured_base as erpnext
|
|
|
|
|
|
|
|
COPY --from=frappe_builder /home/frappe/frappe-bench/apps/frappe /home/frappe/frappe-bench/apps/frappe
|
|
|
|
COPY --from=erpnext_builder /home/frappe/frappe-bench/apps/erpnext /home/frappe/frappe-bench/apps/erpnext
|
|
|
|
COPY --from=erpnext_builder /home/frappe/frappe-bench/env /home/frappe/frappe-bench/env
|
2022-03-23 08:43:47 +00:00
|
|
|
COPY --from=erpnext_builder /home/frappe/frappe-bench/sites/apps.txt /home/frappe/frappe-bench/sites/
|
|
|
|
|
|
|
|
USER frappe
|