This repository contains a simple Containerfile that defines a container image including asciidoctor
and asciidoctor-pdf
to render AsciiDoc content as HTML or PDF, respectively.
The files in this repository serve as a simple example of how to write a Containerfile which can perform more than one task with the same overall goal: rendering AsciiDoc content.
In the directory containing this repository, run the following command to generate a local container image:
$ podman build -f Containerfile -t adoc
This command will create a local container image tagged as localhost/adoc
.
Alternatively, use the Makefile:
$ make container
This container can generate HTML or PDF output for AsciiDoc files once the container image has been generated.
In order to access AsciiDoc files contained on the host machine, we must mount a directory containing AsciiDoc files from the host machine into the file system of the container. The Containerfile defines a volume mount in /docs on the container. To generate output of an AsciiDoc file in the current directory on your host machine, mount the absolute path to the host directory as /docs in the container.
To generate output of the given AsciiDoc file within the mounted directory:
$ podman run --rm -v $(pwd):/docs adoc [html,pdf] README.adoc
Replace [html,pdf]
with either html
or pdf
for the desired output format.
Alternatively, use the Makefile:
$ make [html,pdf,all]
To understand how all of this runs and works together, please see each file in this repository and how it is configured.
The core idea is to configure the runtime for the container image in the Containerfile and encapsulate the logic for switching output formats in entrypoint.sh. Note that the entrypoint is written on the host machine and copied into the container as /sbin/entrypoint.sh.
And remember: have fun!