Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 5 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,39 +108,15 @@ jobs:
sudo find /ostree/repo/objects -name '*.file' -type f | while read f; do
sudo fsverity measure $f >/dev/null
done
# Build documentation using mdBook (only for PRs with 'documentation' label)
# TODO move into Justfile
# Test that we can build documentation
docs:
if: ${{ contains(github.event.pull_request.labels.*.name, 'documentation') }}
runs-on: ubuntu-24.04
env:
MDBOOK_VERSION: 0.4.37
steps:
- uses: actions/checkout@v4
- name: Install mdBook
run: |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
mkdir mdbook
curl -sSL $url | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH
- name: Install mdbook-mermaid
run: |
tag=$(curl 'https://api.github.com/repos/badboy/mdbook-mermaid/releases/latest' | jq -r '.tag_name')
url="https://github.com/badboy/mdbook-mermaid/releases/download/${tag}/mdbook-mermaid-${tag}-x86_64-unknown-linux-gnu.tar.gz"
mkdir mdbook-mermaid
curl -sSL $url | tar -xz --directory=./mdbook-mermaid
echo `pwd`/mdbook-mermaid >> $GITHUB_PATH
- name: Install mdbook-linkcheck
run: |
tag=$(curl 'https://api.github.com/repos/Michael-F-Bryan/mdbook-linkcheck/releases/latest' | jq -r '.tag_name')
archive="mdbook-linkcheck.x86_64-unknown-linux-gnu.zip"
url="https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases/download/${tag}/${archive}"
mkdir mdbook-linkcheck
curl -sSL -O $url && unzip ${archive} -d ./mdbook-linkcheck && chmod +x ./mdbook-linkcheck/mdbook-linkcheck
echo `pwd`/mdbook-linkcheck >> $GITHUB_PATH
- name: Build with mdBook
run: cd docs && mdbook-mermaid install && mdbook build
- name: Bootc Ubuntu Setup
uses: ./.github/actions/bootc-ubuntu-setup
- name: Build mdbook
run: just build-mdbook
# Build containers and disk images for integration testing across OS matrix
build-integration:
strategy:
Expand Down
43 changes: 6 additions & 37 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,53 +14,22 @@ concurrency:
group: "pages"
cancel-in-progress: false

# To build the docs locally you can also do e.g.:
# cargo install mdbook-mermaid
# cd docs
# mdbook-mermaid install
# mdbook serve

jobs:
build:
runs-on: ubuntu-latest
env:
MDBOOK_VERSION: 0.4.37
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install mdBook
run: |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
mkdir mdbook
curl -sSL $url | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH
- name: Install mdbook-mermaid
run: |
tag=$(curl 'https://api.github.com/repos/badboy/mdbook-mermaid/releases/latest' | jq -r '.tag_name')
url="https://github.com/badboy/mdbook-mermaid/releases/download/${tag}/mdbook-mermaid-${tag}-x86_64-unknown-linux-gnu.tar.gz"
mkdir mdbook-mermaid
curl -sSL $url | tar -xz --directory=./mdbook-mermaid
echo `pwd`/mdbook-mermaid >> $GITHUB_PATH
- name: Install mdbook-linkcheck
run: |
tag=$(curl 'https://api.github.com/repos/Michael-F-Bryan/mdbook-linkcheck/releases/latest' | jq -r '.tag_name')
archive="mdbook-linkcheck.x86_64-unknown-linux-gnu.zip"
url="https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases/download/${tag}/${archive}"
mkdir mdbook-linkcheck
curl -sSL -O $url && unzip ${archive} -d ./mdbook-linkcheck && chmod +x ./mdbook-linkcheck/mdbook-linkcheck
echo `pwd`/mdbook-linkcheck >> $GITHUB_PATH
- name: Bootc Ubuntu Setup
uses: ./.github/actions/bootc-ubuntu-setup
- name: Build mdbook
run: mkdir target && just build-mdbook-to target/docs
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Install mdbook_header_footer
run: |
cargo install mdbook_header_footer
- name: Build with mdBook
run: cd docs && mdbook-mermaid install && mdbook build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./docs/book/html
path: ./target/docs

deploy:
environment:
Expand Down
18 changes: 18 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ test-container: build-units build-integration-test-image
podman run --rm --read-only localhost/bootc-units /usr/bin/bootc-units
podman run --rm localhost/bootc-integration bootc-integration-tests container

build-mdbook:
cd docs && podman build -t localhost/bootc-mdbook -f Dockerfile.mdbook

# Generate the rendered HTML to the target DIR directory
build-mdbook-to DIR: build-mdbook
#!/bin/bash
set -xeuo pipefail
# Create a temporary container to extract the built docs
container_id=$(podman create localhost/bootc-mdbook)
podman cp ${container_id}:/src/book {{DIR}}
podman rm -f ${container_id}

mdbook-serve: build-mdbook
#!/bin/bash
set -xeuo pipefail
podman run --init --replace -d --name bootc-mdbook --rm --publish 127.0.0.1::8000 localhost/bootc-mdbook
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The mdbook-serve recipe is great for local development. However, as it is currently written, it doesn't mount the local source code into the container. This means that mdbook serve's live-reloading feature won't work for changes made on the host. To provide a better local development experience, consider mounting the docs directory into the container. This will allow mdbook to watch for file changes and automatically rebuild the documentation.

Note the :Z flag is added for SELinux compatibility, which is good practice when using Podman.

    podman run --init --replace -d --name bootc-mdbook --rm --publish 127.0.0.1::8000 -v ./docs:/src:Z localhost/bootc-mdbook

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I may change this later

echo http://$(podman port bootc-mdbook 8000/tcp)

# Update all generated files (man pages and JSON schemas)
#
# This is the unified command that:
Expand Down
33 changes: 33 additions & 0 deletions docs/Dockerfile.mdbook
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM registry.access.redhat.com/ubi10/ubi:latest
# An intermediate layer which caches the RPMS
RUN <<EORUN
set -xeuo pipefail
dnf -y install cargo rust jq unzip
dnf clean all
EORUN
# See main Dockerfile for rust caching
RUN --mount=type=cache,target=/src/target --mount=type=cache,target=/var/roothome <<EORUN
set -xeuo pipefail

# Bootstrap cargo-binstall
export PATH=$HOME/.cargo/bin:$PATH
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash

deps=(mdbook@0.4.52
mdbook-mermaid@0.16.0
mdbook-linkcheck@0.7.7
mdbook_header_footer@0.0.3)
cargo binstall --no-confirm ${deps[@]}
mv ~/.cargo/bin/* /usr/bin/

EORUN
# And now actually build the docs
WORKDIR /src
COPY . /src
RUN <<EORUN
set -xeuo pipefail
mdbook-mermaid install .
mdbook build
EORUN
CMD ["mdbook", "serve", "-n", "0.0.0.0", "-p", "8000"]
EXPOSE 8000
3 changes: 0 additions & 3 deletions docs/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,3 @@ footers = [

[output.html]
additional-js = ["mermaid.min.js", "mermaid-init.js"]

[output.linkcheck]
optional = true