Hi, I hope I don’t take much time. I’ve started working with frappe recently. I have a few confusions regarding the lifecycle (or devops?) of frappe development.
This is my understanding so far, kindly correct me where I’m wrong:
i) Frappe has two different environments one for Development, and the other for Production.
ii) Development Environment uses Werkzeug Server. Development mode lets you change source code by turning the flag developer_mode = 1. Now in your custom app, if you create a doctype it will generate the respective python code which you can later modify.
iii) Production Environment uses Nginx Server, Redis, etc.
Now I have a few (dumb) questions:
If you setup both development and production environments on the same machine, how do you transfer your code & schema changes to the production environment? I want to grasp the entire lifecycle of development to production.
Can you change source code in Production Environment?
Is it possible to setup each environment on a different machine?
Write my changes in my machine’s development environment/directory.
Use git to push those changes to my remote GitHub 'development' branch.
When my changes are tested and approved, use git to merge those commits from my 'development' branch into my 'production' branch.
Finally, use git to pull the remote GitHub 'production' branch down to my machine’s production environment/directory.
Yes, you definitely can change source code in a Production Environment. The Python, JavaScript, and other files are not read-only or otherwise “locked.” You can edit them at any time…
…which may not be a good idea! However, nothing will prevent you from doing this.
Yes, it is very normal to have different machines with different environments. For example, today I am working on a system with 4 different environments:
Development : My laptop.
Test : VPS hosted by Digital Ocean.
Staging : A second, different VPS hosted by Digital Ocean.
Production: A third, different VPS hosted by Digital Ocean.
The code is synchronized and managed using git and related tools. Data is synchronized and managed using tools like rsync and mysqldump.
Whenever Frappe/ERPNext feels complicated, try to remember that it’s basically just this:
A directory containing thousands of files and subdirectories. Most of them Python, JavaScript, and JSON.
Four databases (which are also just a set of files. but stored somewhere else on the disk)
On a single machine, you can run 1 ERPNext or 10 ERPNexts.
Likewise, it’s possible to take 1 ERPNext, and store its code files on machine A, and databases on machines B, C, D, and E.
Well technically, there are options to prevent Python source code from being changed in production, although they require some manual intervention in lieu of certain bench commands:
install app packages with pip in non-editable mode (you can still change the files, but they won’t affect the installation)