Skip to content

Commit

Permalink
Added Dockerfile and Entrypoint for containerization
Browse files Browse the repository at this point in the history
  • Loading branch information
Crapworks committed Jan 7, 2017
1 parent e837082 commit eff852c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Dockerfile
@@ -0,0 +1,17 @@
FROM centos:7
MAINTAINER Christian Eichelmann "christian@crapworks.de"

ENV CEPH_VERSION jewel

# Install Ceph
RUN rpm --import 'https://download.ceph.com/keys/release.asc'
RUN rpm -Uvh http://download.ceph.com/rpm-${CEPH_VERSION}/el7/noarch/ceph-release-1-1.el7.noarch.rpm
RUN yum install -y epel-release && yum clean all
RUN yum install -y ceph python27 python-pip && yum clean all

COPY . /cephdash
WORKDIR /cephdash
RUN pip install -r requirements.txt

ENTRYPOINT ["/cephdash/contrib/docker/entrypoint.sh"]
CMD ["ceph-dash.py"]
11 changes: 11 additions & 0 deletions app/__init__.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import json

from os.path import dirname
Expand Down Expand Up @@ -32,6 +33,16 @@ def __init__(self):
configfile = join(dirname(dirname(__file__)), 'config.json')
self.update(json.load(open(configfile), object_hook=self._string_decode_hook))

if os.environ.get('CEPHDASH_CEPHCONFIG', False):
self['ceph_config'] = os.environ['CEPHDASH_CEPHCONFIG']
if os.environ.get('CEPHDASH_KEYRING', False):
self['keyring'] = os.environ['CEPHDASH_KEYRING']
if os.environ.get('CEPHDASH_ID', False):
self['client_id'] = os.environ['CEPHDASH_ID']
if os.environ.get('CEPHDASH_NAME', False):
self['client_name'] = os.environ['CEPHDASH_NAME']


app.config['USER_CONFIG'] = UserConfig()

# only load influxdb endpoint if module is available
Expand Down
32 changes: 32 additions & 0 deletions contrib/docker/entrypoint.sh
@@ -0,0 +1,32 @@
#!/usr/bin/env sh

CEPHCONFIG="/etc/ceph/ceph.conf"
CEPHKEYRING="/etc/ceph/keyring"

echo "# REQUIRED ENVIRONMENT VARIABLES"
echo "* CEPHMONS (comma separated list of ceph monitor ip addresses)"
echo "* KEYRING (full keyring to deploy in docker container)"
echo ""
echo "# OPTIONAL ENVIRONMENT VARIABLES"
echo "* NAME (keyring name to use)"
echo "* ID (keyting id to use)"
echo ""

echo "${KEYRING}" > ${CEPHKEYRING}
echo -e "[global]\nmon host = ${CEPHMONS}" > ${CEPHCONFIG}

echo "# CEPH STATUS"
ceph -s

export CEPHDASH_CEPHCONFIG="${CEPHCONFIG}"
export CEPHDASH_KEYRING="${CEPHKEYRING}"

if [ -n "${NAME}" ]; then
export CEPHDASH_NAME="${NAME}"
fi

if [ -n "${ID}" ]; then
export CEPHDASH_ID="${ID}"
fi

python $*

1 comment on commit eff852c

@fersantxez
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!! Thanks Christian! I'll test this as soon as I get a hold of a cluster and report back.

Please sign in to comment.