Install Apps from Local Files When Building Docker Image

Hi There,

I’m having some trouble with building a docker with image Frappe, ERPNext, and my custom app. I’m trying to use AWS CodePipelines to monitor the various repositories and pull down the source code, then use CodeBuild to build the Docker image (so I can deploy to ECS with latest app changes).

Because the pipeline is downloading files for specific commits, I want to use the files downloaded by the pipeline when setting up the image instead of always downloading the latest from GitHub. This way I can easily roll back to old revisions in the pipeline and I also know exactly what is built in to the image.

I’ve tried a bunch of different things to install the apps from the downloaded artifacts, but am always running in to Git related errors. Is there any guidance on how to build the Docker images when the apps are in the local file system, not connected to a remote, and in a detached head state?

I’ve tried:

  • Modifying the containerfile to copy in the apps, then use the custom apps JSON to point to the apps in the filesystem, but this gives errors related to the tags.
  • Using the clone-from flag in bench init, but this gives an error about not finding Python at /env/python (it should be at home/frappe/frappe-bench/env/python
  • Pulling Frappe from GitHub during install, then copying (and overwriting) the apps in the apps directory, populating sites/apps.txt, then running bench setup requirements, this gives an invalid repository error.

It’s worth noting that for all of the above, I’ve needed to fork the frappe_docker repo, which is, not ideal as it adds maintenance overhead.

Please, if anyone has any suggestions, it would be greatly appreciated.

Okay, been trying more to copy the apps in directly after an init with remote Frappe. I’ve pulled the bench source and have encountered 2 bugs, one that can’t be worked around and is blocking to this approach.

The requirements function iterates through every app (or the provided list) and App.install

It looks like the App class supports apps that are not managed by git, hence the AppMeta class has an is_repo attribute that affects how and what data is available about the app.

If the app directory is not found, it defaults is_repo to True which causes issues since the app is not a repo.

  1. The requirements function is passing the app path, not the app name to the App class, so the directory is resolving to /home/frappe/frappe-bench/apps/apps/frappe, is not being found, and defaulting to a repo.
    The workaround, is pass all the apps to the bench setup requirements command as absolute paths, so that os.path.join collapses down to the correct absolute path.
  2. Once we get through that and the install function is called, it calls install_app, passing in tag as self.tag (self referring to the App). The problem is that self.tag is not initialized by setup_details when is_repo is False

To reiterate, I’m still blocked.