From f0f36699e890082bed813b4164dff911ca3fecae Mon Sep 17 00:00:00 2001 From: "Simental Magana, Marcos" Date: Wed, 24 Aug 2016 11:49:46 -0500 Subject: [PATCH] Add ciao-webui container files This commit add the `Dockerfile` and other files needed in order to build a docker image of the ciao-webui dashboard Signed-off-by: Simental Magana, Marcos --- ciao-webui/Dockerfile | 18 +++++++++++++ ciao-webui/README.md | 54 +++++++++++++++++++++++++++++++++++++ ciao-webui/bootstrap.sh | 48 +++++++++++++++++++++++++++++++++ ciao-webui/ciao_config.json | 24 +++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 ciao-webui/Dockerfile create mode 100644 ciao-webui/README.md create mode 100755 ciao-webui/bootstrap.sh create mode 100644 ciao-webui/ciao_config.json diff --git a/ciao-webui/Dockerfile b/ciao-webui/Dockerfile new file mode 100644 index 0000000..9acdf59 --- /dev/null +++ b/ciao-webui/Dockerfile @@ -0,0 +1,18 @@ +FROM clearlinux +MAINTAINER marcos.simental.magana@intel.com + +ARG WEBUI_VERSION=1.2.8.14 + +ARG swupd_args + +RUN swupd bundle-add network-basic nodejs-basic $swupd_args + +RUN mkdir -p /etc/ciao-webui +COPY ciao_config.json /etc/ciao-webui +COPY bootstrap.sh /usr/bin/bootstrap.sh + +RUN curl -LOk https://github.com/01org/ciao-webui/archive/v${WEBUI_VERSION}.tar.gz +RUN tar xf v${WEBUI_VERSION}.tar.gz +RUN mv ciao-webui-${WEBUI_VERSION} ciao-webui + +CMD '/usr/bin/bootstrap.sh' diff --git a/ciao-webui/README.md b/ciao-webui/README.md new file mode 100644 index 0000000..8c380b8 --- /dev/null +++ b/ciao-webui/README.md @@ -0,0 +1,54 @@ +Ciao webui +========== +[![](https://images.microbadger.com/badges/image/clearlinux/ciao-webui.svg)](http://microbadger.com/images/clearlinux/ciao-webui "Get your own image badge on microbadger.com") +[![](https://images.microbadger.com/badges/version/clearlinux/ciao-webui.svg)](http://microbadger.com/images/clearlinux/ciao-webui "Get your own version badge on microbadger.com") + +This provides a ciao web dashboard container + +Build +----- +``` + docker build -t clearlinux/ciao-webui . +``` + +Or just pull it from Dockerhub +------------------------------ +``` + docker pull clearlinux/ciao-webui +``` +Create Ciao-webui SSL certificates +---------------------------------- +``` + YOUR_HOST=`hostname -f` + + openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout webui_key.pem \ + -out webui_cert.pem -subj "/CN=$YOUR_HOST" +``` + +Run the Ciao-webui Container +---------------------------- +``` + docker run -v `pwd`/webui_key.pem:/etc/pki/ciao-webui-key.pem \ + -v `pwd`/webui_cert.pem:/etc/pki/ciao-webui-cert.pem \ + -e CONTROLLER_HOST=controller.example.com \ + -e IDENTITY_HOST=keystone.example.com \ + -p 443:443 -d clearlinux/ciao-webui +``` + +Environment Variables +--------------------- +- ``IDENTITY_HOST`` + Identity (Keystone) host +- ``CONTROLLER_HOST`` + Controller (ciao-controller) host +- ``CERT_PASS`` + Passprhase for the ciao-webui certificate +- ``MODE`` + Ciao-webui deployment mode (production|development) + default is `production` + +Extra Build ARGs +---------------- +- ``swupd_args`` Specifies [SWUPD](https://clearlinux.org/documentation/swupdate_how_to_run_the_updater.html) flags + +Default build args in Docker are on: https://docs.docker.com/engine/reference/builder/#/arg diff --git a/ciao-webui/bootstrap.sh b/ciao-webui/bootstrap.sh new file mode 100755 index 0000000..9cb1d8b --- /dev/null +++ b/ciao-webui/bootstrap.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +NODE_ENV=$MODE +CONTROLLER_HOST=$CONTROLLER_HOST +IDENTITY_HOST=$IDENTITY_HOST +CERT_PASS=$CERT_PASS + +_usage(){ + >&2 echo "usage:" + >&2 echo " $ docker run -v /path/to/ciao-webui-key.pem:/etc/pki/ciao-webui-key.pem \\" + >&2 echo " -v /path/to/ciao-webui-cert.pem:/etc/pki/ciao-webui-cert.pem \\" + >&2 echo " -e CONTROLLER_HOST=controller.example.com \\" + >&2 echo " -e IDENTITY_HOST=keystone.example.com \\" + >&2 echo "(optional: -e CERT_PASS=certificate_passphrase )" +} + +if [[ -z $MODE ]] ; then + NODE_ENV="production" +fi + +if [[ -z $CONTROLLER_HOST || -z $IDENTITY_HOST ]] ; then + >&2 echo -e "missing CONTROLLER_HOST or IDENTITY_HOST arguments\n" + _usage + exit +fi + +if [[ ! -r /etc/pki/ciao-webui-key.pem ]] ; then + >&2 echo -e "missing /etc/pki/ciao-webui-key.pem\n" + _usage + exit +fi + +if [[ ! -r /etc/pki/ciao-webui-cert.pem ]] ; then + >&2 echo -e "missing /etc/pki/ciao-webui-cert.pem\n" + _usage + exit +fi + +sed -i.bak s/##MODE##/$NODE_ENV/g /etc/ciao-webui/ciao_config.json +sed -i.bak s/##CONTROLLER_HOST##/$CONTROLLER_HOST/g /etc/ciao-webui/ciao_config.json +sed -i.bak s/##KEYSTONE_HOST##/$IDENTITY_HOST/g /etc/ciao-webui/ciao_config.json +sed -i.bak s/##CERT_PASS##/$CERT_PASS/g /etc/ciao-webui/ciao_config.json + +ln -sf /etc/ciao-webui/ciao_config.json /ciao-webui/config/ciao_config.json + +cd /ciao-webui +export PORT=443 +./deploy.sh $NODE_ENV diff --git a/ciao-webui/ciao_config.json b/ciao-webui/ciao_config.json new file mode 100644 index 0000000..988275d --- /dev/null +++ b/ciao-webui/ciao_config.json @@ -0,0 +1,24 @@ +{ + "##MODE##": { + "controller": { + "host": "##CONTROLLER_HOST##", + "port": "8774", + "protocol": "https" + }, + "keystone": { + "host": "##KEYSTONE_HOST##", + "port": "35357", + "protocol": "https", + "uri": "/v3/auth/tokens" + }, + "ui": { + "protocol": "https", + "certificates": { + "key": "/etc/pki/ciao-webui-key.pem", + "cert": "/etc/pki/ciao-webui-cert.pem", + "passphrase": "##CERT_PASS##", + "trusted": [] + } + } + } +}