frappe_docker/dokploy/Dockerfile
ubden 6485b93da7 fix: Keep node_modules for runtime dependencies and add troubleshooting guide
Critical fix:
- Dockerfile: Do not delete node_modules folders (socket.io needed at runtime)
- Only remove .git folders and Python cache
- Preserve all npm packages for WebSocket functionality

New documentation:
- dokploy/TROUBLESHOOTING.md: Common issues and solutions
  * WebSocket host not found
  * socket.io module not found
  * Frontend restart loop
  * Site not found errors

This fixes:
- Frontend restart loop
- WebSocket container crashes
- socket.io MODULE_NOT_FOUND errors

WebSocket requires socket.io, redis, socket.io-redis packages at runtime.
These must NOT be deleted in Dockerfile cleanup.
2025-10-14 09:12:51 +03:00

186 lines
6.1 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

ARG PYTHON_VERSION=3.11.6
ARG DEBIAN_BASE=bookworm
FROM python:${PYTHON_VERSION}-slim-${DEBIAN_BASE} AS base
ARG WKHTMLTOPDF_VERSION=0.12.6.1-3
ARG WKHTMLTOPDF_DISTRO=bookworm
ARG NODE_VERSION=20.19.2
ENV NVM_DIR=/home/frappe/.nvm
ENV PATH=${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH}
RUN useradd -ms /bin/bash frappe \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
curl \
git \
vim \
nginx \
gettext-base \
file \
# weasyprint dependencies
libpango-1.0-0 \
libharfbuzz0b \
libpangoft2-1.0-0 \
libpangocairo-1.0-0 \
# For backups
restic \
gpg \
# MariaDB
mariadb-client \
less \
# Postgres
libpq-dev \
postgresql-client \
# For healthcheck
wait-for-it \
jq \
# NodeJS
&& mkdir -p ${NVM_DIR} \
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
&& . ${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 \
&& downloaded_file=wkhtmltox_${WKHTMLTOPDF_VERSION}.${WKHTMLTOPDF_DISTRO}_${ARCH}.deb \
&& 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 \
&& chown -R frappe:frappe /run/nginx.pid
COPY resources/nginx-template.conf /templates/nginx/frappe.conf.template
COPY resources/nginx-entrypoint.sh /usr/local/bin/nginx-entrypoint.sh
FROM base AS build
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
# For frappe framework
wget \
# For psycopg2
libpq-dev \
# Other
libffi-dev \
liblcms2-dev \
libldap2-dev \
libmariadb-dev \
libsasl2-dev \
libtiff5-dev \
libwebp-dev \
pkg-config \
redis-tools \
rlwrap \
tk8.6-dev \
cron \
# For pandas
gcc \
build-essential \
libbz2-dev \
&& rm -rf /var/lib/apt/lists/*
USER frappe
FROM build AS builder
ARG FRAPPE_BRANCH=version-15
ARG FRAPPE_PATH=https://github.com/frappe/frappe
# Frappe framework kurulumu
RUN bench init \
--frappe-branch=${FRAPPE_BRANCH} \
--frappe-path=${FRAPPE_PATH} \
--no-procfile \
--no-backups \
--skip-redis-config-generation \
--verbose \
/home/frappe/frappe-bench
WORKDIR /home/frappe/frappe-bench
# Tüm uygulamaları yükle
# Build context root'tan kopyala (dokploy klasörü altından)
COPY dokploy/apps.json /tmp/apps.json
# Install essential apps only
RUN cd /home/frappe/frappe-bench && \
# ERPNext - version-15 (ERP Core)
bench get-app --branch=version-15 --resolve-deps erpnext https://github.com/frappe/erpnext && \
find apps/erpnext -name "*.pyc" -delete && \
find apps/erpnext -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
RUN cd /home/frappe/frappe-bench && \
# CRM - main (Customer Relations)
bench get-app --branch=main crm https://github.com/frappe/crm && \
find apps/crm -name "*.pyc" -delete && \
find apps/crm -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
RUN cd /home/frappe/frappe-bench && \
# Helpdesk - v1.14.0 (Customer Support)
bench get-app --branch=v1.14.0 helpdesk https://github.com/frappe/helpdesk && \
find apps/helpdesk -name "*.pyc" -delete && \
find apps/helpdesk -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
RUN cd /home/frappe/frappe-bench && \
# Payments - main (Payment Gateways)
bench get-app payments https://github.com/frappe/payments && \
find apps/payments -name "*.pyc" -delete && \
find apps/payments -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true && \
# Final cleanup (keep node_modules for runtime dependencies like socket.io)
echo "{}" > sites/common_site_config.json && \
find apps -mindepth 1 -path "*/.git" -type d -exec rm -rf {} + 2>/dev/null || true && \
find apps -name "*.pyc" -delete && \
find apps -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true && \
find apps -name ".git" -type d -exec rm -rf {} + 2>/dev/null || true
FROM base AS erpnext-complete
USER frappe
RUN echo "echo \"Frappe ERPNext with all apps - Dokploy Ready\"" >> ~/.bashrc
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" \
]
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
CMD bash -c "curl -f http://localhost:8000/api/method/ping || exit 1"
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" \
]