We use AsciiDoc as the format for our documentation for the user group project. AsciiDoc is a bit like Markdown, but it supports multi-file documents out of the box and without any quirks.
We use the Ruby app Asciidoctor to turn our AsciiDoc files into a PDF as part of our build job. Since building the whole application takes time, it is not the fastest way to get feedback when we write the documentation. To shorten the feedback cycle, we put Asciidoctor into a development container to create the PDF whenever we want to check something.
Create a Gem file
In the Ruby Gemfile, we can put all the packages we need to generate our documentation:
1 2 3 4 |
source 'https://rubygems.org' gem 'asciidoctor' gem 'asciidoctor-pdf' gem 'asciidoctor-diagram' |
Create a Dockerfile
For the Dockerfile we used the template I documented in this post on dev containers for Ruby apps. We use the newer Debian release and do not care much about specific versions of Ruby or Bundler:
1 2 3 4 5 6 7 8 9 10 |
FROM ruby:slim-bookworm RUN apt-get update -qq WORKDIR /workspace COPY Gemfile /workspace/Gemfile RUN gem install bundler RUN bundle install |
Create a Docker Compose file
The configuration for Docker Compose may be a bit overhead, but it allows us to set the path for our volume correctly and now is everything in place should we need to add another container.
1 2 3 4 5 6 7 8 9 10 11 12 |
version: "3.2" services: app: build: context: . dockerfile: Dockerfile volumes: - type: bind source: ../../. target: /workspace working_dir: /workspace command: sh -c 'while true; do sleep 30; done' |
Start the container
We can now start our dev container with this command:
1 |
docker-compose up |
From time to time, you should rebuild your container to run apt-get update with this command:
1 |
docker-compose build --no-cache |
Generate the documentation
We can now open a Terminal inside Docker for Windows and run this command inside our container:
1 |
asciidoctor-pdf -a toc -b pdf arc42-template.adoc |
This generates us the PDF file and we can use the Windows Explorer (outside of the container) to check if the PDF file is correct. To not always type this command, we put that into a CreateDocumentation.sh file.
Conclusion
With the help of our new development container, we can run Asciidoctor without the need to install Ruby or wait on the build agent. This allows us a much faster feedback cycle in which we can keep the momentum to write our documentation.
I did not expect that the faster cycle would make much difference but let me tell you that it is like day and night. Therefore, I can strongly advise you to take that hour it took me to build the container with all the right dependencies and automate that part of your workflow – it is worth it.