docs-fp-o-ci-test/build-site-container/Containerfile
Hristo Marinov a23f4117cf
Some checks failed
Build fedocs container image for Fedora Docs / build (x86_64, latest, buildroot) (push) Successful in 3m20s
Build fedocs container image for Fedora Docs / merge (x86_64, latest, buildroot) (push) Successful in 46s
Build Antora container image for Fedora Docs / build (x86_64, latest, buildroot) (push) Successful in 4m10s
Build Antora container image for Fedora Docs / merge (x86_64, latest, buildroot) (push) Successful in 41s
Build container image for previewing the Fedora Docs / build (stg) (push) Failing after 22m27s
Build container image for previewing the Fedora Docs / build (prod) (push) Successful in 25m51s
Work in progress
Signed-off-by: Hristo Marinov <hricky@fedoraproject.org>
2026-09-19 23:31:32 +03:00

205 lines
6.4 KiB
Docker

# SPDX-FileCopyrightText: Fedora Docs maintainers
# SPDX-License-Identifier: MIT
ARG BASEIMAGE_REPO=overridden
ARG BASEIMAGE_TAG=overridden
ARG CHUNKAH_REPO=overridden
ARG CHUNKAH_TAG=overridden
ARG CHUNKAH_TOOL_BASE_IMAGE=overridden
ARG ANTORA_IMAGE=overridden
# Original: FROM ${BASEIMAGE_REPO}:${BASEIMAGE_TAG} AS builder
# Builds on the antora image (build-antora-container/Containerfile) instead of
# repeating its Node/git/PyYAML/Antora install. The antora image is built with
# the pinned Antora version (see antora.yaml), so nothing is reinstalled here.
FROM ${ANTORA_IMAGE} AS builder
# ENV PLAYBOOK_PATH=${PLAYBOOK_PATH}
ENV BUILD_ENV=${BUILD_ENV}
# ENV NODEJS_VERSION=${NODEJS_VERSION}
# ENV ANTORA_VERSION=${ANTORA_VERSION}
# # Install required packages
# RUN --mount=type=cache,rw,target=/cache \
# --mount=type=cache,dst=/var/cache/dnf \
# --mount=type=cache,dst=/var/cache/libdnf5 \
# <<EORUN
# set -euo pipefail
# set -x
# export FORCE_COLUMNS=134
# rm --force /etc/yum.repos.d/fedora-cisco-openh264.repo
# dnf upgrade --assumeyes --refresh --no-allow-downgrade \
# --allowerasing
# dnf --refresh install --assumeyes --allowerasing \
# --no-allow-downgrade --no-docs --setopt=tsflags=nodocs \
# --setopt=install_weak_deps=False --best \
# --exclude container-selinux \
# nodejs${NODEJS_VERSION}-npm \
# git-core \
# python3-pyyaml
# dnf clean all
# # rm --recursive --force /tmp/* /var/lib/dnf/* /var/cache/dnf/* /var/log/*
# rm --recursive --force /var/lib/dnf/* /var/cache/dnf/* /var/log/*
# npm install \
# --global \
# @antora/cli@${ANTORA_VERSION} \
# @antora/site-generator@${ANTORA_VERSION} \
# @antora/lunr-extension \
# cheerio \
# @asciidoctor/tabs
# npm cache clean --force
# mkdir --parents /antora/output
# EORUN
# # Reinstall only the Antora packages that need the pinned version; Node, git,
# # PyYAML and the extensions already come from the antora image.
# RUN <<EORUN
# set -euo pipefail
# set -x
#
# npm install \
# --global \
# @antora/cli@${ANTORA_VERSION} \
# @antora/site-generator@${ANTORA_VERSION}
#
# npm cache clean --force
#
# mkdir --parents /antora/output
# EORUN
RUN mkdir --parents /antora/output
ENV NODE_PATH=/usr/local/lib/node_modules
COPY build-scripts/rebuild-site.py /antora/rebuild-site.py
# COPY ${PLAYBOOK_PATH} /antora/${PLAYBOOK_PATH}
COPY lib /antora/lib
COPY static /antora/static
COPY supplemental-ui /antora/supplemental-ui
WORKDIR /antora
ENV BUILD_ENV=${BUILD_ENV}
RUN /antora/rebuild-site.py
FROM ${BASEIMAGE_REPO}:${BASEIMAGE_TAG} AS docs
# Install required packages
RUN --mount=type=cache,rw,target=/cache \
--mount=type=cache,dst=/var/cache/dnf \
--mount=type=cache,dst=/var/cache/libdnf5 \
<<EORUN
set -euo pipefail
set -x
export FORCE_COLUMNS=134
rm --force /etc/yum.repos.d/fedora-cisco-openh264.repo
dnf upgrade --assumeyes --refresh --no-allow-downgrade \
--allowerasing
dnf --refresh install --assumeyes --allowerasing \
--no-allow-downgrade --no-docs --setopt=tsflags=nodocs \
--setopt=install_weak_deps=False --best \
--exclude container-selinux \
nginx
dnf clean all
# rm --recursive --force /tmp/* /var/lib/dnf/* /var/cache/dnf/* /var/log/*
rm --recursive --force /var/lib/dnf/* /var/cache/dnf/* /var/log/*
# Create log directories and symlink to stdout/stderr
mkdir --parents /var/log/nginx
ln --symbolic /dev/stdout /var/log/nginx/access.log
ln --symbolic /dev/stderr /var/log/nginx/error.log
EORUN
# Copy the nginx configuration
COPY build-site-container/nginx.conf /etc/nginx/nginx.conf
# Copy the built site from builder stage to nginx document root
COPY --from=builder /antora/output/en-US /usr/share/nginx/html
COPY build-site-container/run-site-preview.sh /usr/bin/
# Original: FROM ${CHUNKAH_REPO}:${CHUNKAH_TAG} AS chunkah
#
# Commented out (not deleted) rather than replaced outright, since it's the
# simplest way to use chunkah again if this workaround is ever dropped:
# chunkah's own image downgrade-installs an EL10-built rpm-sequoia so it can
# read PQC signatures from EL10 target rootfs's (see coreos/chunkah commit
# 0427ee2ab8668073eab836f9c9f1e94b9966e28d) — but that EL10 build assumes an
# x86-64-v3/AVX2 CPU baseline and crashes with SIGILL on this host's CPU.
# We only rechunk Fedora rootfs's, so we don't need PQC support: extract just
# the chunkah binary and run it against a plain Fedora rootfs instead, which
# uses the stock (Fedora-built) rpm-sequoia. Pinned to fedora-minimal:44 to
# match the base chunkah's own Containerfile builds the binary against, to
# avoid a glibc/openssl ABI mismatch (confirmed: fedora-minimal:45 fails with
# a missing libssl.so.3, since the binary was linked against an older
# OpenSSL). Revisit if/when upstream Fedora's rpm-sequoia gains PQC support
# and chunkah drops this hack, or if we ever need to rechunk EL10 rootfs's.
FROM ${CHUNKAH_TOOL_BASE_IMAGE} AS chunkah-tool
ARG CHUNKAH_REPO=overridden
ARG CHUNKAH_TAG=overridden
RUN <<EORUN
set -xeuo pipefail
export FORCE_COLUMNS=134
dnf --refresh install --assumeyes --allowerasing \
--no-allow-downgrade --no-docs --setopt=tsflags=nodocs \
--setopt=install_weak_deps=False --best \
--exclude container-selinux \
openssl \
zlib
dnf clean all
rm --recursive --force /tmp/* /var/lib/dnf/* /var/cache/dnf/* /var/log/*
EORUN
COPY --from=${CHUNKAH_REPO}:${CHUNKAH_TAG} /usr/bin/chunkah /usr/bin/chunkah
ENV CHUNKAH_ROOTFS=/chunkah
# Rechunk
# - Use more layers (128)
FROM chunkah-tool AS chunkah
RUN --mount=from=docs,src=/,target=/chunkah,ro \
--mount=type=bind,target=/run/src,rw \
chunkah build \
--verbose \
--skip-special-files \
--max-layers 128 \
--output oci:/run/src/chunkah
# Create the final image from the rechunked oci-archive
FROM --after=chunkah oci:chunkah
LABEL org.opencontainers.image.title="Fedora Docs Previews"
LABEL org.opencontainers.image.description="Container image for previewing the Fedora Docs"
LABEL org.opencontainers.image.source="https://forge.fedoraproject.org/docs/docs-fp-o"
LABEL org.opencontainers.image.licenses="MIT"
LABEL quay.expires-after="4w"
EXPOSE 80
STOPSIGNAL SIGQUIT
ENTRYPOINT ["run-site-preview.sh"]