|
1 | | -# Basic docker based environment |
2 | | -# Necessary to trick dokku into building the documentation |
3 | | -# using dockerfile instead of herokuish |
4 | | -FROM ubuntu:22.04 |
5 | | - |
6 | | -# Add basic tools |
7 | | -RUN apt-get update && \ |
8 | | - apt-get install -y build-essential \ |
9 | | - software-properties-common \ |
10 | | - curl \ |
11 | | - git \ |
12 | | - libxml2 \ |
13 | | - libffi-dev \ |
14 | | - libssl-dev |
15 | | - |
16 | | -# Prevent interactive timezone input |
17 | | -ENV DEBIAN_FRONTEND=noninteractive |
18 | | -RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php && \ |
19 | | - apt-get update && \ |
20 | | - apt-get install -y php8.1-cli php8.1-mbstring php8.1-xml php8.1-zip php8.1-intl php8.1-opcache php8.1-sqlite |
21 | | - |
22 | | -WORKDIR /code |
23 | | - |
24 | | -VOLUME ["/code"] |
25 | | - |
26 | | -CMD [ '/bin/bash' ] |
| 1 | +# ---------------------- |
| 2 | +# 1. Build stage |
| 3 | +# ---------------------- |
| 4 | +FROM node:22-alpine AS builder |
| 5 | + |
| 6 | +# Git is required because docs/package.json pulls a dependency from GitHub. |
| 7 | +RUN apk add --no-cache git openssh-client |
| 8 | + |
| 9 | +WORKDIR /app/docs |
| 10 | + |
| 11 | +# Copy dependency manifests first to preserve Docker layer caching. |
| 12 | +COPY docs/ ./ |
| 13 | +RUN npm ci |
| 14 | + |
| 15 | +# Increase max-old-space-size to avoid memory issues during build |
| 16 | +ENV NODE_OPTIONS="--max-old-space-size=8192" |
| 17 | + |
| 18 | +# Build the site. |
| 19 | +RUN npm run docs:build |
| 20 | + |
| 21 | +# ---------------------- |
| 22 | +# 2. Runtime stage (nginx) |
| 23 | +# ---------------------- |
| 24 | +FROM nginx:1.27-alpine AS runner |
| 25 | + |
| 26 | +# Copy built files |
| 27 | +COPY --from=builder /app/docs/.vitepress/dist /usr/share/nginx/html |
| 28 | + |
| 29 | +# Expose port |
| 30 | +EXPOSE 80 |
| 31 | + |
| 32 | +# Health check (optional) |
| 33 | +HEALTHCHECK CMD wget --quiet --tries=1 --spider http://localhost:80/ || exit 1 |
| 34 | + |
| 35 | +# Start nginx |
| 36 | +CMD ["nginx", "-g", "daemon off;"] |
0 commit comments