2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-11-13 00:36:26 +00:00
frappe_docker/build/nginx/Dockerfile

86 lines
2.5 KiB
Docker
Raw Normal View History

2021-12-13 16:25:40 +00:00
FROM node:14-bullseye-slim as base
RUN apt-get update \
2021-12-13 16:25:40 +00:00
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
git \
build-essential \
2021-12-13 16:25:40 +00:00
python \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
2021-12-13 16:25:40 +00:00
WORKDIR /root/frappe-bench
RUN mkdir -p apps sites/assets/frappe
2021-12-13 16:25:40 +00:00
ARG FRAPPE_VERSION
RUN git clone --depth 1 -b ${FRAPPE_VERSION} https://github.com/frappe/frappe apps/frappe \
&& echo "frappe" >sites/apps.txt
2021-12-13 16:25:40 +00:00
WORKDIR /root/frappe-bench/apps/frappe
2021-12-13 16:25:40 +00:00
FROM base as frappe_node_modules
2021-12-13 16:25:40 +00:00
RUN yarn --prod
2021-12-13 16:25:40 +00:00
FROM frappe_node_modules as frappe_assets
2021-12-13 16:25:40 +00:00
RUN if [ "$(uname -m)" = "aarch64" ]; then \
yarn remove svg-sprite || true \
2021-12-13 16:25:40 +00:00
&& yarn add sass; \
fi \
&& yarn
2021-12-13 16:25:40 +00:00
RUN yarn run production \
&& cp -R frappe/public/* ../../sites/assets/frappe \
&& rm ../../sites/apps.txt
2021-11-19 15:11:23 +00:00
2021-12-13 16:25:40 +00:00
# Get rid of development node modules
COPY --from=frappe_node_modules /root/frappe-bench/apps/frappe/node_modules /root/frappe-bench/sites/assets/frappe/
FROM base as erpnext_node_modules
ARG ERPNEXT_VERSION
RUN cd ../.. \
&& git clone --depth 1 -b ${ERPNEXT_VERSION} https://github.com/frappe/erpnext apps/erpnext \
&& echo "frappe\nerpnext" >sites/apps.txt
RUN yarn --cwd ../erpnext --prod
FROM erpnext_node_modules as erpnext_assets
RUN mkdir -p ../../sites/assets/erpnext
RUN yarn --cwd ../erpnext
2021-12-13 16:25:40 +00:00
# Reuse development node_modules from frappe_assets
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 yarn run production --app erpnext \
&& cp -R ../erpnext/erpnext/public/* ../../sites/assets/erpnext \
&& rm ../../sites/apps.txt
2021-12-13 16:25:40 +00:00
# Get rid of development node modules
COPY --from=erpnext_node_modules /root/frappe-bench/apps/erpnext/node_modules /root/frappe-bench/apps/erpnext/node_modules
2021-12-15 09:01:02 +00:00
FROM base as error_pages
RUN git clone --depth 1 https://github.com/frappe/bench /root/bench
FROM nginx:1.21-alpine as frappe
2021-12-15 09:01:02 +00:00
COPY --from=error_pages /root/bench/bench/config/templates/502.html /usr/share/nginx/html
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}' </nginx-template.conf >/etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'" ]
2021-12-13 16:25:40 +00:00
FROM frappe as erpnext
2021-12-13 16:25:40 +00:00
COPY --from=erpnext_assets /root/frappe-bench/sites /usr/share/nginx/html