| FROM node:22-bookworm-slim AS static-assets |
|
|
| ARG ESBUILD_VERSION=0.28.2 |
|
|
| WORKDIR /build |
|
|
| RUN npm install --global "esbuild@${ESBUILD_VERSION}" \ |
| && test "$(esbuild --version)" = "${ESBUILD_VERSION}" |
|
|
| COPY static/ /build/static/ |
| COPY scripts/build_static_assets.mjs /build/build_static_assets.mjs |
| COPY scripts/copy_reader_vendor.mjs /build/copy_reader_vendor.mjs |
|
|
| RUN mkdir -p /out \ |
| && cp -a static/. /out/ \ |
| && node /build/copy_reader_vendor.mjs /out/vendor \ |
| && esbuild static/app.js --minify --target=es2019 --charset=utf8 --legal-comments=none --outfile=/out/app.js \ |
| && esbuild static/reader-contract.js --minify --target=es2019 --charset=utf8 --legal-comments=none --outfile=/out/reader-contract.js \ |
| && esbuild static/reader-store.js --minify --target=es2019 --charset=utf8 --legal-comments=none --outfile=/out/reader-store.js \ |
| && esbuild static/reader.js --minify --target=es2019 --charset=utf8 --legal-comments=none --outfile=/out/reader.js \ |
| && esbuild static/style.css --minify --outfile=/out/style.css \ |
| && esbuild static/reader.css --minify --outfile=/out/reader.css \ |
| && node /build/build_static_assets.mjs \ |
| && esbuild /out/sw.js --minify --target=es2019 --charset=utf8 --legal-comments=none --outfile=/out/sw.min.js \ |
| && mv /out/sw.min.js /out/sw.js |
|
|
| FROM python:3.11-slim |
|
|
| WORKDIR /app |
|
|
| RUN apt-get update && apt-get install -y --no-install-recommends \ |
| gzip \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
| COPY requirements.txt . |
| RUN pip install --no-cache-dir -r requirements.txt |
|
|
| COPY app.py . |
| COPY --from=static-assets /out/ static/ |
| COPY data/ data/ |
| COPY txt/ txt/ |
|
|
| RUN if [ -f data/search_data.json ]; then \ |
| gzip -k -9 data/search_data.json; \ |
| fi |
|
|
| EXPOSE 7860 |
|
|
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "info"] |
|
|