zendx
1
Hi!
I am using the default setup described in the frappe_docker
repository.
I would like to add a custom app to Frappe to modify ERPNext behavior (yes, I am aware of server scripts/client scripts).
I am trying to add my custom app by connecting to the frappe_docker-backend-1
container and running:
bench new-app mycrm
bench install-app mycrm
However, despite all containers using the same image, the scheduler, queue-long, and queue-short stop working, showing the error:
scheduler-1 | ModuleNotFoundError: No module named 'mycrm'
Restarting all containers does not resolve the issue.
What is the correct way to install a custom app when deploying ERPNext with Docker?
Do not develop apps in production container, if you want to create a development container follow these steps
Create the following
frappe-docker/
├── docker-compose.yml
└── script/
└── init.sh
In docker-compose.yml
# docker-compose.yml
services:
mariadb:
image: mariadb:10.6
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --skip-character-set-client-handshake
- --skip-innodb-read-only-compressed
environment:
MYSQL_ROOT_PASSWORD: 123
MYSQL_ROOT_HOST: '%'
volumes:
- mariadb-data:/var/lib/mysql
ports:
- "3307:3306"
redis-cache:
image: redis:alpine
ports:
- "13000:6379"
redis-queue:
image: redis:alpine
ports:
- "11000:6379"
redis-socketio:
image: redis:alpine
ports:
- "12000:6379"
frappe:
image: frappe/bench:latest
command: sleep infinity
user: "1000:1000"
environment:
- SHELL=/bin/bash
- CHOKIDAR_USEPOLLING=true
volumes:
- ./scripts:/workspace/scripts
- ./frappe-bench:/workspace/frappe-bench
working_dir: /workspace
ports:
- "8000-8005:8000-8005"
- "8080:8080"
- "9000-9005:9000-9005"
depends_on:
- mariadb
- redis-cache
- redis-queue
- redis-socketio
volumes:
mariadb-data:
In init.sh
#!/bin/bash
set -e
# Setup NodeJS
source /home/frappe/.nvm/nvm.sh
nvm alias default 18
nvm use 18
echo "nvm use 18" >> ~/.bashrc
# Wait for MariaDB to be ready
echo "Waiting for MariaDB to be ready..."
until mysql -h mariadb -u root -p123 -e "SELECT 1" >/dev/null 2>&1
do
echo "MariaDB is unavailable - sleeping"
sleep 1
done
echo "MariaDB is up - proceeding with setup"
# Initialize Frappe Bench
cd /workspace
sudo chown -R frappe:frappe frappe-bench
bench init \
--ignore-exist \
--skip-redis-config-generation \
frappe-bench
cd frappe-bench
# Configure Redis and MariaDB hosts
bench set-mariadb-host mariadb
bench set-redis-cache-host redis-cache:6379
bench set-redis-queue-host redis-queue:6379
bench set-redis-socketio-host redis-socketio:6379
# Remove redis from Procfile
sed -i '/redis/d' ./Procfile
# Create new site
echo "Creating new site..."
bench new-site dev.localhost \
--mariadb-root-password 123 \
--admin-password admin \
--db-root-username root \
--no-mariadb-socket
bench --site dev.localhost set-config developer_mode 1
bench --site dev.localhost clear-cache
bench use dev.localhost
echo "Setup complete! You can now start developing with Frappe."
Then start the containers
docker-compose up -d
Then run the init script
docker-compose exec frappe bash /workspace/scripts/init.sh
Access frappe container and start bench
docker-compose exec frappe bash
bench start
Then you can safely create and install your custom app in the premade site dev.localhost
Login:
Administrator
admin
If you are on Windows make sure you are using docker with WSL2 otherwise fix the line endings in the init scriot