Question about git structuring, continuous deployment and updating

Hi all, i am still new to Frappe and Python; I am basically a Node.js/Angular Developer so this is all new to me.

I am used to use github/bitbucket to version control my projects. Usually I initiate .git repo in the client app and another .git repo in the server app, then I add to gitIgnore stuff such as node_modules, dist…e.tc pretty standard I guess.
And in git I usually create develop branch, and feature branches that I merge to develop when done, then periodically I update stage (testing for QA) and master (production) for a every new release (GitFlow approach). Pretty standard.

What I currently have:

  • Erpnext 12 in the virtualbox provided by you (I have Windows 10), I installed gdm3 on it to have interface, and vs code there. and I used it to do the Library management tutorial.
  • There’s another Erpnext 12 for production hosted by someone else that soon I shall have access to it.

I am not sure what’s the best way to structure git, and what flow approach to follow in frappe erpnext, in the Library management tutorial I read:
" Frappe Framework and the apps you build on it require git for version control and update management via Bench."

I am not sure what that means, so does frappe come with git out of the box, with predefined branches? And where do I change the git URI address? How can I use it to push to a private repo that I have?

  • Do I need to the change git URI on both environments my local (virtualbox) , and the one hosted in production server. So when I push to master locally, I pull there in production server for updating?
  • Or should I only need to initiate git for each custom app, and then I need to git pull for each in production and install them to target site manually every time? (by using the bench commands for install custom app to a target site).

Or is there a better and easier (and safer) way than all that?

Yes, ERPNext begins with git immediately upon installation.

Fundamentally, ERPNext consists of 3 source-controlled applications (there are small exceptions, but not worth digressing into yet.)

  1. Frappe Framework/App
    • This has 1 git repository, hosted on GitHub.
    • The most-current, stable git branch is 'version-13'
    • The local path to its git repo is '../frappe-bench/apps/frappe/.git'
  2. ERPNext App
    • This has 1 git repository, hosted on GitHub.
    • The most-current, stable branch is 'version-13'
    • The local path to its git repo is '../frappe-bench/apps/erpnext/.git'
  3. Bench
    • This also has a git repository on GitHub, however…
    • the official recommendation is to install it from PyPI.org via the Python pip utility.
    • You probably don’t need to think about Bench’s git repository, unless you intend to fork and tailor it to your own needs.

Each additional App you develop yourself has its own, separate git repository from the Frappe and ERPNext ones mentioned above.

Otherwise, nothing special regarding the source control. You are free to add your own remotes. Create new branches. All the usual stuff. And use whatever Git strategy suits you best (e.g. Git Flow, GitHub Flow, GitLab Flow, etc.)

If you’re interested in pull requests to the Official repositories, there’s some documentation online here.

2 Likes

First of all you don’t need to do anything with git and frappe, erpnext, or bench unless you are contributing.

The only git you deal with is your custom app. Which flow you use is your choice as you’ve complete control over your custom app. bench new-app will create app as a git repo by default.

I prefer:

  • “main” branch as only branch. Features are on merge requests. Acts as edge, nightly, latest
  • Use git semver tags and a release script that bumps up __init__.py to make versioned production releases.
  • On merging to main, latest images are built, optionally deployed on UAT.
  • On tagging, tagged version of images are built. Manually trigger deploy of tagged images to production.

Advance stuff:

3 Likes

Thank you both for answering.

I have more (possibly dummy) questions:

  • Just to confirm, no git comes automatically when creating a new custom app, right? I 've looked into the folders and I didn’t find any .git, unless it’s hidden somewhere. So I guess I should initiate a repo after creating of a new app.
  • In my understanding, erpnext has “Core apps” like Accounting, Stock, Assets, CRM…etc, the rectangles we see in the “Desk”. I think those are not things to be edited and touched, as they’re the core ERP.
  • While “Custom apps” are additional “modules”, which appear as additional items in the “Desk” (as additional “rectangles”), where you can assign new doctypes and forms and view to it.
  • So, what’s the point of having an Angular app as a “Custom App”? Wouldn’t that make the looks and feel inconsistent with the other core Apps? Or is your Spa example to be used for customers only (and not admins) as their only entry portal? Like the the http://testportalspa.localhost:8000/ example.
  • Is it possible for a “Custom App” to affect the entire looks and feel of the entire ERPnext, including the Desk page …etc? I glimpsed into the topic of themes and I recall someone created a custom app just for that. I am not sure I get it.
  • frappe.model.docstatus seems to be missing, I am using 0, 1 and 2 to indicate states, is that fine?
  • And lately, why in all examples you always create a new site before creating a new custom app, in my understanding a site = a new database, that would lead to a lot of databases. Is that a common practice? why not simply install the app to the default site?

