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?