mirror of
https://github.com/frappe/frappe_docker.git
synced 2026-06-22 15:55:09 +00:00
Clean up nginx dockerfile
This commit is contained in:
parent
89236d8ed6
commit
36f58c5937
1 changed files with 32 additions and 29 deletions
|
|
@ -9,61 +9,57 @@ RUN apt-get update \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /root/frappe-bench
|
WORKDIR /root/frappe-bench
|
||||||
RUN mkdir -p apps sites/assets/frappe
|
RUN mkdir -p sites/assets
|
||||||
|
|
||||||
ARG FRAPPE_VERSION
|
ARG FRAPPE_VERSION
|
||||||
RUN git clone --depth 1 -b ${FRAPPE_VERSION} https://github.com/frappe/frappe apps/frappe \
|
RUN git clone --depth 1 -b ${FRAPPE_VERSION} https://github.com/frappe/frappe apps/frappe
|
||||||
&& echo "frappe" >sites/apps.txt
|
|
||||||
|
|
||||||
WORKDIR /root/frappe-bench/apps/frappe
|
|
||||||
|
|
||||||
|
|
||||||
FROM base as frappe_node_modules
|
|
||||||
|
|
||||||
RUN yarn --prod
|
FROM base as frappe_prod_node_modules
|
||||||
|
|
||||||
|
# Install production node modules
|
||||||
|
RUN yarn --cwd apps/frappe --prod
|
||||||
|
|
||||||
|
|
||||||
FROM frappe_node_modules as frappe_assets
|
|
||||||
|
|
||||||
RUN if [ "$(uname -m)" = "aarch64" ]; then \
|
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 remove svg-sprite || true \
|
||||||
&& yarn add sass; \
|
&& yarn add sass; \
|
||||||
fi \
|
fi \
|
||||||
&& yarn
|
&& yarn
|
||||||
|
|
||||||
RUN yarn run production \
|
# Build assets stored in frappe-bench/sites/assets
|
||||||
&& cp -R frappe/public/* ../../sites/assets/frappe \
|
RUN echo "frappe" >sites/apps.txt \
|
||||||
&& rm ../../sites/apps.txt
|
&& yarn --cwd apps/frappe run production \
|
||||||
|
&& rm sites/apps.txt
|
||||||
# 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
|
|
||||||
|
FROM base as erpnext_prod_node_modules
|
||||||
|
|
||||||
ARG ERPNEXT_VERSION
|
ARG ERPNEXT_VERSION
|
||||||
RUN cd ../.. \
|
RUN git clone --depth 1 -b ${ERPNEXT_VERSION} https://github.com/frappe/erpnext apps/erpnext
|
||||||
&& 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
|
RUN yarn --cwd apps/erpnext --prod
|
||||||
|
|
||||||
|
|
||||||
FROM erpnext_node_modules as erpnext_assets
|
|
||||||
|
|
||||||
RUN mkdir -p ../../sites/assets/erpnext
|
FROM erpnext_prod_node_modules as erpnext_assets
|
||||||
RUN yarn --cwd ../erpnext
|
|
||||||
|
RUN yarn --cwd apps/erpnext
|
||||||
|
|
||||||
# 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/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/
|
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 \
|
RUN echo "frappe\nerpnext" >sites/apps.txt \
|
||||||
&& cp -R ../erpnext/erpnext/public/* ../../sites/assets/erpnext \
|
&& yarn --cwd apps/frappe run production --app erpnext \
|
||||||
&& rm ../../sites/apps.txt
|
&& rm sites/apps.txt
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
|
|
||||||
FROM base as error_pages
|
FROM base as error_pages
|
||||||
|
|
@ -71,15 +67,22 @@ FROM base as error_pages
|
||||||
RUN git clone --depth 1 https://github.com/frappe/bench /root/bench
|
RUN git clone --depth 1 https://github.com/frappe/bench /root/bench
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FROM nginx:1.21-alpine as frappe
|
FROM nginx:1.21-alpine as frappe
|
||||||
|
|
||||||
COPY --from=error_pages /root/bench/bench/config/templates/502.html /usr/share/nginx/html
|
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 --from=frappe_assets /root/frappe-bench/sites /usr/share/nginx/html
|
||||||
|
|
||||||
COPY nginx-template.conf /
|
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;'" ]
|
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;'" ]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FROM frappe as erpnext
|
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 /root/frappe-bench/sites /usr/share/nginx/html
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue