1

I'm trying to generate a Doxygen documentation in a Dockerfile using a Docker-compose to run all the services at the same time.

The goal is to generate the documentation in the container and to retrieve the generated files in local.

Here is my Dockerfile:

FROM ubuntu:latest

RUN apt-get update -y
RUN apt-get install -y doxygen doxygen-gui doxygen-doc graphviz

WORKDIR /doc

COPY Doxyfile .
COPY logo.png .

RUN doxygen Doxyfile

Here is the docker-compose with the doc service:

version: "3"

services:
  doc:
    build: ./doc
    volumes:
      - ./documentation:/doc

The doc is generated on the container and a new directory named "documentation" is generated but it is empty. How can I solve it to be filled with the generated documentation from the container ?

Hugo Sohm
  • 2,872
  • 4
  • 23
  • 40
  • If you change that `RUN` with a `CMD`, and you re-build, does it behave like you expect? – Federkun Mar 01 '20 at 16:55
  • 1
    The problem is not the command, the doc is well generated in `Docker`. The problem is the volume, the `doc` folder in the container does not appear in local. – Hugo Sohm Mar 01 '20 at 17:51
  • `RUN` run on build, `CMD` run when you start the container. In the first case your volume is not mounted yet, because is building the image. With `CMD`, it run after the volume is mounted. Can you humour me and try it before we look at other causes, so we can exclude it? – Federkun Mar 01 '20 at 18:00
  • 1
    I already tried your solution but it doesn't works for me. Here is the error output: `error: configuration file Doxyfile not found!` – Hugo Sohm Mar 01 '20 at 18:28
  • Try moving the Doxyfile file into the `./documentation` folder – Federkun Mar 01 '20 at 18:38

1 Answers1

1

The goal is to generate the documentation in the container and to retrieve the generated files in local.

You use a local directory as source of the mount here : - ./documentation:/doc.
It will make the /doc directory on the container to be synchronized with the ./documentation on the host but the source of the content is the host, not the container.
To get generated files on the host you can use a named volume instead of :

volumes:
   - documentation-doxygen:/doc

After the container run you could get more information on that volume (location among other things) with docker volume inspect documentation-doxygen.

But if you mount the volume only to get the created folder, I think that you don't need to use volume at all.
A straighter alternative is simply doing the copy of the folder on the host after the container run :

docker copy DOC_CONTAINER_ID:/doc ./documentation-doxygen  

As another alternative, if you want to execute doxygen Doxyfile in a local context in terms of folder but in a container (possible way in local env), you could replace RUN BY CMD or ENTRYPOINT to execute it as the container startup command and mount the current directory as a bind mount.
It will spare you some copies in the Dockerfile.

FROM ubuntu:latest

RUN apt-get update -y
RUN apt-get install -y doxygen doxygen-gui doxygen-doc graphviz

WORKDIR /doc

# REMOVE THAT COPY Doxyfile .
# REMOVE THAT COPY logo.png .

ENTRYPOINT doxygen Doxyfile

And the docker-compose part :

version: "3"

services:
  doc:
    build: ./doc
    volumes:
      - ./:/doc

Here ./is specified to use as bind source the base directory of the context of the doc service.

davidxxx
  • 125,838
  • 23
  • 214
  • 215