Add opnfvdocs build container 07/48507/5
authorJulien <zhang.jun3g@zte.com.cn>
Thu, 7 Dec 2017 08:08:59 +0000 (00:08 -0800)
committerJulien <zhang.jun3g@zte.com.cn>
Tue, 6 Feb 2018 11:11:54 +0000 (19:11 +0800)
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 <zhang.jun3g@zte.com.cn>
docker/Dockerfile [new file with mode: 0644]
docker/README.md [new file with mode: 0644]
docker/entrypoint.sh [new file with mode: 0644]

diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644 (file)
index 0000000..fe1ff80
--- /dev/null
@@ -0,0 +1,23 @@
+FROM ubuntu:14.04
+
+MAINTAINER Julien Zhang <julienjut@gmail.com>
+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 (file)
index 0000000..c7b119c
--- /dev/null
@@ -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 (file)
index 0000000..6982bff
--- /dev/null
@@ -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
+