Files
mdm-ordinis/docs/Dockerfile
T
Zimin A.N. cfe26a07a7 docs: Dockerfile + nginx + CI publish для deploy на ordinis.k8s.264.nstart.cloud/docs/
Multi-stage Dockerfile: yfm build (Node 20 alpine) → nginx 1.27 alpine
serving static HTML. Nginx config:
- /healthz endpoint для k8s probes
- /docs/ alias → /usr/share/nginx/html/ (Diplodoc делает relative links,
  alias корректно работает без URL rewriting)
- Hash-named assets (_bundle/) — cache 1y immutable
- HTML pages — cache 5min must-revalidate
- /docs (без trailing slash) → 301 → /docs/
- Security headers (X-Content-Type-Options, X-Frame-Options, Referrer-Policy)

CI:
- build-docs (sanity check) — теперь только на non-main branches и MR
  (для preview без push). Production build идёт через docker-docs.
- docker-docs (NEW) — multi-stage Dockerfile build + push в repo.nstart.cloud
  через standard .docker_base + .publish_script pattern. Path-filtered на
  docs/**, manual через web UI.
- resolve-tag: emit RESOLVED_DOCS_TAG (= IMAGE_TAG, тот же что для backend).
- trigger-deploy-{staging,prod}: pass DOCS_IMAGE_TAG в downstream pipeline.

Local verify:
  cd docs && docker build -t ordinis-docs:test .
  docker run --rm -p 18088:8080 ordinis-docs:test
  curl localhost:18088/healthz       → 200
  curl -I localhost:18088/docs       → 301 → /docs/
  curl localhost:18088/docs/         → 200 index.html
  curl localhost:18088/docs/integration/api/auth.html → 200
  curl localhost:18088/docs/missing.html → 404

Соответствующие infra-side изменения (Helm chart docs deployment + Ingress
path /docs/, values, deploy script) — commit в ordinis-infra repo.
2026-05-07 23:44:03 +03:00

34 lines
1.2 KiB
Docker

# Multi-stage build для Ordinis Integrator Guide.
# Stage 1: build HTML через @diplodoc/cli (yfm).
# Stage 2: nginx serving static files на /docs/ path.
ARG NODE_IMAGE=repo.nstart.cloud/library/node:20-alpine
ARG NGINX_IMAGE=repo.nstart.cloud/library/nginx:1.27-alpine
# ─── Stage 1: Build HTML ─────────────────────
FROM ${NODE_IMAGE} AS builder
WORKDIR /docs
# Layered cache: package.json + lockfile меняются реже чем content.
COPY package.json pnpm-lock.yaml ./
RUN corepack enable \
&& corepack prepare pnpm@9.0.0 --activate \
&& pnpm install --frozen-lockfile
# Copy остальное (toc, .yfm, markdown).
COPY .yfm toc.yaml index.md ./
COPY integration ./integration
RUN pnpm build
# ─── Stage 2: nginx ──────────────────────────
FROM ${NGINX_IMAGE}
COPY --from=builder /docs/_dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Healthcheck для k8s readiness/liveness.
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 \
CMD wget -q -O - http://localhost:8080/healthz || exit 1
EXPOSE 8080