2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-11-09 23:00:56 +00:00
frappe_docker/development
2020-03-06 06:45:54 +05:30
..
.vscode feat: development docker 2020-03-05 21:56:31 +05:30
README.md fix: Improve README(s) 2020-03-06 06:45:54 +05:30

Getting Started

Prerequisites

  • Docker
  • docker-compose
  • user added to docker group

Bootstrap Containers for development

Clone and change to frappe_docker directory

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

Manually start containers

In case VS Code is not used follow these steps.

docker-compose -f .devcontainer/docker-compose.yml up -d

Enter the bench container at location /workspace/development

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

Use VS Code Remote Containers extension

Follow these in case VS Code is used. Do not start containers manually.

  • Install Remote Development Pack / Remote Containers extension.
  • Install VS Code Python extension.
  • Open frappe_docker in VS Code.
  • From Command Palette (Ctrl + Shift + P) Execute Remote Containers : Reopen in Container.

Setup Docker specific bench environment

Notes:

  • development directory is ignored by git. It is mounted and available in container. Create all your benches inside this directory.
  • Execute these commands from container.
  • nvm with node v12 and v10 is installed. Check with nvm ls. Node v12 is default.

Setup first bench

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

Set 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
  • honcho/Procfile starts processes required for development.
  • By default Procfile has 3 redis processes that it starts. Comment (#) or remove these lines and then run bench start.
  • Another option is to run following command :
honcho start \
    web \
    socketio \
    watch \
    schedule \
    worker_short \
    worker_long \
    worker_default

Notes:

  • bench new-site command creates a user in mariadb with container IP as host
  • After rebuilding container there is a chance that new bench container will not be able to access mariadb
  • 'db_name'@'%' needs to be set in mariadb and permission to the site database be given to the user
  • Replace db_name and db_password from site's site_config.json
  • MariaDB root password is 123

Enter mariadb shell

mysql -uroot -p123 -hmariadb

Execute following queries

UPDATE mysql.user SET Host = '%' where User = 'db_name';
SET PASSWORD FOR 'db_name'@'%' = PASSWORD('db_password');
GRANT ALL PRIVILEGES ON `db_name`.* TO 'db_name'@'%';
FLUSH PRIVILEGES;

Visual Studio Code Python Debugging

  • Install VS Code Python Extension once in remote container
  • Reload VS Code
  • Do not start web process with honcho
honcho start \
    socketio \
    watch \
    schedule \
    worker_short \
    worker_long \
    worker_default
  • On debugger tab, Connect debugger. This will start the web process with debugger connected