Search code examples
dockerdocfx

How to serve docfx in docker container?


I have tried to build a docker image based on mono to serve a docfx documentation.

Here is my dockerfile code :

FROM mono:latest

#Set environment
ENV DOCFX_VER 2.40.12

COPY entrypoint.sh /

RUN apt-get update \
 && apt-get -y install wget zip \
 && mkdir -p /opt/docfx \
 && wget -q https://github.com/dotnet/docfx/releases/download/v${DOCFX_VER}/docfx.zip \
 && sha512sum docfx.zip \
 && docfx_sha512='11b8bee1079b7a8afcaad0927caaa166553471582d634b30e2392d78c80c012071bded7fd9fa1335782b4194cc42a189737a1985c6dcf2066ce0f872de39b3b6' \
 && echo "$docfx_sha512  docfx.zip" | sha512sum -c - \
 && unzip docfx.zip -d /opt/docfx/ \
 && rm docfx.zip \
 && apt-get -y purge wget zip \
 && rm -rf /var/cache/apt/* \
 && chmod 755 /entrypoint.sh \
 && adduser \
        --uid 1000 \
        --shell /bin/false \
        --no-create-home \
        --gecos "" \
        --disabled-password \
        --disabled-login \
      docfx \
 && chmod 755 /entrypoint.sh
COPY . /doc
USER docfx
EXPOSE 8080
WORKDIR /doc
ENTRYPOINT [ "/entrypoint.sh" ]

The entrypoint.sh is :

#!/bin/sh

set -e

DOCFX_CMD=/opt/docfx/docfx.exe

mono "$DOCFX_CMD" serve -p 8080 . 

The build is done and succeed : docker build -t docfxtest .

When I run the image I get the following :

PS E:\Projects\Moon\US-119\docfx> docker logs 67f6e241ff75
Serving "/doc" on http://localhost:8080
PS E:\Projects\Moon\US-119\docfx>

The container stopped.

I have tested it on docker for windows. As I am still a newbie on docker, I might have missed something. Can someone help me to understand the problem?

My built docker image is availabl there : docker push shoattraceparts/docfxtest:latest

Thanks,


Solution

  • I found this solution, which totally differnt approach. I use the following command

    # Image source
    FROM nginx:alpine
    # Copy static assets into var/www
    COPY _site /usr/share/nginx/html