Speed up asset building when developing

main
Alexander Graf 2 years ago
parent 71263f1a8c
commit f7caaddbec
No known key found for this signature in database
GPG Key ID: B8A9DC143E075629

@ -4,13 +4,19 @@ FROM node:16-alpine3.16
WORKDIR /work
COPY content/ ./
COPY package.json ./
COPY webpack.config.js ./
RUN set -euxo pipefail \
&& npm config set update-notifier false \
&& npm install --no-audit --no-fund \
&& sed -i 's/#007bff/#55a5d9/' node_modules/admin-lte/build/scss/_bootstrap-variables.scss \
&& for l in ca da de:de-DE en:en-GB es:es-ES eu fr:fr-FR he hu is it:it-IT ja nb_NO:no-NB nl:nl-NL pl pt:pt-PT ru sv:sv-SE zh; do \
; npm config set update-notifier false \
; npm install --no-audit --no-fund \
; sed -i 's/#007bff/#55a5d9/' node_modules/admin-lte/build/scss/_bootstrap-variables.scss \
; mkdir assets \
; for l in ca da de:de-DE en:en-GB es:es-ES eu fr:fr-FR he hu is it:it-IT ja nb_NO:no-NB nl:nl-NL pl pt:pt-PT ru sv:sv-SE zh; do \
cp node_modules/datatables.net-plugins/i18n/${l#*:}.json assets/${l%:*}.json; \
done \
&& node_modules/.bin/webpack-cli --color
done
COPY assets/ ./assets/
RUN set -euxo pipefail \
; node_modules/.bin/webpack-cli --color

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

@ -47,14 +47,11 @@ cp -r "${base}"/libs .
sed -E '/^#/d;s:^FROM system$:FROM system AS base:' "${base}/Dockerfile" >Dockerfile
# assets
cp -r "${assets}/content" .
cp "${assets}/package.json" .
cp -r "${assets}/assets/" .
awk '/new compress/{f=1}!f{print}/}),/{f=0}' <"${assets}/webpack.config.js" >webpack.config.js
sed -E '/^#/d;s:^(FROM [^ ]+$):\1 AS assets:' "${assets}/Dockerfile" >>Dockerfile
cat >>Dockerfile <<EOF
RUN set -euxo pipefail \
; rm -f /work/static/*.gz
EOF
# admin
sed -E '/^#/d;/^(COPY|EXPOSE|HEALTHCHECK|VOLUME|CMD) /d; s:^(.* )[^ ]*pybabel[^\\]*(.*):\1true \2:' "${admin}/Dockerfile" >>Dockerfile
@ -107,8 +104,8 @@ for vol in audit.py start.py mailu/ migrations/; do
volumes+=( --volume "${admin}/${vol}:/app/${vol}" )
done
for file in "${assets}/content/assets"/*; do
[[ "${file}" == */vendor.js ]] && continue
for file in "${assets}/assets"/*; do
[[ ! -f "${file}" || "${file}" == */vendor.js ]] && continue
volumes+=( --volume "${file}:/app/static/${file/*\//}" )
done

Loading…
Cancel
Save