Automate update/migrate for new custom app version for multiple existing sites

Hello,

If we are building a custom image through GitHub - frappe/frappe_docker: Docker images for production and development setups of the Frappe framework and ERPNext with our custom app, how do we upgrade the custom app that is installed across multiple sites? What is the best way to do that? Can that be automated through CI/CD?

You need to update the image tag to the one that has the latest app code and then run migrate across your sites. How are you deploying the containers? Are you using kubernetes?

Hi Varun, yes. We deploy it in EKS using Helm.

then its easier. Use helm upgrade and set the image tag. I am using something like this:

IMAGE_TAG="v14-${BITBUCKET_COMMIT}"
K8S_NS="<fill ur ns>"
helm repo add frappe https://helm.erpnext.com
helm upgrade <release name> frappe/erpnext --set image.tag=${IMAGE_TAG} --reuse-values -n ${K8S_NS}
echo "Waiting for pods to be ready in namespace ${K8S_NS}"
kubectl wait --for=condition=Available=true deploy/${K8S_RELEASE_NAME}-erpnext-worker-s  -n  ${K8S_NS} --timeout=600s
kubectl wait --for=condition=Available=true deploy/${K8S_RELEASE_NAME}-erpnext-worker-l  -n  ${K8S_NS} --timeout=600s
kubectl wait --for=condition=Available=true deploy/${K8S_RELEASE_NAME}-erpnext-worker-d  -n  ${K8S_NS} --timeout=600s
kubectl wait --for=condition=Available=true deploy/${K8S_RELEASE_NAME}-erpnext-worker-s  -n  ${K8S_NS} --timeout=600s
kubectl wait --for=condition=Available=true deploy/${K8S_RELEASE_NAME}-erpnext-gunicorn  -n  ${K8S_NS} --timeout=600s
kubectl wait --for=condition=Available=true deploy/${K8S_RELEASE_NAME}-erpnext-nginx   -n  ${K8S_NS}     --timeout=600s
kubectl wait --for=condition=Available=true deploy/${K8S_RELEASE_NAME}-erpnext-scheduler  -n  ${K8S_NS}  --timeout=600s
kubectl wait --for=condition=Available=true deploy/${K8S_RELEASE_NAME}-erpnext-socketio   -n  ${K8S_NS}  --timeout=600s
echo "All deployments are ready. Running migrate"
kubectl exec deploy/"${K8S_RELEASE_NAME}"-erpnext-worker-s -n  ${K8S_NS} -- bench --site ${SITE_NAME} migrate
echo "Successfully migrated"

If you are using ArgoCD, your have a use a post render hook .

Your Containerfile will look like:

FROM erpnext:v15.xxxx


USER frappe
#WORKDIR /home/frappe/frappe-bench
COPY  --chown=frappe:frappe . /home/frappe/frappe-bench/apps/<appname>/
RUN env/bin/python3 -m pip install -e ./apps/<appname> &&  ls -1 /home/frappe/frappe-bench/apps > sites/apps.txt;
RUN export BENCH_DEVELOPER=1 && cd /home/frappe/frappe-bench/apps/<appname> && \
    bench build  --production
RUN cd /home/frappe/frappe-bench && \
    find apps/<appname> / -mindepth 1 -path "*/.git" | xargs rm -fr

CMD [ \
  "/home/frappe/frappe-bench/env/bin/gunicorn", \
  "--chdir=/home/frappe/frappe-bench/sites", \
  "--bind=0.0.0.0:8000", \
  "--threads=4", \
  "--workers=2", \
  "--worker-class=gthread", \
  "--worker-tmp-dir=/dev/shm", \
  "--timeout=120", \
  "--preload", \
  "frappe.app:application" \
]