FROM node:14-bullseye-slim as base RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ git \ build-essential \ python \ ca-certificates \ && rm -rf /var/lib/apt/lists/* WORKDIR /root/frappe-bench RUN mkdir -p sites/assets ARG FRAPPE_VERSION RUN git clone --depth 1 -b ${FRAPPE_VERSION} https://github.com/frappe/frappe apps/frappe FROM base as frappe_prod_node_modules # Install production node modules RUN yarn --cwd apps/frappe --prod FROM frappe_prod_node_modules as frappe_assets # Install development node modules RUN cd apps/frappe && \ if [ "$(uname -m)" = "aarch64" ]; then \ yarn remove svg-sprite || true \ && yarn add sass; \ fi \ && yarn # Build assets they're stored in frappe-bench/sites/assets RUN echo "frappe" >sites/apps.txt \ && yarn --cwd apps/frappe run production \ && rm sites/apps.txt FROM base as erpnext_prod_node_modules ARG ERPNEXT_VERSION RUN git clone --depth 1 -b ${ERPNEXT_VERSION} https://github.com/frappe/erpnext apps/erpnext RUN yarn --cwd apps/erpnext --prod FROM erpnext_prod_node_modules as erpnext_assets RUN yarn --cwd apps/erpnext COPY --from=frappe_assets /root/frappe-bench/apps/frappe/node_modules /root/frappe-bench/apps/frappe/node_modules COPY --from=frappe_assets /root/frappe-bench/apps/frappe/package.json /root/frappe-bench/apps/frappe/yarn.lock /root/frappe-bench/apps/frappe/ RUN echo "frappe\nerpnext" >sites/apps.txt \ && yarn --cwd apps/frappe run production --app erpnext \ && rm sites/apps.txt FROM base as error_pages RUN git clone --depth 1 https://github.com/frappe/bench /root/bench FROM nginx:1.21-alpine as frappe COPY --from=error_pages /root/bench/bench/config/templates/502.html /usr/share/nginx/html COPY --from=base /root/frappe-bench/apps/frappe/frappe/public /usr/share/nginx/html/assets/frappe COPY --from=frappe_prod_node_modules /root/frappe-bench/apps/frappe/node_modules /usr/share/nginx/html/assets/frappe/node_modules COPY --from=frappe_assets /root/frappe-bench/sites /usr/share/nginx/html COPY nginx-template.conf / CMD [ "/bin/sh" , "-c" , "envsubst '${BACKEND} ${SOCKETIO} ${FRAPPE_SITE_NAME_HEADER}' /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'" ] FROM frappe as erpnext COPY --from=erpnext_prod_node_modules /root/frappe-bench/apps/erpnext/erpnext/public /usr/share/nginx/html/assets/erpnext COPY --from=erpnext_prod_node_modules /root/frappe-bench/apps/erpnext/node_modules /usr/share/nginx/html/assets/erpnext/node_modules COPY --from=erpnext_assets /root/frappe-bench/sites /usr/share/nginx/html