Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Deploy a Python3 project with Gunicorn

Notifications You must be signed in to change notification settings

anthropedia/gunicorn-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Docker server image based on Python3 and Gunicorn

Run a Docker container for a Python 3 project (Flask, Django, …) with Gunicorn as a server. Eventually this can be behind a Nginx proxy for multiple websites.

Git is enabled and OpenSSH installed and .ssh folder mountable as a volume. You may therefore use ssh keys and private repositories.

A requirements.txt file is expected at the root of your project.

The image exposes the port 80. The project should be mounted as a volume.

If you make a restful service – such as an API – make sure to uppercase the verbs you use (GET, POST, PUT, PATCH, DELETE, …) as Gunicorn is case-sensitive.

Here's a full example

Building the image

docker build -t gunicorn-server .

Running a container

This will create a container, mounting the current system as the root application, using the ~/.ssh folder within the container, then running a pip -r requirements.txt automatically and start Gunicorn on local port 5000.

docker run -v `pwd`:/app -v ~/.ssh:/root/.ssh:ro -p 5000:80 gunicorn-server

You app is now running on http://localhost:5000.