From 3d8e9eb621cc58071bf37f4e3da679693301e9ad Mon Sep 17 00:00:00 2001 From: Graham McGregor Date: Thu, 5 Jan 2017 15:37:20 -0500 Subject: [PATCH] Dockerize the app Had to update gevent because of an ssl error with the previous version that caused issues when running in Docker. --- Dockerfile | 28 ++++++++++++++++++++++++++++ README.md | 17 +++++++++++++++++ docker-compose.yml | 12 ++++++++++++ requirements.txt | 2 +- 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e6bb79c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM python:2.7-alpine + +RUN apk update && apk upgrade && \ + apk add \ + gcc python python-dev py2-pip \ + # greenlet + musl-dev \ + # sys/queue.h + bsd-compat-headers \ + # event.h + libevent-dev \ + && rm -rf /var/cache/apk/* + +# want all dependencies first so that if it's just a code change, don't have to +# rebuild as much of the container +ADD requirements.txt /opt/requestbin/ +RUN pip install -r /opt/requestbin/requirements.txt \ + && rm -rf ~/.pip/cache + +# the code +ADD requestbin /opt/requestbin/requestbin/ + +EXPOSE 8000 + +WORKDIR /opt/requestbin +CMD gunicorn -b 0.0.0.0:8000 --worker-class gevent --workers 2 --max-requests 1000 requestbin:app + + diff --git a/README.md b/README.md index 92d445c..18c7639 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,23 @@ Now just deploy via git: It will push to Heroku and give you a URL that your own private RequestBin will be running. +## Deploy your own instance using Docker + +On the server/machine you want to host this, you'll first need a machine with +docker and docker-compose installed, then grab the RequestBin source using git: + +`$ git clone git://github.com/Runscope/requestbin.git` + +Go into the project directory and then build and start the containers + +``` +$ sudo docker-compose build +$ sudo docker-compose up -d +``` + +Your own private RequestBin will be running on this server. + + Contributors ------------ * Barry Carlyon diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..cb8ebe5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +app: + build: . + environment: + REALM: prod + REDIS_URL: "//redis:6379" + links: + - redis + ports: + - "8000:8000" + +redis: + image: redis diff --git a/requirements.txt b/requirements.txt index 8f69217..c2d4efc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -gevent==0.13.8 +gevent==1.0.2 greenlet==0.4.1 ProxyTypes==0.9 nose==1.3.0