2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-11-10 15:20:55 +00:00
frappe_docker/build/worker/Dockerfile

116 lines
3.8 KiB
Docker
Raw Normal View History

2021-12-15 07:32:10 +00:00
# syntax=docker/dockerfile:1.3
2021-12-13 16:24:15 +00:00
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/*
2020-02-10 08:00:54 +00:00
2021-01-08 12:15:22 +00:00
RUN useradd -ms /bin/bash frappe
2021-12-13 16:24:15 +00:00
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
2020-06-27 18:14:13 +00:00
2021-12-13 16:24:15 +00:00
RUN pip install --no-cache-dir -U pip wheel \
&& python -m venv env \
&& env/bin/pip install --no-cache-dir -U pip wheel
2021-12-15 07:32:10 +00:00
USER root
2020-06-27 18:14:13 +00:00
2021-12-15 07:32:10 +00:00
FROM base as build_deps
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
2021-12-13 16:24:15 +00:00
# Install git here because it is not required in production
2020-02-10 08:00:54 +00:00
git \
2021-12-13 16:24:15 +00:00
# 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.
2021-01-08 12:15:22 +00:00
gcc \
2021-12-13 16:24:15 +00:00
g++ \
2021-08-10 16:03:08 +00:00
&& rm -rf /var/lib/apt/lists/*
2021-12-15 07:32:10 +00:00
2021-12-13 16:24:15 +00:00
USER frappe
2020-08-05 16:10:37 +00:00
2021-12-15 07:32:10 +00:00
FROM build_deps as frappe_builder
2021-12-13 16:24:15 +00:00
ARG FRAPPE_VERSION
RUN git clone --depth 1 -b ${FRAPPE_VERSION} https://github.com/frappe/frappe apps/frappe \
&& env/bin/pip install --no-cache-dir -e apps/frappe \
&& rm -r apps/frappe/.git
2021-02-20 10:54:01 +00:00
2021-11-18 11:58:25 +00:00
2021-12-15 07:32:10 +00:00
# We split ERPNext wheels build in separate stage to achieve concurrency with Frappe build
FROM build_deps as erpnext_wheels
2020-02-10 08:00:54 +00:00
2021-12-13 16:24:15 +00:00
ARG ERPNEXT_VERSION
RUN git clone --depth 1 -b ${ERPNEXT_VERSION} https://github.com/frappe/erpnext apps/erpnext \
&& rm -r apps/erpnext/.git
2021-12-15 07:32:10 +00:00
RUN pip wheel --wheel-dir /home/frappe/erpnext-wheels -r apps/erpnext/requirements.txt
FROM frappe_builder as erpnext_builder
COPY --from=erpnext_wheels --chown=frappe /home/frappe/frappe-bench/apps/erpnext /home/frappe/frappe-bench/apps/erpnext
RUN --mount=type=bind,target=/home/frappe/erpnext-wheels,source=/home/frappe/erpnext-wheels,from=erpnext_wheels \
--mount=type=cache,target=/home/frappe/.cache/pip,source=/home/frappe/.cache/pip,from=erpnext_wheels \
env/bin/pip install --find-links=/home/frappe/erpnext-wheels --no-cache-dir -e apps/erpnext
2021-12-13 16:24:15 +00:00
FROM base as configured_base
2020-02-10 08:00:54 +00:00
2021-12-15 07:32:10 +00:00
RUN apt-get update \
2021-12-15 08:50:46 +00:00
&& apt-get install --no-install-recommends -y curl \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get purge -y --auto-remove curl \
&& apt-get update \
2021-12-15 07:32:10 +00:00
&& apt-get install --no-install-recommends -y \
# MariaDB
mariadb-client \
# Postgres
postgresql-client \
# wkhtmltopdf
xvfb \
libfontconfig \
wkhtmltopdf \
# For healthcheck.sh in helm chart
wait-for-it \
2021-12-15 08:50:46 +00:00
# other
nodejs \
2021-12-15 07:32:10 +00:00
&& rm -rf /var/lib/apt/lists/*
USER frappe
2021-12-13 16:24:15 +00:00
COPY pretend-bench.sh /usr/local/bin/bench
2021-12-15 05:30:00 +00:00
COPY push_backup.py /usr/local/bin/push-backup
2021-12-13 16:24:15 +00:00
# healthcheck.sh used in helm chart
COPY configure.py patched_bench_helper.py healthcheck.sh /usr/local/bin/
2020-02-10 08:00:54 +00:00
WORKDIR /home/frappe/frappe-bench/sites
# TODO: Do volumes are being overwritten after copying from other stages?
VOLUME [ "/home/frappe/frappe-bench/sites" ]
2021-12-13 16:24:15 +00:00
CMD [ "/home/frappe/frappe-bench/env/bin/gunicorn", "-b", "0.0.0.0:8000", "frappe.app:application", "--access-logfile", "-" ]
FROM configured_base as frappe
RUN echo "frappe" >/home/frappe/frappe-bench/sites/apps.txt
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
FROM configured_base as erpnext
2021-12-13 16:24:15 +00:00
RUN echo "frappe\nerpnext" >/home/frappe/frappe-bench/sites/apps.txt
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