Skip to content

Commit 60c89d4

Browse files
committed
#369 Add documentation for Docker run
1 parent 51caf18 commit 60c89d4

1 file changed

Lines changed: 92 additions & 4 deletions

File tree

htmlSanityCheck-cli/README.adoc

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,48 @@ The Command Line Interface (CLI) module of HTML Sanity Check (xref:{xrefToManual
1717

1818
== Installation (Command Line Interface)
1919

20-
=== Prerequisites
20+
You can run HSC on your machine
21+
22+
* As a <<sec:java-usage,Java application>>{nbsp}->{nbsp}<<sec:java-installation>>, or
23+
* As a <<sec:container-usage,Container>>{nbsp}->{nbsp}<<sec:container-installation>>, or
24+
25+
26+
[[sec:java-installation]]
27+
=== Java Installation
28+
29+
==== Prerequisites
2130

2231
The HSC CLI needs Java 8 (`java` executable) or higher on the respective OS search path (`+${PATH}+` on Linux/macOS, `%path%` on Windows).
2332

24-
=== SDKMAN
33+
==== SDKMAN
2534

2635
If you use https://sdkman.io[SDKMAN], you can install HSC as SDKMAN candidate: `sdk install hsc`.
2736

28-
=== Download
37+
==== Download
2938

30-
Alternatively,
39+
Alternatively, you can download and unpack the CLI release:
3140

3241
* Download the HSC CLI from the https://github.com/aim42/htmlSanityCheck/releases[release{nbsp}page].
3342
* Unpack the file in a convenient place, e.g., `/usr/local/hsc`.
43+
* Add the unpacked bin directory to your path, e.g. (for Unix), `+PATH=${PATH}:/usr/local/hsc/bin+`.
44+
45+
[[sec:container-installation]]
46+
=== Container (Docker) Installation
47+
48+
Alternatively, you can use a local Container runtime (such as https://www.docker.com/[Docker] or https://podman.io/[Podman]) and execute HSC as a container.
49+
In this case, no prelminary installation is necessary (except for the container runtime) you can directly <<sec:container-usage,run HSC>>.
50+
51+
[NOTE]
52+
====
53+
While HSC supports both Docker and Podman as container runtimes, our examples and automated tests currently only use Docker.
54+
The commands should work similarly with Podman by replacing `docker` with `podman` in the examples.
55+
====
3456

3557
== Usage
3658

59+
[[sec:java-usage]]
60+
=== Java usage
61+
3762
Execute the CLI tool with the following command.
3863
If the `sourceDirectory` is omitted, HSC uses the current directory as base-directory to search for HTML files.
3964

@@ -51,6 +76,69 @@ Windows::
5176
hsc.bat [ options ] [ sourceDirectory ]
5277
----
5378

79+
[[sec:container-usage]]
80+
=== Using the Container image
81+
82+
You can run HSC without installing Java or the CLI by using the Container image published at the GitHub Container Registry:
83+
`ghcr.io/aim42/hsc`.
84+
85+
Unix (shell) example (Linux/macOS)::
86+
+
87+
[source,sh]
88+
----
89+
# Assume your HTML files are under ./docs and you want the report under ./build/reports
90+
docs_dir="${PWD}/docs"
91+
reports_dir="${PWD}/build/reports"
92+
mkdir -p "$reports_dir"
93+
94+
# Run the Docker image, mount the docs and a host reports directory, and set the working directory
95+
docker run --rm \
96+
-v "${docs_dir}:${docs_dir}" \
97+
-v "${reports_dir}:/reports" \
98+
-w "${docs_dir}" \
99+
ghcr.io/aim42/hsc:latest \
100+
-r /reports
101+
----
102+
103+
Add options as necessary (example)::
104+
+
105+
[source,sh]
106+
----
107+
# Exclude some external links via regex and restrict checked suffixes
108+
docker run --rm \
109+
-v "$docs_dir:$docs_dir" \
110+
-v "$reports_dir:/reports" \
111+
-w "$docs_dir" \
112+
ghcr.io/aim42/hsc:latest \
113+
-r /reports \
114+
--exclude https://www.example.com/.* \
115+
--suffix html,htm
116+
----
117+
118+
Windows PowerShell example::
119+
+
120+
[source,powershell]
121+
----
122+
$DocsDir = (Resolve-Path ./docs).Path
123+
$ReportsDir = (Resolve-Path ./build/reports).Path
124+
New-Item -Force -ItemType Directory $ReportsDir | Out-Null
125+
126+
docker run --rm `
127+
-v "$DocsDir`:$DocsDir" `
128+
-v "$ReportsDir`:/reports" `
129+
-w "$DocsDir" `
130+
ghcr.io/aim42/hsc:latest `
131+
-r /reports
132+
----
133+
134+
Notes::
135+
136+
* The container entrypoint simply invokes the CLI (`java -jar /hsc.jar`) and forwards all arguments, so you can pass the same options as described below.
137+
* Reports will be written to the directory you mount at `/reports` when using `-r /reports`.
138+
* Tags: use `:latest` for the latest released image.
139+
Development builds may also be available using branch-name tags (used in integration tests).
140+
* The integration test `integration-test/build.gradle` contains a full working example of the Docker invocation used in CI.
141+
54142
=== Options
55143

56144
The CLI tool exposes a few options as part of its configuration:

0 commit comments

Comments
 (0)