tfrere HF Staff commited on
Commit
bb24d8d
·
1 Parent(s): cba14c0

update dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +35 -26
Dockerfile CHANGED
@@ -2,32 +2,39 @@
2
  # Build with Playwright (browsers and deps ready)
3
  FROM mcr.microsoft.com/playwright:v1.55.0-jammy AS build
4
 
5
- # Install git, git-lfs, and dependencies for Pandoc
6
  RUN apt-get update && apt-get install -y git git-lfs wget && apt-get clean
7
 
8
- # Install latest Pandoc from GitHub releases (not apt which is outdated)
9
  RUN wget -qO- https://github.com/jgm/pandoc/releases/download/3.8/pandoc-3.8-linux-amd64.tar.gz | tar xzf - -C /tmp && \
10
  cp /tmp/pandoc-3.8/bin/pandoc /usr/local/bin/ && \
11
  cp /tmp/pandoc-3.8/bin/pandoc-lua /usr/local/bin/ && \
12
  rm -rf /tmp/pandoc-3.8
13
 
14
  # Set the working directory in the container
15
- WORKDIR /workspace
16
 
17
- # Copy the entire git repository (including .git folder and LFS files)
18
- COPY . .
19
-
20
- # Pull LFS files with HuggingFace credentials
21
- # RUN git lfs pull
22
-
23
- # Move to app directory for building
24
- WORKDIR /workspace/app
25
 
26
  # Install dependencies
27
  RUN npm install
28
 
29
- # Convert LaTeX to MDX before building
30
- RUN npm run latex:convert
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  # Ensure `public/data` is a real directory with real files (not a symlink)
33
  # This handles the case where `public/data` is a symlink in the repo, which
@@ -39,30 +46,32 @@ RUN set -e; \
39
  mkdir -p public/data; \
40
  cp -a src/content/assets/data/. public/data/
41
 
42
- # Build the application
43
  RUN npm run build
44
 
45
  # Generate the PDF (light theme, full wait)
46
  RUN npm run export:pdf -- --theme=light --wait=full
47
 
48
- # Use an official Nginx runtime as the base image for serving the application
49
- FROM nginx:alpine
50
 
51
- # Copy the built application from the build stage
52
- COPY --from=build /workspace/app/dist /usr/share/nginx/html
53
 
54
- # Copy a custom Nginx configuration file
55
  COPY nginx.conf /etc/nginx/nginx.conf
56
 
57
- # Create necessary directories and set permissions
58
- RUN mkdir -p /var/cache/nginx /var/run /var/log/nginx && \
59
- chmod -R 777 /var/cache/nginx /var/run /var/log/nginx /etc/nginx/nginx.conf
60
 
61
- # Switch to non-root user
62
- USER nginx
 
 
63
 
64
  # Expose port 8080
65
  EXPOSE 8080
66
 
67
- # Command to run the application
68
- CMD ["nginx", "-g", "daemon off;"]
 
2
  # Build with Playwright (browsers and deps ready)
3
  FROM mcr.microsoft.com/playwright:v1.55.0-jammy AS build
4
 
5
+ # Install git, git-lfs, and dependencies for Pandoc (only if ENABLE_LATEX_CONVERSION=true)
6
  RUN apt-get update && apt-get install -y git git-lfs wget && apt-get clean
7
 
8
+ # Install latest Pandoc from GitHub releases (only installed if needed later)
9
  RUN wget -qO- https://github.com/jgm/pandoc/releases/download/3.8/pandoc-3.8-linux-amd64.tar.gz | tar xzf - -C /tmp && \
10
  cp /tmp/pandoc-3.8/bin/pandoc /usr/local/bin/ && \
11
  cp /tmp/pandoc-3.8/bin/pandoc-lua /usr/local/bin/ && \
12
  rm -rf /tmp/pandoc-3.8
13
 
14
  # Set the working directory in the container
15
+ WORKDIR /app
16
 
17
+ # Copy package.json and package-lock.json
18
+ COPY app/package*.json ./
 
 
 
 
 
 
19
 
20
  # Install dependencies
21
  RUN npm install
22
 
23
+ # Copy the rest of the application code
24
+ COPY app/ .
25
+
26
+ # Conditionally convert LaTeX to MDX if ENABLE_LATEX_CONVERSION=true
27
+ ARG ENABLE_LATEX_CONVERSION=false
28
+ RUN if [ "$ENABLE_LATEX_CONVERSION" = "true" ]; then \
29
+ echo "🔄 LaTeX importer enabled - running latex:convert..."; \
30
+ npm run latex:convert; \
31
+ else \
32
+ echo "⏭️ LaTeX importer disabled - skipping..."; \
33
+ fi
34
+
35
+ # Pre-install notion-importer dependencies (for runtime import)
36
+ # Note: Notion import is done at RUNTIME (not build time) to access secrets
37
+ RUN cd scripts/notion-importer && npm install && cd ../..
38
 
39
  # Ensure `public/data` is a real directory with real files (not a symlink)
40
  # This handles the case where `public/data` is a symlink in the repo, which
 
46
  mkdir -p public/data; \
47
  cp -a src/content/assets/data/. public/data/
48
 
49
+ # Build the application (with minimal placeholder content)
50
  RUN npm run build
51
 
52
  # Generate the PDF (light theme, full wait)
53
  RUN npm run export:pdf -- --theme=light --wait=full
54
 
55
+ # Generate LaTeX export
56
+ RUN npm run export:latex
57
 
58
+ # Install nginx in the build stage (we'll use this image as final to keep Node.js)
59
+ RUN apt-get update && apt-get install -y nginx && apt-get clean && rm -rf /var/lib/apt/lists/*
60
 
61
+ # Copy nginx configuration
62
  COPY nginx.conf /etc/nginx/nginx.conf
63
 
64
+ # Copy entrypoint script
65
+ COPY entrypoint.sh /entrypoint.sh
66
+ RUN chmod +x /entrypoint.sh
67
 
68
+ # Create necessary directories and set permissions
69
+ RUN mkdir -p /var/cache/nginx /var/run /var/log/nginx /var/lib/nginx/body && \
70
+ chmod -R 777 /var/cache/nginx /var/run /var/log/nginx /var/lib/nginx /etc/nginx/nginx.conf && \
71
+ chmod -R 777 /app
72
 
73
  # Expose port 8080
74
  EXPOSE 8080
75
 
76
+ # Use entrypoint script that handles Notion import if enabled
77
+ ENTRYPOINT ["/entrypoint.sh"]