How did you create the new app? If you use the command line tool (bench new-app), a .git folder will be created automatically. I’ve never tried, but I’m not sure it’s even possible to manage custom apps without git. Bench in particular assumes the existence for many commands.

In Frappe/ERPNext, you have apps, modules, and doctypes.

Apps are packages of source code, installed to a given site and corresponding 1-to-1 to a git repo. They often bring together related functionality, but there’s no reason they need to.

The two “standard” apps are Frappe (the framework, which doesn’t have much content on its own) and ERPNext (which defines most of the content that comes standard, like invoices, price lists, manufacturing processes, etc.).

There are other apps for domains (i.e., Healthcare), regions (i.e., compliance with Swiss law), integrations (i.e., Shopify), and functionality (i.e., a wiki or a point of sales). For end users, apps are relatively transparent, and where one app stops or another starts isn’t really visible. App structure is more a matter for developers and server administrators than users.

Modules group together related document types into conceptual areas, such as Sales, Manufacturing, HR, etc. All doctypes must be part of a module, though at present the modules themselves don’t actually affect much apart from a few permissions related things. There’s been some talk at various points about formalizing modules a bit to define protocols, apis, etc., but at present it’s really more organizational than functional.

Doctypes define individual data structures and life cycle events. These are the things you see as forms, such as Sales Invoices, Leave Requests, Price Lists, etc.

There’s no particular point, aside from allowing you to program in angular if that’s your preference. Frappe comes with Vue.js built in, though it’s not used for very much at this point. It is a resource available to anyone creating custom pages. If you prefer a different stack, you can probably get it to work without much difficulty.

As for integrated looks and feel, it depends on your use-case. If you’re creating a POS for your floor team, for example, creating a unified appearance may not be an issue. For SPAs that blend in a bit more, the maintainers have recently released Frappe-UI, which is a set of components in Vue and Tailwind.

As mentioned above, apps are just bundles of code installed together. Most functionality, including desk pages, can be changed or recreated using Frappe’s hooks system. This could include slight tweaks to the appearance or a total rewrite of the UI.

I’m not sure I understand. What do you mean that it is missing? In Frappe, some doctypes are defined as “Submittable”, in which case each document will have a field called “docstatus” with a value of either 0 (draft), 1 (submitted), or 2 (cancelled). Generally speaking, you would not want to mess with docstatus directly or apply other meanings to it. If you need to indicate different kinds of state, use a different field (or look into “Workflows”).

There is no requirement to create a new site before creating an app. The tutorials you are seeing are probably meant to demonstrate development from an empty installation. If you already have a site, you can install your new app on that if you’d like.

1 Like

the ERPNext app can only be installed on fresh site with wizard yet to complete. Some other apps may have this prerequisite.

1 Like

I have used that same command to the letter, surely I didn’t create the app structure all manually from the scratch.
See below screenshot, there’s only gitignore that got auto-created, so I expected to find a .git in the same directory.

The VS code doesn’t detect any repo there either.

That’s not a big issue since I can easily initiate one for each custom app, but I was wondering why It didn’t generate it with the bench new-app command.

Same thing for the library management tutorial app which I created following the tutorial to the letter, no .git there. The below screenshot is from Ubuntu directly.

The library is not part of frappe python library, despite that this line is everywhere in your tutorials. It simply does not exist.
image

That’s why I had to use 0, 1, and 2 instead of its methods for status checking in controllers, I had no choice.

At this moment docstatus.py exists only on develop branch https://github.com/frappe/frappe/blob/develop/frappe/model/docstatus.py

There is no docstatus.py in other branches.

Yeah, unfortunately really couldn’t tell you. I’ve tested now on both WSL on Windows 10 and a VPS running Ubuntu 18.04. In both cases, the git repo was created. If you’re not seeing any error messages on new app creation, I’m without any quick suggestions.

Edit: Just one thing I noticed, which may or may not be helpful here: I just noticed that VSCode hides .git folders from the explorer by default. If you load up a terminal and try to navigate to the directory, is it still not there?

image

Nope.

Sorry, then. I can’t really think what the issue might be. I’m not able to reproduce it.