Skip to content

Commit f6be9fb

Browse files
committed
Build documentation in a container on Win arm64
Locally building the windows installer requires to build the documentation. And building documentation requires Pandoc. There is no pre-built binaries for Windows arm64 and this makes it complicated to build the Podman Windows installer on Windows arm64. To unlock this scenario we are adding a new winmake.ps1 target to build the documentation in a container (where Pandoc is pre-installed). Signed-off-by: Mario Loriedo <[email protected]>
1 parent bc81470 commit f6be9fb

File tree

3 files changed

+75
-10
lines changed

3 files changed

+75
-10
lines changed

build_windows.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,19 @@ reloaded. This can also be manually changed by configuring the `PATH`:
5959
$env:Path += ";C:\Program Files\Go\bin\;C:\Program Files\Git\cmd\"
6060
```
6161

62-
### Pandoc
62+
### Pandoc (optional)
6363

6464
[Pandoc](https://pandoc.org/) is used to generate Podman documentation. It is
65-
required for building the documentation and the
66-
[bundle installer](#build-the-installer). It can be avoided when building and
67-
testing the
68-
[Podman client for Windows](#build-and-test-the-podman-client-for-windows) or
69-
[the standalone `podman.msi` installer](#build-and-test-the-standalone-podmanmsi-file).
65+
used for building the documentation.
7066
Pandoc can be installed from https://pandoc.org/installing.html. When performing
7167
the Pandoc installation one, has to choose the option "Install for all users"
7268
(to put the binaries into "Program Files" directory).
69+
Alternatively, Podman documentation can be built using a container with the target
70+
`docs-using-podman` in the `winmake.ps1` script.
71+
72+
```pwsh
73+
.\winmake docs-using-podman
74+
```
7375

7476
### .NET SDK
7577

@@ -326,7 +328,7 @@ To build the installation bundle, run the following command:
326328
.\winmake.ps1 installer
327329
```
328330

329-
:information_source: making `podman-remote`, `win-gvproxy`, and `docs` is
331+
:information_source: making `podman-remote`, `win-gvproxy`, and `docs` (or `docs-using-podman`) is
330332
required before running this command.
331333

