How to speed up docker image build with custom apps in Frappe

Hi everyone!

I’m building a custom Docker image for Frappe using frappe_docker with this custom_apps guide. I also pass APPS_JSON_BASE64 to dynamically install my custom apps during build (via bench init ... --apps_path=/opt/frappe/apps.json). This works well, but the build takes a long time every run because it:

  • Clones all custom app repositories
  • Installs all Python/NPM packages again
  • Does a full bench init every time

I want to optimize this and reuse Docker layers or cache where possible, especially for:

  • Python packages
  • Node dependencies
  • The cloned apps (unless they’ve changed)

Has anyone successfully optimized the Frappe Docker image builds with custom apps this way? It usually takes around 15 minutes to build an image so i wanted it to be faster

1 Like
  1. Create a layer for base and builder.
  2. Base image has prod deps, use last to copy built bench
  3. Builder image has dev deps for bench

It speed up by 5 min only. Less than 15 min is fine.

When I first created container images for frappe/erpnext I predicted we’ll be having 2 GB images. Today we are aiming for 5GB or even 10GB images! Sky is the limit, time is not the limit! Good that it gets built before runner times out.

2 Likes

I am just using the containerfile from frappe_docker custom image

I think it already has what u enumerated. At this point, I’m not sure how else to improve it further. Should I just accept that the current build time is the tradeoff for this setup?

Pipelines · castlecraft / CEPL ERPNext Images · GitLab. My builds take ~22 min.

2 Likes

Thanks for sharing your build time, Revant! Now I feel justified about mine taking too long.