Simplify Dockerfiles and custom app guide (#714)
* Add assets builder image * Use assets builder in custom_app tutorial * Use erpnext in custom app tutorial * Add info about base images (frappe or erpnext) * Add assets-builder image to frappe group so it is built in CI * Update backend image: - Fix mounted caching - Uncomplicate ERPNext build - Fix root-frappe permissions * Add build-assets script for simpler frontend build * Add install-app script for backend build * Rename build-assets to install-app for frontend build * Update custom app builds according to new main dockerfiles * Cache pip packages in custom app example backend dockerfile * Update custom app guide * Fix typo in backend dockerfile * Add info about install-app scripts in readme
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
FROM node:14-bullseye-slim as base
|
||||
FROM node:14-bullseye-slim as assets_builder
|
||||
|
||||
RUN apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
||||
@@ -8,81 +8,55 @@ RUN apt-get update \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /root/frappe-bench
|
||||
RUN mkdir -p sites/assets
|
||||
WORKDIR /frappe-bench
|
||||
|
||||
RUN mkdir -p sites/assets /out/assets \
|
||||
&& echo frappe >sites/apps.txt
|
||||
|
||||
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 yarn --cwd apps/frappe
|
||||
|
||||
# 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 \
|
||||
RUN yarn --cwd apps/frappe \
|
||||
# TODO: Currently `yarn run production` doesn't create .build on develop branch: https://github.com/frappe/frappe/issues/15396
|
||||
&& if [ ! -f sites/.build ]; then touch sites/.build; fi
|
||||
&& if [ ! -f sites/.build ]; then touch sites/.build; fi \
|
||||
&& cp sites/.build /out
|
||||
|
||||
COPY install-app.sh /usr/local/bin/install-app
|
||||
|
||||
|
||||
FROM assets_builder as frappe_assets
|
||||
|
||||
FROM base as erpnext_prod_node_modules
|
||||
RUN install-app frappe
|
||||
|
||||
|
||||
FROM assets_builder as erpnext_assets
|
||||
|
||||
ARG ERPNEXT_VERSION
|
||||
RUN git clone --depth 1 -b ${ERPNEXT_VERSION} https://github.com/frappe/erpnext apps/erpnext
|
||||
|
||||
RUN yarn --cwd apps/erpnext --prod
|
||||
RUN install-app erpnext ${ERPNEXT_VERSION} https://github.com/frappe/erpnext
|
||||
|
||||
|
||||
FROM alpine/git as bench
|
||||
|
||||
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
|
||||
|
||||
# Error pages
|
||||
RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \
|
||||
&& mkdir /out \
|
||||
&& mv /tmp/bench/bench/config/templates/502.html /out/
|
||||
|
||||
|
||||
FROM nginxinc/nginx-unprivileged:1.21.6-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
|
||||
|
||||
# https://github.com/nginxinc/docker-nginx-unprivileged/blob/main/stable/alpine/20-envsubst-on-templates.sh
|
||||
COPY nginx-template.conf /etc/nginx/templates/default.conf.template
|
||||
# https://github.com/nginxinc/docker-nginx-unprivileged/blob/main/stable/alpine/docker-entrypoint.sh
|
||||
COPY entrypoint.sh /docker-entrypoint.d/frappe-entrypoint.sh
|
||||
|
||||
USER 1000
|
||||
COPY --from=bench /out /usr/share/nginx/html/
|
||||
COPY --from=frappe_assets /out /usr/share/nginx/html
|
||||
|
||||
USER 1000
|
||||
|
||||
|
||||
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
|
||||
COPY --from=erpnext_assets /out /usr/share/nginx/html
|
||||
|
||||
Reference in New Issue
Block a user