Skip to content

zachvalenta/docker-flask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

overview

The bare bones to Dockerize Flask.

why does this exist?

Most 'hello world' examples of a Dockerized Flask app suffer from one of these problems:

  • They're not actually 'hello world'; they add gunicorn, a database setup, a REST framework. In other words, more stuff to debug when you just want to get started with Docker.
  • They use the old way of initializing a Flask app (i.e. if __name__ == '__main__:'), which harkens from when Flask still didn't have a major version released (prior to 2018).

This repo, on the other hand, aims to be a minimal, viable, and complete, and nothing more.

how to run?

To run as a container, have DockerCE installed and use the Makefile:

# create image
make build

# run container using image
make start

# hit Flask server healthcheck
make hc

# stop container
make stop

Of course, you can still work with the app locally (outside of a container, on your own operating system) using a virtual environment:

# create virtual environment
python3 -m venv venv

# activate virtual environment
source venv/bin/activate

# update base dependencies
pip install -q --upgrade pip setuptools wheel

# install Flask
pip install flask

# hit Flask server running on your OS
make flask

FYI

I have another branch that uses Poetry for dependency management.

Here's the full list of projects I have in this vein:

Here are the Docker versions I'm working with:

$ docker --version  # Docker version 18.09.2, build 6247962
$ docker-compose --version  # docker-compose version 1.23.2, build 1110ad01
$ docker-machine --version  # docker-machine version 0.16.1, build cce350d7

About

🦴 the bare bones to Dockerize Flask 🚢

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published