├── Dockerfile ├── README.md ├── webapp.tar.gz └── webapp ├── .gitignore ├── Procfile ├── app.py ├── requirements.txt └── tests.py /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | MAINTAINER Docker Education Team 3 | RUN apt-get update 4 | RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q python-all python-pip 5 | ADD ./webapp/requirements.txt /tmp/requirements.txt 6 | RUN pip install -qr /tmp/requirements.txt 7 | ADD ./webapp /opt/webapp/ 8 | WORKDIR /opt/webapp 9 | EXPOSE 5000 10 | CMD ["python", "app.py"] 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Docker Fundamentals WebApp 2 | ========================== 3 | 4 | The Docker Fundamentals repository contains the example Hello World Python WebApp 5 | 6 | ## License 7 | 8 | Apache 2.0 9 | 10 | ## Copyright 11 | 12 | Copyright Docker Inc Education Team 2014 13 | -------------------------------------------------------------------------------- /webapp.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docker-training/webapp/5ffb1e220d718b734055291fdc2cb0ea3ad031c2/webapp.tar.gz -------------------------------------------------------------------------------- /webapp/.gitignore: -------------------------------------------------------------------------------- 1 | venv 2 | *.pyc 3 | -------------------------------------------------------------------------------- /webapp/Procfile: -------------------------------------------------------------------------------- 1 | web: python app.py 2 | -------------------------------------------------------------------------------- /webapp/app.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from flask import Flask 4 | 5 | app = Flask(__name__) 6 | 7 | @app.route('/') 8 | def hello(): 9 | provider = str(os.environ.get('PROVIDER', 'world')) 10 | return 'Hello '+provider+'!' 11 | 12 | if __name__ == '__main__': 13 | # Bind to PORT if defined, otherwise default to 5000. 14 | port = int(os.environ.get('PORT', 5000)) 15 | app.run(host='0.0.0.0', port=port) 16 | -------------------------------------------------------------------------------- /webapp/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask 2 | Jinja2 3 | Werkzeug 4 | distribute 5 | wsgiref 6 | -------------------------------------------------------------------------------- /webapp/tests.py: -------------------------------------------------------------------------------- 1 | from app import app 2 | 3 | import os 4 | import unittest 5 | 6 | class AppTestCase(unittest.TestCase): 7 | 8 | def test_root_text(self): 9 | tester = app.test_client(self) 10 | response = tester.get('/') 11 | assert 'Hello world!' in response.data 12 | 13 | if __name__ == '__main__': 14 | unittest.main() 15 | --------------------------------------------------------------------------------