fix(erpnext): run bench setup production as root, add nginx+supervisor

- bench setup production requires root (is_root check) - was failing as frappe user
- Add nginx and supervisor as apt dependencies for production setup
- Remove custom erpnext.service - bench manages gunicorn+workers via supervisor
- Port 8000 → 80 (nginx reverse proxy)
- Fix bench update in CT to run as frappe user with proper PATH
This commit is contained in:
CanbiZ (MickLesk)
2026-03-25 14:26:04 +01:00
parent 929e78f39b
commit 825a718a07
3 changed files with 7 additions and 25 deletions

View File

@@ -31,8 +31,7 @@ function update_script() {
fi
msg_info "Updating ERPNext"
cd /opt/frappe-bench
$STD bench update --reset
$STD sudo -u frappe bash -c 'export PATH="$HOME/.local/bin:$PATH"; cd /opt/frappe-bench && bench update --reset'
msg_ok "Updated ERPNext"
exit
}
@@ -44,7 +43,7 @@ description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8000${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"
echo -e "${INFO}${YW} Credentials:${CL}"
echo -e "${TAB}${BGN}Username: Administrator${CL}"
echo -e "${TAB}${BGN}Password: see /opt/frappe-bench/.env${CL}"

View File

@@ -22,6 +22,8 @@ $STD apt install -y \
libffi-dev \
libssl-dev \
redis-server \
nginx \
supervisor \
xvfb \
libfontconfig1 \
libxrender1 \
@@ -79,29 +81,10 @@ $STD systemctl enable --now redis-server
msg_ok "Configured ERPNext"
msg_info "Setting up Production"
$STD sudo -u frappe bash -c 'export PATH="$HOME/.local/bin:$PATH"; cd /opt/frappe-bench && bench setup production frappe --yes'
$STD bash -c 'export PATH="/home/frappe/.local/bin:$PATH"; cd /opt/frappe-bench && bench setup production frappe --yes'
$STD systemctl enable --now supervisor
msg_ok "Set up Production"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/erpnext.service
[Unit]
Description=ERPNext (Frappe Bench)
After=network.target mariadb.service redis-server.service
[Service]
Type=simple
User=frappe
WorkingDirectory=/opt/frappe-bench
ExecStart=/opt/frappe-bench/env/bin/gunicorn --bind 0.0.0.0:8000 --workers 4 --timeout 120 frappe.app:application
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now erpnext
msg_ok "Created Service"
motd_ssh
customize
cleanup_lxc

View File

@@ -8,7 +8,7 @@
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 8000,
"interface_port": 80,
"documentation": "https://docs.erpnext.com/",
"website": "https://erpnext.com/",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/erpnext.webp",