Best way to deploy new versions of custom app in self hosted docker setup

Thanks @khoran for a workable solution, and others for raising this topic. Gotta say, what a headache deploying a custom app is on docker compose!

I had expected installing an app would be as simple as:-

docker compose exec backend bench get-app https://github.com/<my-repo>/<my-custom-app>
docker compose exec backend bench --site example.org install-app <my-custom-app>

Doing this invariably breaks the installation in the assets directory / volume.

For some reason, bench build appears to have issues with the docker compose setup, which I think may stem from the fact that the Containerfile removes the .git directory from each app.

In the function frappe.build.download_frappe_assets, the line frappe_head = getoutput("cd ../apps/frappe && git rev-parse HEAD") becomes fatal: not a git repository (or any of the parent directories): .git

Iā€™m not sure if this causes the final issues I have though. What happens with me is that the static assets directories arenā€™t symlinked properly. In sites/assets, there should be symlinks for erpnext, frappe, and my-custom-app, but these become directories, populated only with dist/js and dist/css

I have had varied success with then running: bench build --app <my-custom-app> --hard-link, as this copies all the static assets across.

Anyway, what Iā€™ve done is modify x-customizable-image in my compose.yaml file, which now looks like this:

x-customizable-image: &customizable_image
  # By default the image used only contains the `frappe` and `erpnext` apps.
  # See https://github.com/frappe/frappe_docker/blob/main/docs/custom-apps.md
  # about using custom images.
  image: frappe/erpnext:${ERPNEXT_VERSION:?No ERPNext version set}
  build:
    context: https://github.com/frappe/frappe_docker.git
    dockerfile: images/custom/Containerfile

    # Generate and export APPS_JSON_BASE64 by piping an apps.json file to `base64 -w 0`.
    # This has to be done outside of compose...
    args:
      - APPS_JSON_BASE64=${APPS_JSON_BASE64:-}
      # Some other args in the Containerfile
      #- FRAPPE_BRANCH=${FRAPPE_BRANCH:-}
      #- NODE_VERSION=${NODE_VERSION:-}
    # mount the default shell agent, for private repos.
    ssh:
      - default

Now, to update my private app, my workflow will become:

APPS_JSON_BASE64=$(cat <<__EOF | base64 -w 0
[
  {
    "url": "https://github.com/frappe/erpnext",
    "branch": "version-15"
  },
  {
    "url": "https://<username>:${GITHUB_API_KEY}@github.com/<username>/<my-custom-app>.git",
    "branch": "main"
  }                                                                                                                                                                                                                   
]                                                                                                                                                                                                                     
__EOF                                                                                                                                                                                                                 
) 

docker compose build

docker compose down && docker compose up -d

docker compose exec backend bench --site example.org clear-cache

Yeah, itā€™s a real PITA. I think bench build should allow building and updating customs apps in running containers, personally, so I can just layer my custom app over the top of the frappe/erpnext docker image, but maybe thereā€™s a difference in opinion on this?

Hey everybody,

is there any solution for this simple docker-compose setup or do we have to delete the assets folder every time? Iā€™m using simple docker setup on my vps and release my custom app with docker compose.

And I canā€™t just delete my volume where the assets are, because my assets folder is inside sites folder and I would lose my site.