Introduction

In this first part, you'll learn how to quickly spin up a reproducible development environment with Docker to create a RESTful API powered by Python, Postgres, and the Flask web framework. After the app is up and running locally, you'll learn how to deploy it to an Amazon EC2 instance.

We'll take a practical approach to test driven development (TDD), where we'll write tests first only when it makes sense.

flask tdd logo

This series uses the following tools and technologies:

Part 1

  1. Python v3.6.1
  2. Flask v0.12.2
  3. Flask-Script v2.0.5
  4. Flask-SQLAlchemy v2.2
  5. Flask-Testing v0.6.2
  6. Gunicorn v19.7.1
  7. Nginx v1.13.0
  8. Docker v17.03.1-ce
  9. Docker Compose v1.11.2
  10. Docker Machine v0.10.0

Part 2

  1. Coverage.py v4.4.1
  2. Node v7.10.0
  3. NPM v4.2.0
  4. Create React App v1.3.0
  5. Axios v0.16.2
  6. Flask-CORS v3.0.2

Part 3

  1. Flask-Migrate v2.0.4
  2. Flask-Bcrypt v0.7.1
  3. PyJWT v1.5.0
  4. react-router-dom v4.1.1
  5. React Bootstrap v0.31.0
  6. React Router Bootstrap v0.24.2

Part 4

  1. TestCafe v0.16.1
  2. node-randomstring v1.1.5
  3. Swagger UI v3.0.8

Before beginning, you should have some familiarity with the following topics. Refer to the resources for more info:

Topic Resource
Docker Get started with Docker
Docker Compose Get started with Docker Compose
Docker Machine Docker Machine Overview
Flask Real Python

Objectives

By the end of this part, you should be able to...

  1. Develop a RESTful API with Flask
  2. Practice test driven development
  3. Configure and run services locally with Docker, Docker Compose, and Docker Machine
  4. Utilize volumes to mount your code into a container
  5. Run unit and integration tests inside a Docker container
  6. Enable services running in different containers to talk to one another
  7. Work with Python and Flask running inside a Docker Container
  8. Install Flask, Ngnix, and Gunicorn on an Amazon EC2 instance

App

Check out the live app, running on EC2 - http://54.89.0.180/

You can also test out the following endpoints...

Endpoint HTTP Method CRUD Method Result
/users GET READ get all users
/users/:id GET READ get single user
/users POST CREATE add a user

The /users POST endpoint is restricted as of Part 3.

Essentially, the app is running in three containers - Flask, Postgres, and Nginx. At the end of this first part, you will have the above app completed and deployed. We'll add authentication and a number of other services in the subsequent parts.

Code

Grab the code from the flask-microservices-users repo.



Introduction

In this first part, you'll learn how to quickly spin up a reproducible development environment with Docker to create a RESTful API powered by Python, Postgres, and the Flask web framework. After the app is up and running locally, you'll learn how to deploy it to an Amazon EC2 instance.

We'll take a practical approach to test driven development (TDD), where we'll write tests first only when it makes sense.

flask tdd logo

This series uses the following tools and technologies:

Part 1

  1. Python v3.6.1
  2. Flask v0.12.2
  3. Flask-Script v2.0.5
  4. Flask-SQLAlchemy v2.2
  5. Flask-Testing v0.6.2
  6. Gunicorn v19.7.1
  7. Nginx v1.13.0
  8. Docker v17.03.1-ce
  9. Docker Compose v1.11.2
  10. Docker Machine v0.10.0

Part 2

  1. Coverage.py v4.4.1
  2. Node v7.10.0
  3. NPM v4.2.0
  4. Create React App v1.3.0
  5. Axios v0.16.2
  6. Flask-CORS v3.0.2

Part 3

  1. Flask-Migrate v2.0.4
  2. Flask-Bcrypt v0.7.1
  3. PyJWT v1.5.0
  4. react-router-dom v4.1.1
  5. React Bootstrap v0.31.0
  6. React Router Bootstrap v0.24.2

Part 4

  1. TestCafe v0.16.1
  2. node-randomstring v1.1.5
  3. Swagger UI v3.0.8

Before beginning, you should have some familiarity with the following topics. Refer to the resources for more info:

Topic Resource
Docker Get started with Docker
Docker Compose Get started with Docker Compose
Docker Machine Docker Machine Overview
Flask Real Python

Objectives

By the end of this part, you should be able to...

  1. Develop a RESTful API with Flask
  2. Practice test driven development
  3. Configure and run services locally with Docker, Docker Compose, and Docker Machine
  4. Utilize volumes to mount your code into a container
  5. Run unit and integration tests inside a Docker container
  6. Enable services running in different containers to talk to one another
  7. Work with Python and Flask running inside a Docker Container
  8. Install Flask, Ngnix, and Gunicorn on an Amazon EC2 instance

App

Check out the live app, running on EC2 - http://54.89.0.180/

You can also test out the following endpoints...

Endpoint HTTP Method CRUD Method Result
/users GET READ get all users
/users/:id GET READ get single user
/users POST CREATE add a user

The /users POST endpoint is restricted as of Part 3.

Essentially, the app is running in three containers - Flask, Postgres, and Nginx. At the end of this first part, you will have the above app completed and deployed. We'll add authentication and a number of other services in the subsequent parts.

Code

Grab the code from the flask-microservices-users repo.