2023-10-20 13:10:10 +00:00
|
|
|
ARG PYTHON_VERSION=3.11.6
|
2023-06-26 06:24:37 +00:00
|
|
|
ARG DEBIAN_BASE=bookworm
|
|
|
|
FROM python:${PYTHON_VERSION}-slim-${DEBIAN_BASE} AS base
|
2023-01-15 22:50:09 +00:00
|
|
|
|
2023-01-20 07:55:21 +00:00
|
|
|
COPY resources/nginx-template.conf /templates/nginx/frappe.conf.template
|
|
|
|
COPY resources/nginx-entrypoint.sh /usr/local/bin/nginx-entrypoint.sh
|
|
|
|
|
2023-06-26 06:24:37 +00:00
|
|
|
ARG WKHTMLTOPDF_VERSION=0.12.6.1-3
|
|
|
|
ARG WKHTMLTOPDF_DISTRO=bookworm
|
2023-10-20 13:10:10 +00:00
|
|
|
ARG NODE_VERSION=18.18.2
|
2023-01-15 22:50:09 +00:00
|
|
|
ENV NVM_DIR=/home/frappe/.nvm
|
2024-07-22 08:15:50 +00:00
|
|
|
ENV PATH=${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH}
|
2023-01-15 22:50:09 +00:00
|
|
|
|
|
|
|
RUN useradd -ms /bin/bash frappe \
|
|
|
|
&& apt-get update \
|
|
|
|
&& apt-get install --no-install-recommends -y \
|
|
|
|
curl \
|
|
|
|
git \
|
|
|
|
vim \
|
|
|
|
nginx \
|
|
|
|
gettext-base \
|
2024-03-22 05:57:00 +00:00
|
|
|
file \
|
2023-01-17 11:42:27 +00:00
|
|
|
# weasyprint dependencies
|
|
|
|
libpango-1.0-0 \
|
|
|
|
libharfbuzz0b \
|
|
|
|
libpangoft2-1.0-0 \
|
|
|
|
libpangocairo-1.0-0 \
|
2023-01-18 06:01:18 +00:00
|
|
|
# For backups
|
|
|
|
restic \
|
2024-01-28 06:23:14 +00:00
|
|
|
gpg \
|
2023-01-15 22:50:09 +00:00
|
|
|
# MariaDB
|
|
|
|
mariadb-client \
|
2024-01-28 06:23:14 +00:00
|
|
|
less \
|
2023-01-15 22:50:09 +00:00
|
|
|
# Postgres
|
|
|
|
libpq-dev \
|
|
|
|
postgresql-client \
|
|
|
|
# For healthcheck
|
|
|
|
wait-for-it \
|
|
|
|
jq \
|
|
|
|
# NodeJS
|
|
|
|
&& mkdir -p ${NVM_DIR} \
|
2023-10-20 13:10:10 +00:00
|
|
|
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
|
2023-01-15 22:50:09 +00:00
|
|
|
&& . ${NVM_DIR}/nvm.sh \
|
|
|
|
&& nvm install ${NODE_VERSION} \
|
|
|
|
&& nvm use v${NODE_VERSION} \
|
|
|
|
&& npm install -g yarn \
|
|
|
|
&& nvm alias default v${NODE_VERSION} \
|
|
|
|
&& rm -rf ${NVM_DIR}/.cache \
|
|
|
|
&& echo 'export NVM_DIR="/home/frappe/.nvm"' >>/home/frappe/.bashrc \
|
|
|
|
&& echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm' >>/home/frappe/.bashrc \
|
|
|
|
&& echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >>/home/frappe/.bashrc \
|
|
|
|
# Install wkhtmltopdf with patched qt
|
|
|
|
&& if [ "$(uname -m)" = "aarch64" ]; then export ARCH=arm64; fi \
|
|
|
|
&& if [ "$(uname -m)" = "x86_64" ]; then export ARCH=amd64; fi \
|
2023-06-26 06:24:37 +00:00
|
|
|
&& downloaded_file=wkhtmltox_${WKHTMLTOPDF_VERSION}.${WKHTMLTOPDF_DISTRO}_${ARCH}.deb \
|
2023-01-15 22:50:09 +00:00
|
|
|
&& curl -sLO https://github.com/wkhtmltopdf/packaging/releases/download/$WKHTMLTOPDF_VERSION/$downloaded_file \
|
|
|
|
&& apt-get install -y ./$downloaded_file \
|
|
|
|
&& rm $downloaded_file \
|
|
|
|
# Clean up
|
|
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
|
|
&& rm -fr /etc/nginx/sites-enabled/default \
|
|
|
|
&& pip3 install frappe-bench \
|
|
|
|
# Fixes for non-root nginx and logs to stdout
|
|
|
|
&& sed -i '/user www-data/d' /etc/nginx/nginx.conf \
|
|
|
|
&& ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log \
|
|
|
|
&& touch /run/nginx.pid \
|
|
|
|
&& chown -R frappe:frappe /etc/nginx/conf.d \
|
|
|
|
&& chown -R frappe:frappe /etc/nginx/nginx.conf \
|
|
|
|
&& chown -R frappe:frappe /var/log/nginx \
|
|
|
|
&& chown -R frappe:frappe /var/lib/nginx \
|
2023-01-20 07:55:21 +00:00
|
|
|
&& chown -R frappe:frappe /run/nginx.pid \
|
2023-01-21 11:18:53 +00:00
|
|
|
&& chmod 755 /usr/local/bin/nginx-entrypoint.sh \
|
|
|
|
&& chmod 644 /templates/nginx/frappe.conf.template
|
2023-01-15 22:50:09 +00:00
|
|
|
|
|
|
|
FROM base AS builder
|
|
|
|
|
|
|
|
RUN apt-get update \
|
|
|
|
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
|
|
|
# For frappe framework
|
|
|
|
wget \
|
2024-04-25 23:16:07 +00:00
|
|
|
#for building arm64 binaries
|
|
|
|
libcairo2-dev \
|
|
|
|
libpango1.0-dev \
|
|
|
|
libjpeg-dev \
|
|
|
|
libgif-dev \
|
|
|
|
librsvg2-dev \
|
2023-01-15 22:50:09 +00:00
|
|
|
# For psycopg2
|
|
|
|
libpq-dev \
|
|
|
|
# Other
|
|
|
|
libffi-dev \
|
|
|
|
liblcms2-dev \
|
|
|
|
libldap2-dev \
|
|
|
|
libmariadb-dev \
|
|
|
|
libsasl2-dev \
|
|
|
|
libtiff5-dev \
|
|
|
|
libwebp-dev \
|
|
|
|
redis-tools \
|
|
|
|
rlwrap \
|
|
|
|
tk8.6-dev \
|
|
|
|
cron \
|
|
|
|
# For pandas
|
|
|
|
gcc \
|
|
|
|
build-essential \
|
|
|
|
libbz2-dev \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
# apps.json includes
|
|
|
|
ARG APPS_JSON_BASE64
|
|
|
|
RUN if [ -n "${APPS_JSON_BASE64}" ]; then \
|
|
|
|
mkdir /opt/frappe && echo "${APPS_JSON_BASE64}" | base64 -d > /opt/frappe/apps.json; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
USER frappe
|
|
|
|
|
2023-10-20 13:10:10 +00:00
|
|
|
ARG FRAPPE_BRANCH=version-15
|
2023-01-15 22:50:09 +00:00
|
|
|
ARG FRAPPE_PATH=https://github.com/frappe/frappe
|
|
|
|
RUN export APP_INSTALL_ARGS="" && \
|
|
|
|
if [ -n "${APPS_JSON_BASE64}" ]; then \
|
|
|
|
export APP_INSTALL_ARGS="--apps_path=/opt/frappe/apps.json"; \
|
|
|
|
fi && \
|
|
|
|
bench init ${APP_INSTALL_ARGS}\
|
|
|
|
--frappe-branch=${FRAPPE_BRANCH} \
|
|
|
|
--frappe-path=${FRAPPE_PATH} \
|
|
|
|
--no-procfile \
|
|
|
|
--no-backups \
|
|
|
|
--skip-redis-config-generation \
|
|
|
|
--verbose \
|
|
|
|
/home/frappe/frappe-bench && \
|
|
|
|
cd /home/frappe/frappe-bench && \
|
2023-03-05 13:18:37 +00:00
|
|
|
echo "{}" > sites/common_site_config.json && \
|
2023-01-18 06:01:18 +00:00
|
|
|
find apps -mindepth 1 -path "*/.git" | xargs rm -fr
|
2023-01-15 22:50:09 +00:00
|
|
|
|
2024-07-03 21:19:10 +00:00
|
|
|
FROM base AS backend
|
2023-01-15 22:50:09 +00:00
|
|
|
|
|
|
|
USER frappe
|
|
|
|
|
|
|
|
COPY --from=builder --chown=frappe:frappe /home/frappe/frappe-bench /home/frappe/frappe-bench
|
|
|
|
|
|
|
|
WORKDIR /home/frappe/frappe-bench
|
|
|
|
|
|
|
|
VOLUME [ \
|
|
|
|
"/home/frappe/frappe-bench/sites", \
|
|
|
|
"/home/frappe/frappe-bench/sites/assets", \
|
|
|
|
"/home/frappe/frappe-bench/logs" \
|
|
|
|
]
|
|
|
|
|
|
|
|
CMD [ \
|
|
|
|
"/home/frappe/frappe-bench/env/bin/gunicorn", \
|
|
|
|
"--chdir=/home/frappe/frappe-bench/sites", \
|
|
|
|
"--bind=0.0.0.0:8000", \
|
|
|
|
"--threads=4", \
|
|
|
|
"--workers=2", \
|
|
|
|
"--worker-class=gthread", \
|
|
|
|
"--worker-tmp-dir=/dev/shm", \
|
|
|
|
"--timeout=120", \
|
|
|
|
"--preload", \
|
|
|
|
"frappe.app:application" \
|
|
|
|
]
|