Multi-stage Alpine build to provide Doxygen with git and Graphviz.
149
A lightweight, high-performance Docker image for generating Doxygen documentation. This image uses a multi-stage Alpine build to provide a minimal runtime environment including Graphviz for generating call graphs and inheritance diagrams.
# =========================
# Builder stage
# =========================
FROM alpine:latest AS builder
ARG DOXYGEN_REF=master
RUN apk add --no-cache \
build-base \
cmake \
python3 \
flex \
bison \
git
WORKDIR /src
# Clone official repository
RUN git clone --depth 1 \
--branch ${DOXYGEN_REF} \
https://github.com/doxygen/doxygen.git .
# Configure + build + install
RUN cmake -S . -B build \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/doxygen \
&& cmake --build build -j"$(nproc)" \
&& cmake --install build
# =========================
# Runtime stage
# =========================
FROM alpine:latest
RUN apk add --no-cache \
git \
graphviz \
libstdc++
COPY --from=builder /opt/doxygen /opt/doxygen
ENV PATH="/opt/doxygen/bin:${PATH}"
WORKDIR /workspace
# This allows the container to run doxygen by default,
# but makes it much easier to override with a shell script.
CMD ["doxygen"]
Run this command in your project root to generate documentation using your existing Doxyfile:
docker run --rm -v $(pwd):/workspace <your-username>/doxygen
HAVE_DOT = YES to generate SVG/PNG diagrams.If your configuration file is named differently (e.g., Doxyfile.ci):
docker run --rm -v $(pwd):/workspace <your-username>/doxygen Doxyfile.ci
Add this to your docker-compose.yml for a standardized local build environment:
services:
docs:
image: <your-username>/doxygen
volumes:
- .:/workspace
# Overriding the entrypoint for complex scripts
entrypoint: /bin/sh
command: -c "doxygen Doxyfile && echo 'Docs built!'"
The image uses /workspace as the default working directory. Ensure you map your project root to this path:
Doxyfile.OUTPUT_DIRECTORY in the Doxyfile points to a path within the mapped volume (e.g., ./docs) to persist the files on your host.docker build -t <your-username>/doxygen .
When you go to your repository on Docker Hub:
latest for your main build, but consider tagging versions (e.g., 1.10.0-alpine) so users can have reproducible builds.Content type
Image
Digest
sha256:9ecf2f1db…
Size
32.6 MB
Last updated
5 months ago
docker pull ruseler/doxygen:alpine