FlexDoc/XML - Generator

Running in Docker

Docker is a tool that is used to automate the deployment of applications in lightweight containers so that applications can work efficiently in different environments in isolation. A Docker container is essentially a specialized implementation of Linux. Almost every major distribution of Linux currently supports a version for Docker.

For more information, please see: docker.com The further explanation assumes that you have Docker already installed on your system, for instance the Docker Desktop.

See also: FlexDoc/XML | DiagramKit | FAQ | Generator Setups | Running with Docker

Example Goal

When you have FlexDoc/XML installed on your computer, you can immediately run XSDDoc to generate a demo XML Schema documentation.

Under Windows, that can be done simply by running:

{flexdoc-xml}/XSDDoc/run/generator.bat
All generator settings will be loaded from the generator.config via the main configuration file prepared for XSDDoc:
{flexdoc-xml}/config/generator.config
{flexdoc-xml}/config/flexdoc.config
So, to pick everything only that flexdoc.config must be specified to the generator directly on the command line with the -flexdocconfig option.

A Windows batch file that launches such a generation looks as follows:

set  FDH=C:\flexdoc-xml
set  MP=%FDH%\lib\flexdoc-xml.jar;%FDH%\lib\xercesImpl.jar
java  -Xmx2048m --module-path %MP% --module flexdoc.xml/xyz.flexdoc.xml.Generator -flexdocconfig %FDH%\XSDDoc\config\flexdoc.config
The result generated documentation will be found in the folder:
{flexdoc-xml}/out
according to what is specified in the generator.config.

Now, let's see how to do the same in Docker.

Building Docker Image

First, we need to prepare a Dockerfile:

Dockerfile

# Basic Docker image to run Java applications. It is based on AlpineLinux, one of the smallest that exists.
FROM alpine/java:22-jre

# Copy everything necessary to run the XSDDoc demo into '/flexdoc-xml/' folder inside the Docker container's file system
COPY ["lib", "/flexdoc-xml/lib/"]
COPY ["XSDDoc/templates", "/flexdoc-xml/XSDDoc/templates"]
COPY ["XSDDoc/config", "/flexdoc-xml/XSDDoc/config"]
COPY ["XSDDoc/demo", "/flexdoc-xml/XSDDoc/demo"]

# Launching the FlexDoc/XML Generator
ENTRYPOINT ["java", "-Xms2048m", "-Xmx4096m", \
  "--module-path", "/flexdoc-xml/lib/flexdoc-xml.jar:/flexdoc-xml/lib/xercesImpl.jar", \
  "--module", "flexdoc.xml/xyz.flexdoc.xml.Generator", \
  "-flexdocconfig", "/flexdoc-xml/XSDDoc/config/flexdoc.config", \
  "-d", "/flexdoc-xml/out"]

Then, build the Docker image with the following command (on Windows) run in same folder as the Dockerfile:

docker build -f Dockerfile -t xsddoc C:\flexdoc-xml
where
  • 'xsddoc' is the tag name of the result image, by which it can be referenced later
  • the last argument 'C:\flexdoc-xml' is the build context, a location against which the Dockerfile is interpreted

Running Docker Image

The result Docker image can be run with a simple command:
docker run -it xsddoc
However, the generated XML Schema documentation will remain inside the Docker. So, while running everything on Windows, we need to get it somehow from Docker into the Windows local file system.

That can be done with the Docker volume that maps the Docker's folder with the result documentation:

/flexdoc-xml/out
onto the Windows folder:
C:\flexdoc-xml\out
So, the final command to run XSDDoc inside Docker will the following:
docker run -v C:\flexdoc-xml\out:/flexdoc-xml/out -it xsddoc