diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..161a726e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:latest + +ADD . /server +WORKDIR /server +RUN pip install -r requirements.txt + +EXPOSE 3000 + +CMD python server.py diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..cc0a8b41 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: build +build: + docker build --rm=true -t react-tutorial . + +.PHONY: start +start: + export HOST='0.0.0.0' && docker run --rm -it --name react-tutorial -p 3000:3000 -e HOST -v `pwd`:/server react-tutorial diff --git a/README.md b/README.md index 4862f5df..f4bf5a96 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,18 @@ pip install -r requirements.txt python server.py ``` +or, using Docker: + +``` +make build +make start +``` + +Check your Docker machine IP with + docker-machine ip + +Visit + ### Ruby ```sh ruby server.rb diff --git a/server.py b/server.py index 5cf598df..4332920b 100644 --- a/server.py +++ b/server.py @@ -33,4 +33,4 @@ def comments_handler(): return Response(json.dumps(comments), mimetype='application/json', headers={'Cache-Control': 'no-cache', 'Access-Control-Allow-Origin': '*'}) if __name__ == '__main__': - app.run(port=int(os.environ.get("PORT",3000))) + app.run(host=os.environ.get("HOST",'127.0.0.1'),port=int(os.environ.get("PORT",3000)))