Skip to content

Instantly share code, notes, and snippets.

@revant
Last active July 28, 2024 06:24
Show Gist options
  • Save revant/010c058f7c485cc62f2cc4d604ab8511 to your computer and use it in GitHub Desktop.
Save revant/010c058f7c485cc62f2cc4d604ab8511 to your computer and use it in GitHub Desktop.
Frappe Docker development bench in production

Install frappe-bench using docker

Clone frappe_docker

git clone https://github.com/frappe/frappe_docker.git
cd frappe_docker

Install bench using docker

cp -R devcontainer-example bench
docker-compose -f bench/docker-compose.yml up -d

Exec into the container

docker exec -e "TERM=xterm-256color" -w /workspace/development -it bench_frappe_1 bash

Install Frappe Framework and ERPNext

# Install bench for root
supo pip3 install -e /home/frappe/.bench

# Create frappe-bench
bench init --skip-redis-config-generation --frappe-branch version-12 frappe-bench
cd frappe-bench

# Set docker specific 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

# Get ERPNext
bench get-app --branch version-12 erpnext

# Create new site
bench new-site myerp.mysite.com --mariadb-root-password 123 --admin-password admin --no-mariadb-socket

# Install ERPNext on site
bench --site myerp.mysite.com install-app erpnext

# Setup supervisor (includes nginx)
bench setup supervisor --skip-redis

# Symlink or copy supervisor and nginx configs
sudo ln -s `pwd`/config/nginx.conf /etc/nginx/conf.d/frappe.conf
sudo ln -s `pwd`/config/supervisor.conf /etc/supervisor/conf.d/frappe.conf
# Or copy supervisor and nginx configs
sudo cp `pwd`/config/nginx.conf /etc/nginx/conf.d/frappe.conf
sudo cp `pwd`/config/supervisor.conf /etc/supervisor/conf.d/frappe.conf

# exit container

Start supervisord

docker exec --user root -e "TERM=xterm-256color" -w /workspace/development -d bench_frappe_1 supervisord

Stop supervisord

docker exec --user root -e "TERM=xterm-256color" -w /workspace/development -d bench_frappe_1 supervisorctl stop all

Notes:

  • publish port 80 in bench/docker-compose.yml
  • Add volumes for /etc/nginx/conf.d/ and /etc/supervisor/conf.d/
  • default frappe/bench:latest image does not have supervisor and nginx installed. Either install or build new image with frappe/bench as base image
@mtssantos18
Copy link

mtssantos18 commented Oct 26, 2023

Hello Revant,
I'm having troblue trying to access /workspace/development from outside the container, for example, if I want to change to the directory from a Dockerfile to this path /workspace/developemnt it can't access, or when I try the command docker exec using the flag -w passing the path, it also doesn't work.

it says to me the Cwd must be an absolute path: unknown.

I can only acces this folder when i'm inside the container bash, any idea of what I should do, so I can access this path from outside my container?

I'm working from Windows 10

@revant
Copy link
Author

revant commented Oct 28, 2023

I'm working from Windows 10

Hope someone who uses windows helps you. I use Linux.

@mtssantos18
Copy link

Oh got it, no problem Revant!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment