| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| FROM node:20-slim |
|
|
| ARG ENABLE_PDF_EXPORT=false |
| ARG ENABLE_LATEX_CONVERSION=false |
| ARG ENABLE_LATEX_EXPORT=false |
| ARG ENABLE_NOTION_IMPORT=true |
|
|
| |
| ENV ENABLE_PDF_EXPORT=${ENABLE_PDF_EXPORT} |
| ENV ENABLE_LATEX_EXPORT=${ENABLE_LATEX_EXPORT} |
|
|
| |
| RUN apt-get update && \ |
| apt-get install -y --no-install-recommends nginx git && \ |
| apt-get clean && rm -rf /var/lib/apt/lists/* |
|
|
| WORKDIR /app |
|
|
| |
| COPY app/package*.json ./ |
| RUN npm ci |
|
|
| |
| COPY app/ . |
|
|
| |
| RUN set -e; \ |
| if [ -L public/data ] || { [ -e public/data ] && [ ! -d public/data ]; }; then rm -f public/data; fi; \ |
| mkdir -p public/data; \ |
| cp -a src/content/assets/data/. public/data/ |
|
|
| |
| RUN if [ "$ENABLE_LATEX_CONVERSION" = "true" ]; then \ |
| echo "π LaTeX importer enabled - installing Pandoc..." && \ |
| apt-get update && apt-get install -y --no-install-recommends wget ca-certificates && \ |
| wget -qO- https://github.com/jgm/pandoc/releases/download/3.8/pandoc-3.8-linux-amd64.tar.gz | tar xzf - -C /tmp && \ |
| cp /tmp/pandoc-3.8/bin/pandoc /usr/local/bin/ && \ |
| cp /tmp/pandoc-3.8/bin/pandoc-lua /usr/local/bin/ && \ |
| rm -rf /tmp/pandoc-3.8 && \ |
| apt-get clean && rm -rf /var/lib/apt/lists/* && \ |
| npm run latex:convert; \ |
| else echo "βοΈ LaTeX conversion disabled"; fi |
|
|
| |
| RUN if [ "$ENABLE_NOTION_IMPORT" = "true" ]; then \ |
| echo "π¦ Pre-installing Notion importer dependencies..." && \ |
| cd scripts/notion-importer && npm ci && cd ../..; \ |
| else echo "βοΈ Notion importer disabled"; fi |
|
|
| |
| |
| RUN set -e; \ |
| if [ "$ENABLE_PDF_EXPORT" = "true" ]; then \ |
| echo "π Downloading Chromium (background)..."; \ |
| npx playwright install --with-deps chromium > /tmp/chromium.log 2>&1 & \ |
| CHROMIUM_PID=$!; \ |
| fi; \ |
| echo "π¨ Building Astro site..."; \ |
| npm run build; \ |
| if [ "$ENABLE_PDF_EXPORT" = "true" ]; then \ |
| echo "β³ Waiting for Chromium download..."; \ |
| wait $CHROMIUM_PID; \ |
| cat /tmp/chromium.log; \ |
| fi |
|
|
| |
| |
| RUN set -e; \ |
| PIDS=""; \ |
| if [ "$ENABLE_PDF_EXPORT" = "true" ]; then \ |
| echo "π Starting PDF export..."; \ |
| npm run export:pdf -- --theme=light --wait=full > /tmp/pdf.log 2>&1 & \ |
| PIDS="$PIDS $!"; \ |
| fi; \ |
| if [ "$ENABLE_LATEX_EXPORT" = "true" ]; then \ |
| echo "π Installing Pandoc + starting LaTeX export..."; \ |
| ( if ! command -v pandoc > /dev/null 2>&1; then \ |
| apt-get update && apt-get install -y --no-install-recommends wget ca-certificates && \ |
| wget -qO- https://github.com/jgm/pandoc/releases/download/3.8/pandoc-3.8-linux-amd64.tar.gz | tar xzf - -C /tmp && \ |
| cp /tmp/pandoc-3.8/bin/pandoc /usr/local/bin/ && \ |
| cp /tmp/pandoc-3.8/bin/pandoc-lua /usr/local/bin/ && \ |
| rm -rf /tmp/pandoc-3.8 && \ |
| apt-get clean && rm -rf /var/lib/apt/lists/*; \ |
| fi && \ |
| npm run export:latex \ |
| ) > /tmp/latex.log 2>&1 & \ |
| PIDS="$PIDS $!"; \ |
| fi; \ |
| if [ -n "$PIDS" ]; then \ |
| echo "β³ Waiting for exports to complete..."; \ |
| FAIL=0; \ |
| for PID in $PIDS; do wait $PID || FAIL=1; done; \ |
| [ "$ENABLE_PDF_EXPORT" = "true" ] && cat /tmp/pdf.log; \ |
| [ "$ENABLE_LATEX_EXPORT" = "true" ] && cat /tmp/latex.log; \ |
| if [ "$FAIL" -ne 0 ]; then echo "β One or more exports failed"; exit 1; fi; \ |
| echo "β
All exports completed"; \ |
| else \ |
| echo "βοΈ All exports disabled"; \ |
| fi |
|
|
| |
| COPY nginx.conf /etc/nginx/nginx.conf |
| COPY entrypoint.sh /entrypoint.sh |
| RUN chmod +x /entrypoint.sh |
|
|
| |
| RUN mkdir -p /var/cache/nginx /var/run /var/log/nginx /var/lib/nginx/body && \ |
| chmod -R 777 /var/cache/nginx /var/run /var/log/nginx /var/lib/nginx /etc/nginx/nginx.conf && \ |
| chmod -R 777 /app |
|
|
| EXPOSE 8080 |
|
|
| ENTRYPOINT ["/entrypoint.sh"] |
|
|