fix(custom): pass base64 encoded apps json

This commit is contained in:
Revant Nandgaonkar 2023-01-01 13:59:51 +05:30
parent 4e96a16ee2
commit b82b5bf583
2 changed files with 23 additions and 14 deletions

View file

@ -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

View file

@ -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