diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..289f35e --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/README.md b/README.md index f41dda0..f1b9301 100644 --- a/README.md +++ b/README.md @@ -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() diff --git a/app.py b/app.py new file mode 100644 index 0000000..f20f26e --- /dev/null +++ b/app.py @@ -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('//') +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) + diff --git a/autocomplete/models_compressed.pkl b/autocomplete/models_compressed.pkl new file mode 100644 index 0000000..aa04296 Binary files /dev/null and b/autocomplete/models_compressed.pkl differ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e64db1b --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +bottle diff --git a/run_server.py b/run_server.py new file mode 100644 index 0000000..6332a36 --- /dev/null +++ b/run_server.py @@ -0,0 +1,4 @@ +import autocomplete +autocomplete.load() +autocomplete.run_server() +