Try ERPNext Buy Support Partners Foundation

How to Import fixtures into a production frappe_docker env?

How to Import fixtures into a production frappe_docker env?
Working in version-12
Wiki talks a bit about fixtures but, I have not been able to persist changes on a docker production env.


Instructions from the previous wiki lack of information for production environments.

Please advise

Correct me if I am wrong, I answer (in theory) to the question.
In your development environment

  1. Create a new frappe app
  2. Create your customisations on the desired doctypes
  3. in console run: bench --site site_name export-fixtures
  4. The new app now has the exported fixtures. We need to create a container for the app with the frappe docker wrapper.

In production env.

  1. Pull and launch the Docker container for the new app.
  2. run worker container with parameter INSTALL_APPS pointing to the new app.

Instructions are still not clear enough, and still, need to try it and see if it really works.
Anyone had success with it?

development and production environments are not connected.

development is just dockerized setup to bootstrap environment to start development.
development containers are not immutable.

production is minimal environment(s) to serve frappe/ERPNext.
production containers don’t have bench or any development tools.

Custom Apps section of readme explains how to make custom apps into docker image(s).

Note that, ERPNext is also custom app installed on frappe framework. Check how ERPNext images are made using install_app wrapper script contributed by chabad360.

My concern is not about environments but how to reach to the main subject of this post. What is the process of applying “changes” into a production instance.
I didn’t find the process described in the repository documentation clear enough, but as I said before,. I may need to try the whole process before I make sure there are no gaps.
Thanks any way for your response @revant_one

yes we need to create a container for the app with frappe docker wrapper https://github.com/frappe/frappe_docker/#custom-apps

Only in case new site is created the app will be installed, there is no way currently to install app to existing site in production environment. App are installed on site creation.

If app is already installed, whenever new image is created for app and container is running with new image, run migrate command for fixtures to get applied. (https://github.com/frappe/frappe_docker/#updating-and-migrating-sites)

That is exactly what I was afraid of. And didn’t find in documentation.
Thanks for confirming that it is not possible to install an app on an existing production site. I appreciate the time you have saved me before trying.
I hope it is in the roadmap of docker_frappe to make it possible.

Best!

I have been able to apply changes to code trough a git apply patch.
Not all customisations will take effect. But for some .py and .html file updates, it did the trick for me.
Changes will be lost when container is updated, so we may need to apply patches again.

All I did to the docker environment was to add the apps folder to a volume to be able to access it.

So I know this works for code updates but, would this work for doctypes?

That will just add the directory. It needs to be installed in the python environment located in ~/frappe-bench/env directory inside container.

no it won’t work for doctypes.
json changes need migration to run.

I don’t use custom apps. So not on my priority list.

If it is urgent for you,

You will need to add install_app.py under commands (https://github.com/frappe/frappe_docker/tree/develop/build/common/commands)

Use environment variables to input site and app name and call install_app function from frappe.installer.

Also add needed lines to docker-entrypoint.sh

do add a test for install-app command
https://github.com/frappe/frappe_docker/blob/develop/tests/docker-test.sh to test

test:

  1. add new site only with frappe
  2. install-app erpnext to previously added site. (no need for custom app image)

Whenever you build your image and base it on frappe/frappe-* or frappe/erpnext-* images it will inherit this command

Yes, I wanted to apply a patch to erpnext code.
So it perfectly works. “it is a contribution to core that has not been yet approved” so need to do it manualy.

Ok, so still looking for ways to make safe updates to the core in this docker prod env.
I may tray, migration command for json files. It is ready and it is possible

I was not looking for custom-apps my self either. It is just there seems to not be more options left. Are there?

The instructions provided will be very helpful in case I do not find any other way to complete a development cicle into production. :+1:t2:

On this learning process I am still looking for a good flow on a complete dev -> test -> prod development and integration pipeline. Also learning what can be done and how… your support and your many posts in this forum are making this learning process possible.

Thanks a lot.

Here’s one alternative for pipeline. Start with it and optimize as you have more experience.

  • Use docker development bench or native bench for development.
  • manage to trigger CI / job to build images for specific branch where you commit
  • after images are built deploy them on staging server as deployment with alternate image/tag
  • user/developer can test on production like environment with production like images.
  • commit new code and repeat the cycle.
2 Likes