-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.docs
More file actions
87 lines (67 loc) · 3.41 KB
/
Copy pathDockerfile.docs
File metadata and controls
87 lines (67 loc) · 3.41 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# ── Stage 1: Build cli-generator binary ──────────────────────────────────────
# Compile the generator tool that produces the site's Quarto source.
FROM rust:1.92-bookworm AS generator
WORKDIR /build
COPY Cargo.toml Cargo.lock ./
COPY crates/ ./crates/
COPY src/ ./src/
COPY templates/ ./templates/
COPY sites/ ./sites/
RUN cargo build --release --bin cli-generator
# Build cargo-generate in the same stage so we can copy it to the renderer
# without needing Rust in that stage. Pin to a known-good release.
ARG CARGO_GENERATE_VERSION=0.21.3
RUN cargo install cargo-generate --version "${CARGO_GENERATE_VERSION}" --locked \
&& cp /usr/local/cargo/bin/cargo-generate /build/cargo-generate
# Install runtime deps: curl for Quarto download, ca-certificates for HTTPS
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
# Quarto version — pin explicitly to avoid render drift between builds.
# Update this when upgrading locally (check with: quarto --version).
ARG QUARTO_VERSION=1.6.42
RUN curl -fsSL \
"https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.deb" \
-o /tmp/quarto.deb \
&& dpkg -i /tmp/quarto.deb \
&& rm /tmp/quarto.deb
# Copy the built generator binary, cargo-generate, and site configs from stage 1.
RUN cp /build/target/release/cli-generator /usr/local/bin/cli-generator
RUN cp /build/cargo-generate /usr/local/bin/cargo-generate
RUN cp -r /build/sites/ /sites/
# Site to generate. Override at build time with:
# docker build --build-arg SITE=boat -f Dockerfile.docs .
ARG SITE=goat
RUN mkdir -p /workdir && \
groupadd -g 1000 newgroup && \
useradd -u 1000 -g newgroup -m newuser && \
chown -R newuser:newgroup /workdir /sites
# Switch to the non-root user
ENV USER=newuser
# Generate the site's source tree (--no-wasm skips WASM copy; not needed for docs).
RUN cli-generator new "$SITE" \
--output-dir /workdir \
--config /sites \
--no-wasm
# Render the Quarto docs to static HTML (_site/).
RUN quarto render "/workdir/${SITE}-cli/docs" --no-cache
# ── Stage 3: Serve with nginx ─────────────────────────────────────────────────
# Minimal image — just nginx + the rendered HTML.
# nginx:alpine runs as the built-in "nginx" user (uid 101) by default.
# We declare it explicitly so image scanners (hadolint DL3002) see a non-root USER.
FROM nginx:1.27-alpine AS docs
ARG SITE=goat
# Remove the default nginx placeholder page.
RUN rm -f /usr/share/nginx/html/index.html /usr/share/nginx/html/50x.html
# Copy rendered static site to the /docs path served by nginx.
COPY --from=generator /workdir/${SITE}-cli/docs/_site /usr/share/nginx/html/docs
# Nginx config: serve from /docs/, redirect / → /docs/.
COPY docker/nginx-docs.conf /etc/nginx/conf.d/default.conf
# Ensure log dir is owned by nginx user.
RUN chown -R nginx:nginx /var/log/nginx /var/cache/nginx /usr/share/nginx/html
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget -qO- http://localhost/docs/ || exit 1
LABEL org.opencontainers.image.description="Quarto docs for the ${SITE} SDK"
LABEL org.opencontainers.image.source="https://github.com/genomehubs/cli-generator"