GithubHelp home page GithubHelp logo

1mr-newton / gunicorn-flask-docker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iamelin/gunicorn-flask-docker

0.0 0.0 0.0 6 KB

A small and fast image with Gunicorn to deploy your Flask applications!

License: MIT License

Shell 3.71% Python 53.98% Roff 42.32%

gunicorn-flask-docker's Introduction

Gunicorn Server with Flask in Docker

Docker Pulls

This is a small and fast Docker image to fast deploy your Flask applications via Gunicorn server.

All images are based on Python-Alpine images.

GitHub Repository Page: https://github.com/iamelin/gunicorn-flask-docker

Docker Hub Page: https://hub.docker.com/r/amelin/gunicorn-flask

Supported tags

  • python3.9
  • python3.8
  • python3.7
  • python3.6

Quick Start

Deploying your application is very simple! Just do the following:

  1. Create a directory app with your Python application. The main file must be named main.py and the Flask object must be named app.
  2. Pull the image from Docker Hub: docker pull amelin/gunicorn-flask:python3.8
  3. Create Dockerfile with the following content:
FROM amelin/gunicorn-flask:python3.8

ADD ./app/ /app

That's all! Now build your image and start a new container. If the file /app/requirements.txt exists, packages will be installed automatically before starting the application. Then you can send requests to your application that listens port 5000.

Configuration

You can configure Gunicorn and image using the following environment variables:

  • PORT — port that the server listens (default value: 5000)
  • WORKERS — number of workers that handle requests (default value: number of cores of your processor * 2 + 1)
  • LOGLEVEL — level of logs (default value: info)
  • ACCESS_LOG — file which the server writes access logs to (default no access logs)
  • ERROR_LOG — file which the server writes error logs to (default value: stdout)
  • MODULE_NAME — a Python module that contains a Flask object (default value: main, file main.py in the working directory /app)
  • APP_NAME — a Flask object which handles requests (default value: app)
  • GUNICORN_CONFIG — a Python script that contains the configuration of a Gunicorn instance (default value: gunicorn.conf.py in the working directory /app)
  • TZ — timezone (default value: UTC)

Also the application directory /app contains the file prestart.sh that runs before starting a container. You can use it to prepare your application to work (e.g. run migrations etc).

gunicorn-flask-docker's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.