This image contains Nginx with Gunicorn on top of Python3 docker image. These software entities are managed with Supervisor.
To try out the image directy from DockerHub, pull the image with:
docker pull sanjibm/python-nginx:latest
and then run
docker run -p 127.0.0.1:8000:80 sanjibm/python-nginx
Now point your host's browser to http://localhost:8000 and you should see the output "Hello World"
The entry point of your application must be named as run.py. Moreover, the instance in that file must be called api. Also, by default the worker class used is Gevent.
You can include a custom Gunicorn configuration file into your application. By default the configuration file must be named as gunicorn.config.py
Here is an example of a Dockerfile using that image :
FROM sanjibm/python-nginx:latest
LABEL maintainer="sanjibm2006@gmail.com"
# Copy the application
COPY . /api
# Install application requirements
RUN pip install -U pip
RUN pip install -r /api/requirements.txt
There is also a Flask demo application in the api folder of this repository.
First, build your image based on your Dockerfile.
docker build -t pyapi
Then, you can run a container like this :
docker run -p 127.0.0.1:8000:80 pyapi
And finally access it with curl for instance :
curl localhost:8000