Skip to content

Docker environment to develop flask project with docker hub continuous integration (build+test+deploy)

Notifications You must be signed in to change notification settings

itarano/flask-development

Repository files navigation

flask-development

Local environment

  1. Docker and Docker Compose (for example, Docker for Windows)
  2. GitHub and DockerHub (CI/CD)

Use

Up and running dev environment:

docker-compose up --build -d

Python version: 3.7.7 (python:3.7.7 docker image in Dockerfile, change it if you want another version!)

Integration with Docker Hub

In order to deploy flask app container to test and shared the application (or deploy it in production), we can push an image to docker hub automatically when commit occurs (continuous integration). Moreover, it is also posible to run test before push to DockerHub automatically with docker-compose.test.yml file.

docker blog

We have to create a Docker Hub repository (for example, flask-dev) and configure it as shown below:

Docker Hub Configuration

Docker Hub Configuration

We have configurated two rules:

  1. Push image always when commit occurs with latest tag
  2. Push release image (release-x.x.x) when a new release is generated in the github repo with tag x.x.x

Test or deploy DockerHub image

docker run -d -p 5000:5000 itarano/flask-dev:release-1.0.0

This shows how easy is to deploy or test new releases in any kind of environment.

Test with Github Actions

In the directory .github/workflows there is a file to define ci/cd pipeline with Github Actions (test)

Github Action