332334
Locate the installer in the `contrib\win-installer` folder (relative to checkout

docs/Containerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The resulting image can be used to generate podman-remote documentation.
2+
#
3+
# The CMD expects that the podman git repository is bind mounted to /podman.
4+
# The generated documentation will be copied to ./docs/build/remote/.
5+
#
6+
# Example usage:
7+
# podman build --build-arg TARGET_OS=windows -t podman-docs-generator $(pwd)/docs
8+
# podman run --rm -v $(pwd):/podman podman-docs-generator
9+
#
10+
FROM docker.io/golang:latest
11+
ARG TARGET_OS=windows # valid values: macos, linux, windows
12+
RUN apt-get update && apt-get install -y pandoc man
13+
RUN mkdir -p /podman-copy/podman
14+
ENV TARGET_OS=$TARGET_OS
15+
WORKDIR /podman-copy/podman
16+
CMD echo "Copying /podman/ to /podman-copy/. It will take some time but 1) the build will be faster 2) the local bin folder won't be overridden." && \
17+
cp -a /podman/ /podman-copy/ && \
18+
echo "Generating docs" && make podman-remote-${TARGET_OS}-docs && \
19+
echo "Copying generated docs to /podman/" && mkdir -p /podman/docs/build/ && \
20+
mkdir -p /podman/docs/build/remote/ && \
21+
cp -a /podman-copy/podman/docs/build/remote/${TARGET_OS}/* /podman/docs/build/remote/

winmake.ps1

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ function Installer{
9696
$requiredArtifacts | ForEach-Object {
9797
if (!(Test-Path -Path $PSItem -PathType Leaf)) {
9898
Write-Host "$PSItem not found."
99-
Write-Host "Make 'podman', 'win-gvproxy' and 'docs' before making the installer:"
99+
Write-Host "Make 'podman', 'win-gvproxy' and 'docs' (or 'docs-using-podman') before making the installer:"
100100
Write-Host " .\winmake.ps1 podman-remote"
101101
Write-Host " .\winmake.ps1 win-gvproxy"
102-
Write-Host " .\winmake.ps1 docs"
102+
Write-Host " .\winmake.ps1 docs or .\winmake.ps1 docs-using-podman"
103103
Exit 1
104104
}
105105
}
@@ -159,6 +159,7 @@ function Documentation{
159159
# Check that pandoc is installed
160160
if (!(Get-Command -Name "pandoc" -ErrorAction SilentlyContinue)) {
161161
Write-Host "Pandoc not found. Pandoc is required to convert the documentation Markdown files into HTML files."
162+
Write-Host "Alternatively, use '.\winmake docs-using-podman' to use a container to run pandoc and generate the documentation."
162163
Exit 1
163164
}
164165
# Check that the podman client is built
@@ -170,6 +171,41 @@ function Documentation{
170171
Run-Command "$PSScriptRoot\docs\make.ps1 $podmanClient"
171172
}
172173

174+
# DocumentationUsingPodman generates documentation with pandoc running in a container.
175+
# This is usefult on Windows arm64 where pandoc is not available.
176+
# It's also useful to generate documentation identical to CI.
177+
# It requires the podman client to be built and a podman machine running.
178+
# The whole podman git repository is bind mounted in the container at /podman.
179+
# The documentation is generated by running the command `make podman-remote-windows-docs`.
180+
# The generated documentation is stored in the directory docs/build/remote.
181+
function DocumentationUsingPodman{
182+
Write-Host "Generating documentation artifacts"
183+
# Check that podman has been built
184+
$podmanClient = "${PSScriptRoot}\bin\windows\podman.exe"
185+
if (!(Test-Path -Path $podmanClient -PathType Leaf)) {
186+
Write-Host "$podmanClient not found. Make 'podman-remote' before 'documentation'."
187+
Exit 1
188+
}
189+
# Check that a podman machine exist
190+
$currentMachine = (& ${podmanClient} machine info -f json | ConvertFrom-Json).Host.CurrentMachine
191+
if (!$currentMachine) {
192+
Write-Host "Podman machine doesn't exist. Initialize and start one before running the validate script."
193+
Exit 1
194+
}
195+
# Check that the podman machine is running
196+
$state = (& ${podmanClient} machine info -f json | ConvertFrom-Json).Host.MachineState
197+
if ($state -ne "Running") {
198+
Write-Host "Podman machine is not running. Start the machine before running the validate script."
199+
Exit 1
200+
}
201+
202+
Write-Host "Building the image to generate the documentation"
203+
Run-Command "${podmanClient} build --build-arg TARGET_OS=windows -t podman-docs-generator ${PSScriptRoot}/docs"
204+
205+
Write-Host "Starting the container to run the documentation build"
206+
Run-Command "${podmanClient} run -t --rm -v ${PSScriptRoot}:/podman podman-docs-generator"
207+
}
208+
173209
function Validate{
174210
$podmanExecutable = "podman"
175211
$podmanSrcVolumeMount = "${PSScriptRoot}:/go/src/github.com/containers/podman"
@@ -329,6 +365,9 @@ switch ($target) {
329365
'docs' {
330366
Documentation
331367
}
368+
'docs-using-podman' {
369+
DocumentationUsingPodman
370+
}
332371
'validatepr' {
333372
Validate
334373
}
@@ -359,9 +398,12 @@ switch ($target) {
359398
Write-Host "Example: Run windows installer tests"
360399
Write-Host " .\winmake installertest hyperv"
361400
Write-Host
362-
Write-Host "Example: Generate the documetation artifacts"
401+
Write-Host "Example: Generate the documentation artifacts"
363402
Write-Host " .\winmake docs"
364403
Write-Host
404+
Write-Host "Example: Generate the documentation artifacts by running pandoc in a container"
405+
Write-Host " .\winmake docs-using-podman"
406+
Write-Host
365407
Write-Host "Example: Validate code changes before submitting a PR"
366408
Write-Host " .\winmake validatepr"
367409
Write-Host

0 commit comments

Comments
 (0)