diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6c317c2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM ubuntu:trusty +MAINTAINER Zach Musgrave + +RUN apt-get update +RUN apt-get install -y git make +RUN apt-get install -y python2.7 python2.7-dev python-pip +RUN apt-get install -y libyaml-dev libpcre3-dev + +ADD . / +RUN pip install -Ur requirements.txt +RUN make frontend + +CMD uwsgi --ini tscached.uwsgi.ini --wsgi-file tscached/uwsgi.py + +EXPOSE 8008 diff --git a/Makefile b/Makefile index 68fac43..f478ade 100644 --- a/Makefile +++ b/Makefile @@ -4,13 +4,12 @@ # Feel free to change PYTHONEXEC if you need to. PYTHONEXEC=python2.7 -DEBUGPORT=8008 +PORT=8008 -# turns out 'source' isn't a thing in sh. SHELL=/usr/bin/env bash -PACKAGE_VERSION=$(shell python setup.py --version 2>/dev/null) -PACKAGE_DEBIAN_REVISION=1 +VERSION_BASH=$(shell bash -c "cat tscached/__init__.py | grep VERSION | sed 's/VERSION = //g' | sed \"s/'//g\"") +VERSION_PYTHON=$(shell python setup.py --version 2>/dev/null) # builds the darn thing all: venv frontend @@ -43,7 +42,7 @@ run: venv frontend # Run with single-threaded debug server. Flask gives you auto-reloading on code changes for free. debug: venv frontend - echo "from tscached import app; app.debug = True; app.run(host='0.0.0.0', port=${DEBUGPORT})" > debug-run.py + echo "from tscached import app; app.debug = True; app.run(host='0.0.0.0', port=${PORT})" > debug-run.py source venv/bin/activate; venv/bin/python debug-run.py # Copy the debug frontend from kairosdb into our project @@ -60,4 +59,12 @@ package: frontend # changelog stuff changelog: - dch -D trusty -u low -v ${PACKAGE_VERSION}-1 + dch -D trusty -u low -v ${VERSION_PYTHON}-1 + +.PHONY: docker_build +docker_build: + docker build -t tscached_v${VERSION_BASH} . + +.PHONY: docker_run +docker_run: docker_build + docker run -p 0.0.0.0:${PORT}:8008 -t tscached_v${VERSION_BASH}