diff --git a/docs/custom-apps.md b/docs/custom-apps.md index 0b25675a..dbd073bc 100644 --- a/docs/custom-apps.md +++ b/docs/custom-apps.md @@ -24,6 +24,7 @@ export APPS_JSON='[ "branch": "main" } ]' +export APPS_JSON_BASE64=$(echo ${APPS_JSON} | base64 --wrap=0) ``` Note: @@ -38,7 +39,7 @@ buildah build \ --build-arg=FRAPPE_BRANCH=version-14 \ --build-arg=PYTHON_VERSION=3.10.5 \ --build-arg=NODE_VERSION=16.18.0 \ - --build-arg=APPS_JSON=$APPS_JSON \ + --build-arg=APPS_JSON_BASE64=$APPS_JSON_BASE64 \ --tag=ghcr.io/user/repo/custom:1.0.0 \ --file=images/custom/Containerfile . ``` @@ -46,9 +47,11 @@ buildah build \ Note: - Use `docker` instead of `buildah` as per your setup. -- Make sure `APPS_JSON` variable has correct JSON. +- `FRAPPE_PATH` and `FRAPPE_BRANCH` build args are optional and can be overridden in case of fork/branch. +- Make sure `APPS_JSON_BASE64` variable has correct base64 encoded JSON string. It is consumed as build arg, base64 encoding ensures it to be friendly with environment variables - Make sure the `--tag` is valid image name that will be pushed to registry. - Change `--build-arg` as per version of Python, NodeJS, Frappe Framework repo and branch +- The final image will have no traces of `.git` directory for any apps including frappe framework. ### Push image to use in yaml files diff --git a/images/custom/Containerfile b/images/custom/Containerfile index e53027b1..a4b080c0 100644 --- a/images/custom/Containerfile +++ b/images/custom/Containerfile @@ -73,23 +73,29 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* # apps.json includes -ARG APPS_JSON=[] -RUN mkdir /opt/frappe && echo "${APPS_JSON}" | jq . > /opt/frappe/apps.json +ARG APPS_JSON_BASE64 +RUN if [ -n "${APPS_JSON_BASE64}" ]; then \ + mkdir /opt/frappe && echo "${APPS_JSON_BASE64}" | base64 -d > /opt/frappe/apps.json; \ + fi USER frappe ARG FRAPPE_BRANCH=version-14 ARG FRAPPE_PATH=https://github.com/frappe/frappe -RUN bench init \ - --frappe-branch=${FRAPPE_BRANCH} \ - --frappe-path=${FRAPPE_PATH} \ - --no-procfile \ - --no-backups \ - --skip-redis-config-generation \ - --verbose \ - --skip-assets \ - --apps_path=/opt/frappe/apps.json \ - /home/frappe/frappe-bench && \ +RUN export APP_INSTALL_ARGS="" && \ + if [ -n "${APPS_JSON_BASE64}" ]; then \ + export APP_INSTALL_ARGS="--apps_path=/opt/frappe/apps.json"; \ + fi && \ + bench init ${APP_INSTALL_ARGS}\ + --frappe-branch=${FRAPPE_BRANCH} \ + --frappe-path=${FRAPPE_PATH} \ + --no-procfile \ + --no-backups \ + --skip-redis-config-generation \ + --verbose \ + --skip-assets \ + --apps_path=/opt/frappe/apps.json \ + /home/frappe/frappe-bench && \ cd /home/frappe/frappe-bench && \ bench setup requirements && \ find /home/frappe/frappe-bench/apps -mindepth 1 -path "*/.git" | xargs rm -fr