Skip to content

Instantly share code, notes, and snippets.

@rahul286
Last active March 13, 2024 20:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rahul286/fd6a01b902616df3499219dfecf8aca2 to your computer and use it in GitHub Desktop.
Save rahul286/fd6a01b902616df3499219dfecf8aca2 to your computer and use it in GitHub Desktop.

Based on https://github.com/frappe/frappe_docker/blob/main/docs/development.md

Setup Frappe Docker basics

Clone git repo

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

Devcontainers in vscode

cp -R devcontainer-example .devcontainer
cp -R development/vscode-example development/.vscode

Open current dir in VSCode

code .

VScode will prompt to open it in devcontainer. If not run VSCode command Remote-Containers: Reopen in Container

Setup First bench (for ERPNext)

💡 Important – we need to ensure that Frappe and ERPNext have same versions. Hence mention versions explicitly.

Open a new terminal panel in VScode and run following inside /workspace/development dir inside devcontainer

bench init --skip-redis-config-generation frappe-bench

# bench drop frappe-bench
# bench init --skip-redis-config-generation --frappe-branch version-14 frappe-bench

cd frappe-bench

Setup hosts

We need to tell bench to use the right containers instead of localhost. Run the following commands inside the container:

bench set-config -g db_host mariadb
bench set-config -g redis_cache redis://redis-cache:6379
bench set-config -g redis_queue redis://redis-queue:6379
bench set-config -g redis_socketio redis://redis-socketio:6379

Create new site

bench new-site mysite.localhost --mariadb-root-password 123 --admin-password admin --no-mariadb-socket

Set developer mode

bench --site mysite.localhost set-config developer_mode 1
bench --site mysite.localhost clear-cache

Install ERPNext & HRMS

bench get-app --branch version-14 --resolve-deps erpnext
bench --site mysite.localhost install-app erpnext

bench get-app --branch version-14 hrms
bench --site mysite.localhost install-app hrms

Start Frappe 🎉

bench start

For logging in, go to mysite.localhost:8000

  • Username Administrator
  • Password admin

[Extras] Create another frappe site for helpdesk, wiki and more apps

bench new-site support.localhost --mariadb-root-password 123 --admin-password admin --no-mariadb-socket
bench get-app https://github.com/frappe/desk
bench --site support.localhost install-app frappedesk

bench get-app https://github.com/frappe/insights
bench --site support.localhost install-app wiki
bench --site support.localhost install-app insights
bench --site support.localhost install-app gameplan

⚠️ Note: insights and gameplan is failing to install

For logging in, go to support.localhost:8000

  • Username Administrator
  • Password admin

Direct terminal access to devcontainers

I find using iTerm more convient to run bench commands than vscode built-in terminal. So I did following workaround based on:

Open .devcontainer/devcontainer.json file and add followng line:

    "postStartCommand": "printenv > ./container.env",

Above will store env variables into actual host path development/container.env

Then launch docker exec to get into frappe's main container:

docker exec -it \
  -w /workspace \
  --env-file="$(pwd)/development/container.env" \
  $(docker ps --filter "name=$(basename $(pwd))_devcontainer-frappe" --format "{{.ID}}") \
  bash

⚠️ Please make sure you are inside frappe-docker dir on host machine when running following command. Bonus

Add an alias in ~/.config/fish/config.fish (or some other config file)

alias dc-frappe='docker exec -it -w /workspace --env-file="$(pwd)/development/container.env" $(docker ps --filter "name=$(basename $(pwd))_devcontainer-frappe" --format "{{.ID}}") bash'
@niraj2477
Copy link

Update

bench --site support.localhost install-app frappedesk

to

bench --site support.localhost install-app helpdesk

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