From 658778cd891d9327a1ce91e6bcbc8fcfd81e7cd6 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 7 Dec 2017 00:08:59 -0800 Subject: Add opnfvdocs build container Currently, rst files only can be built in opnfvdocs project's CI pipeline and feature projects can not verify this before submitting doc files. Feature project can use this container to build its docs without installing any docs tools. JIRA: DOCS-183 Change-Id: I715d19d24da776d76e509309c9010d4072e6f4f8 Signed-off-by: Julien --- docker/Dockerfile | 23 +++++++++++++++++++++++ docker/README.md | 28 ++++++++++++++++++++++++++++ docker/entrypoint.sh | 28 ++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/README.md create mode 100644 docker/entrypoint.sh diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..fe1ff808a --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,23 @@ +FROM ubuntu:14.04 + +MAINTAINER Julien Zhang +LABEL version="0.1" Description="OPNFVDocs Docker container" + +ARG BRANCH=master +ARG build=html +ENV BRANCH=$BRANCH +ENV build=$build + +# Dependencies for sphinx, pip and git +RUN apt-get update && apt-get install -y \ + python-pip python-sphinx git + +RUN git clone --depth=1 --branch=$BRANCH https://git.opnfv.org/opnfvdocs /opnfvdocs +RUN pip install -r /opnfvdocs/etc/requirements.txt +RUN pip install virtualenv +RUN rm -rf /var/lib/apt-lists/* /root/.cache/pip /opnfvdocs/.git + +ADD ./entrypoint.sh /sbin/entrypoint.sh +RUN chmod 755 /sbin/entrypoint.sh + +ENTRYPOINT /sbin/entrypoint.sh diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..c7b119c1b --- /dev/null +++ b/docker/README.md @@ -0,0 +1,28 @@ +# OPNFVDoc tool readme +------------------------ + +This docker container is used for building OPNFV docs from **rst** format files for each feature +project. The output is just like contents in [opnfvdocs](http://docs.opnfv.org/) website. You can +review the contents through web browser. Currently *PDF* output is not good enough and it will make +the container image size 3x larger. PDF output format is not supported in this release. + +# Usage + +* The default build is *html*, you can run: +``` +docker run -it --rm -v ./some-opnfv-repo:/docs -v /tmp/output:/output \ + opnfv/opnfvdocs +``` + +* Then if you want to build epub, etc you could pass it as an arg: +``` +docker run -it --rm -v ./some-opnfv-repo:/docs -v /tmp/output:/output \ + -e build=epub opnfv/opnfvdocs +``` + +## env parameters +* build: [html | singlehtml | epub] + +## two directory parameters +* /docs: **mandatory**, used for source files +* /output: **optional**, used for storing the built result diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 000000000..6982bffa2 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,28 @@ +#!/bin/bash -x + +if [ ! -d /docs ]; then + echo source path /docs not exist and no repo for building + exit 1 +fi + +cd /docs +for item in conf.py _templates _static +do + cp -r /opnfvdocs/docs/$item ./ +done + +# use the same procedure as verify Job +# [TODO]create a common macro can be consumed in Docker and Jenkins +sudo pip install virtualenv +virtualenv $WORKSPACE/venv +. $WORKSPACE/venv/bin/activate +pip install --upgrade pip +pip freeze +pip install tox +tox -edocs + +# copy the building result to host +if [ -d /output ]; then + cp -R ./docs/_build /output +fi + -- cgit 1.2.3-korg