From 3dab455197712a006a03965401827b8d420d0f96 Mon Sep 17 00:00:00 2001 From: Henning Kage Date: Mon, 11 Jan 2016 12:17:53 +0100 Subject: [PATCH] Issue #1: Added Docker support --- .gitignore | 1 + Dockerfile | 25 +++++++++++++++++++++++++ README.md | 12 ++++++++++++ Vagrantfile | 2 +- settings.py | 2 +- 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index f15f9b8..76e684a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ dist # Vagrant .vagrant +.bash_history diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e5f5d39 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM debian:stable + +MAINTAINER Henning Kage "henning.kage@gmail.com" + +USER root + +# Link the project directory +ADD . /app + +# Set environment variables +ENV PYTHON_VERSION 2.7 + +# Install basic requirements +RUN apt-get update && apt-get upgrade -y +RUN apt-get install -y --no-install-recommends build-essential openssh-client git git-core python-pip procps net-tools wget unzip python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python-distribute + +# Install the requirements and run the application +RUN (cd /app && python setup.py install) +#CMD (cd /app && python run.py --port=8000 --logging=debug) + +RUN chown -R www-data: /app + +CMD ["python", "/app/run.py"] + +EXPOSE 8000 diff --git a/README.md b/README.md index 4e51654..e8edee9 100644 --- a/README.md +++ b/README.md @@ -61,3 +61,15 @@ start the development server with the following command: $ vagrant up $ fab vagrant devserver + +You can now access your application via `http://localhost:8000` + +Docker +--- + +To run the application within Docker, you need to build and then run the image: + + $ sudo docker build --tag=tornado-app --rm=true . + $ sudo docker run -p 8000:8000 -t -i tornado-app:latest + +You can now access your application via `http://localhost:8000` diff --git a/Vagrantfile b/Vagrantfile index 05f751c..f6390be 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,7 +1,7 @@ Vagrant.configure(2) do |config| config.vm.box = "ubuntu/trusty64" config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box" - config.vm.network :forwarded_port, guest: 8888, host: 8888, id: "tornado" + config.vm.network :forwarded_port, guest: 8000, host: 8000, id: "tornado" config.vm.synced_folder ".", "/home/vagrant" config.vm.provision :shell, :path => "bootstrap.sh" end diff --git a/settings.py b/settings.py index 5916554..fe15b60 100644 --- a/settings.py +++ b/settings.py @@ -5,7 +5,7 @@ from tornado.options import define -define("port", default=8888, help="run on the given port", type=int) +define("port", default=8000, help="run on the given port", type=int) define("config", default=None, help="tornado config file") define("debug", default=False, help="debug mode")