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 ?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.