File size: 2,487 Bytes
85e5ca8 e329457 49f98d3 85e5ca8 bb24d8d 9011170 bb24d8d 9011170 d912fc5 85e5ca8 bb24d8d d912fc5 bb24d8d 85e5ca8 bb24d8d f7b880e bb24d8d c7b266f 52307d3 f7b880e 85e5ca8 e329457 e0ad823 f7b880e 85e5ca8 f7b880e 85e5ca8 f7b880e 85e5ca8 bb24d8d f7b880e 85e5ca8 f7b880e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# Use an official Node runtime as the base image for building the application
# Build with Playwright (browsers and deps ready)
FROM mcr.microsoft.com/playwright:v1.56.0-jammy AS build
# Install git, git-lfs, and dependencies for Pandoc (only if ENABLE_LATEX_CONVERSION=true)
RUN apt-get update && apt-get install -y git git-lfs wget && apt-get clean
# Install latest Pandoc from GitHub releases (only installed if needed later)
RUN 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
# Set the working directory in the container
WORKDIR /app
# Copy package.json and package-lock.json
COPY app/package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY app/ .
# Conditionally convert LaTeX to MDX if ENABLE_LATEX_CONVERSION=true
ARG ENABLE_LATEX_CONVERSION=true
RUN if [ "$ENABLE_LATEX_CONVERSION" = "true" ]; then \
echo "🔄 LaTeX importer enabled - running latex:convert..."; \
npm run latex:convert; \
else \
echo "⏭️ LaTeX importer disabled - skipping..."; \
fi
# Ensure `public/data` is a real directory with real files (not a symlink)
# This handles the case where `public/data` is a symlink in the repo, which
# would be broken inside the container after COPY.
RUN set -e; \
if [ -e public ] && [ ! -d public ]; then rm -f public; fi; \
mkdir -p public; \
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/
# Build the application
RUN npm run build
# Generate the PDF (light theme, full wait)
RUN npm run export:pdf -- --theme=light --wait=full
# Use an official Nginx runtime as the base image for serving the application
FROM nginx:alpine
# Copy the built application from the build stage
COPY --from=build /app/dist /usr/share/nginx/html
# Copy a custom Nginx configuration file
COPY nginx.conf /etc/nginx/nginx.conf
# Create necessary directories and set permissions
RUN mkdir -p /var/cache/nginx /var/run /var/log/nginx && \
chmod -R 777 /var/cache/nginx /var/run /var/log/nginx /etc/nginx/nginx.conf
# Switch to non-root user
USER nginx
# Expose port 8080
EXPOSE 8080
# Command to run the application
CMD ["nginx", "-g", "daemon off;"]
|