

DOCKER FLASK POSTGRES APP CODE
You can find the complete code on GitHub. Docker and Docker Compose will make it easier to deploy anywhere.
DOCKER FLASK POSTGRES APP HOW TO
In this post, we're going to focus on infrastructure – namely, how to set up and deploy the application.įor this project, I'm using NGINX, Flask, and Postgres on the back-end. In the last post, we built out the Puppeteer script that will do the actual scraping. The example project is a Google rank tracker that we'll build together piece by piece, but you can apply these lessons to any kind of SaaS app. If you haven't read the first post in the series, this is a step by step guide on building a SaaS app that goes beyond the basics, showing you how to do everything from accept payments to manage users. Configure a load balancer (ALB) and add health checks to the serviceġ.By the end of this post, you will have a deployable app that is ready to serve real users efficiently and securely! Spin up a containerized Postgres service in the clusterġ. Add Container - name it, use the ECR image, expose port 5000ġ. **Service**: instantiated Task Definitionsġ.

**Cluster**: groups of EC2 instances where the containers runġ. **Task Definitions**: think of them as blueprints, similar to a Docker Compose fileġ. To set up ECS, we need to configure the following pieces:ġ. $(aws ecr get-login -no-include-email -region us-west-1 -profile fargate) From the AWS console, navigate to the () dashboard and create two new Image repos: () account with the following group-level policies: $ docker-compose exec users /bin/bash -c "isort project/*/*.py" -check-only $ docker-compose exec users black project -check $ docker-compose exec users flake8 project $ docker-compose exec users pytest "project/tests" -p no:warnings $ docker-compose exec users python manage.py seed_db

$ docker-compose exec users python manage.py recreate_db
DOCKER FLASK POSTGRES APP UPDATE
| /users/:id | PUT | UPDATE | update a user |īuild the images and spin up the containers: | /users/:id | GET | READ | get a single user | | Endpoint | HTTP Method | CRUD Method | Result | Decreased transparency (infrastructure is managed by someone else) Put another way, the focus is solely on the containers (your application)ġ. (infrastructure is managed by someone else, so devs can focus on writing business-valuable code) The key advantage is the increased velocity

How much control over the environment do you need? Are you willing to take on more operational costs to maintain a more flexible environment? When looking at costs, are you taking indirect costs like maintenance and upgrades into account?ġ. **vs Lambda** - Fargate get things a bit closer to Lambda without a huge app refactor, more control, *probably* quicker, *probably* cheaperġ. **vs ECS (with EC2)** - less complex, *probably* more expensive since Fargate abstracts out the underlying architectureġ. Put simply, it's a tool for running and managing containerized apps on groups of EC2 instances.ĮCS with () is a container orchestration tool used for running Docker-based containers without having to manage the underlying infrastructure.ġ. () ("Elastic Container Service") is a container orchestration tool used for managing and running Docker-based containers. In the Docker world, you'll need to use a container orchestration tool.Īs you move from deploying containers on a single machine to deploying them across a number of machines, you will need an orchestration tool to manage the arrangement and coordination of the containers across the entire system. While you can run multiple apps or services, it's better to use a different AWS product in order to scale each app vertically and horizontally more efficiently. It's perfect for running a single app or Docker service. () ("Elastic Compute Cloud") is a virtual machine in the cloud. Configure Fargate to run a Flask microservice Utilize ECR image registry to store Docker imagesġ. Spin up a Flask app locally with Dockerġ. Explain what container orchestration is and why you may need to use an orchestration toolġ. Describe the similarities and differences between EC2, ECS, and Fargateġ. Explain the following AWS services and why you may need to use each of them - EC2, IAM, ECR, ECS, and Fargateġ. 😍 - (), (), (), ()īy the end of this tutorial, you should be able to.ġ. # Engineer, Educator, Entrepreneur from Denver, COġ. Flask on Fargate: Deploying a Flask App to AWS Fargate
