1
+ FROM node:20.11-slim as dependencies
2
+ WORKDIR /app
3
+
4
+ # Install pnpm and build dependencies
5
+ RUN npm install -g
[email protected] && \
6
+ apt-get update -qq && \
7
+ apt-get install -y python3 build-essential && \
8
+ rm -rf /var/lib/apt/lists/*
9
+
10
+ # Create the environments directory and env file FIRST
11
+ RUN mkdir -p src/environments && \
12
+ echo "PLAYWRIGHT_BROWSERS_PATH=/app/pw-browsers" > src/environments/browser-path.env
13
+
14
+ # Copy package files
15
+ COPY package.json pnpm-lock.yaml ./
16
+
17
+ # Install dependencies and extra packages needed for content generation
18
+ ENV PLAYWRIGHT_BROWSERS_PATH=/app/pw-browsers
19
+ ENV HUSKY=0
20
+ RUN pnpm install && \
21
+ pnpm add
[email protected] html-escaper kleur && \
22
+ pnpm playwright install chromium
23
+
24
+ # Content generation stage
25
+ FROM dependencies as content-builder
26
+ WORKDIR /app
27
+
28
+ # Copy source files
29
+ COPY . .
30
+
31
+ # Copy over the node_modules and Playwright browsers
32
+ COPY --from=dependencies /app/node_modules ./node_modules
33
+ COPY --from=dependencies /app/pw-browsers ./pw-browsers
34
+ COPY --from=dependencies /app/src/environments/browser-path.env ./src/environments/browser-path.env
35
+
36
+ # First generate the content
37
+ RUN pnpm run epub & pnpm run social-previews:build & wait
38
+
39
+ # Run just the Astro build
40
+ RUN pnpm exec astro build --experimental-integrations || if [ -d "dist" ]; then \
41
+ exit 0; \
42
+ else \
43
+ exit 1; \
44
+ fi
45
+
46
+ # Production stage for static files
47
+ FROM nginx:alpine
48
+ COPY --from=content-builder /app/dist /usr/share/nginx/html
49
+
50
+ EXPOSE 80
51
+ CMD ["nginx" , "-g" , "daemon off;" ]
0 commit comments