vomebook commited on
Commit
be3cfca
·
verified ·
1 Parent(s): b1cb815

Minify frontend assets during image build

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -1
Dockerfile CHANGED
@@ -1,3 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  FROM python:3.11-slim
2
 
3
  WORKDIR /app
@@ -8,7 +24,7 @@ RUN pip install --no-cache-dir -r requirements.txt
8
 
9
  COPY app.py build_fulltext_db.py prepare_fulltext_index.py start.sh ./
10
 
11
- COPY static/ static/
12
 
13
  COPY data/ data/
14
 
 
1
+ FROM node:22-bookworm-slim AS static-assets
2
+
3
+ ARG ESBUILD_VERSION=0.25.8
4
+
5
+ WORKDIR /build
6
+
7
+ RUN npm install --global "esbuild@${ESBUILD_VERSION}" \
8
+ && test "$(esbuild --version)" = "${ESBUILD_VERSION}"
9
+
10
+ COPY static/ /build/static/
11
+
12
+ RUN cp -a static /out \
13
+ && esbuild static/app.js --minify --target=es2019 --charset=utf8 --legal-comments=none --outfile=/out/app.js \
14
+ && esbuild static/style.css --minify --outfile=/out/style.css \
15
+ && esbuild static/sw.js --minify --target=es2019 --charset=utf8 --legal-comments=none --outfile=/out/sw.js
16
+
17
  FROM python:3.11-slim
18
 
19
  WORKDIR /app
 
24
 
25
  COPY app.py build_fulltext_db.py prepare_fulltext_index.py start.sh ./
26
 
27
+ COPY --from=static-assets /out/ static/
28
 
29
  COPY data/ data/
30