Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addng docker Support #11

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#FROM python:3
#ADD . ~/autocomplete
#WORKDIR ~/autocomplete
#RUN pip install -r requirements.txt
#RUN python setup.py install
#EXPOSE 8080
#CMD ["python","start_server.py"]

# this is an official Python runtime, used as the parent image
FROM python:3.6.5-slim

# set the working directory in the container to /app
WORKDIR /app

# add the current directory to the container as /app
ADD . /app

# execute everyone's favorite pip command, pip install -r
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# unblock port 80 for the Bottle app to run on
EXPOSE 80

# execute the Flask app

CMD python app.py
#CMD ["tail","-f","/dev/null"]
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ For those short on time, the [ELI5](#explain-like-im-5) section is devoid of nom
```python
import autocomplete

## Play using Docker

docker build -t autocomp_image .

## Run Docker container and go to http://localhost:5000/

docker run -d --name autocomp -p 8000:8000 autocomp_image



# load pickled python Counter objects representing our predictive models
# I use Peter Norvigs big.txt (http://norvig.com/big.txt) to create the predictive models
autocomplete.load()
Expand Down
26 changes: 26 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

import bottle
from bottle import route, run, debug
import autocomplete
from autocomplete import models, predict
models.load_models()
#autocomplete.load()
#autocomplete.run_server()


app = bottle.default_app()

@route('/')
def hello_world():
#autocomplete.load()
#autocomplete.run_server()
return "Hello, world! Simple test to make sure if Docker is running fine"

@route('/<first_word>/<last_word>')
def hello_ml(first_word, last_word):
return dict(predict(first_word,last_word))

if __name__ == "__main__":
autocomplete.load()
run(host="0.0.0.0", port=8000, debug=True, reloader=True)

Binary file added autocomplete/models_compressed.pkl
Binary file not shown.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bottle
4 changes: 4 additions & 0 deletions run_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import autocomplete
autocomplete.load()
autocomplete.run_server()