How fureasu/simple-flask works
Project Type & Purpose
• This is a containerized, single‐service web application built in Flask and served by Gunicorn.
• It’s intended as a simple CI/CD demo: four endpoints (home, cookies, input, picture), writes to local files, sets cookies, and reports health.
• Supports local development via Docker Compose and production deployment via AWS ECS, with CI pipelines defined in GitHub Actions.
File‐Structure Analysis
• Top‐level:
• Dockerfile + docker‐compose.yml → container build & local orchestration
• ecs‐task‐definition‐template.json → AWS ECS service definition
• .github/workflows/…yml → CI/CD workflows (dev & staging)
• app/ → application code & config
• tests/ → pytest unit tests & fixtures
• app/simpleflask/ → Flask blueprints for each page (cookies, input, picture, health, home), plus templates & static assets.
• Configuration files: .env, gunicorn.conf.py, requirements.txt, pytest.ini.
Key Components to Render
a. Client / User’s Browser
b. CI/CD Pipeline
– GitHub Actions (simple‐flask‐dev.yml & simple‐flask‐stg.yml)
– Steps: code checkout → dependency install → pytest → Docker build → push to registry → deploy to ECS
c. Docker Registry (Docker Hub or ECR)
d. Deployment Targets
– Local: Docker Compose
– Staging/Production: AWS ECS Service & Task (ecs-task-definition-template.json) behind a Load Balancer
e. Containerized Service
– Gunicorn process
– Flask app modules (endpoints)
– Environment variables injected (APP_DATA_PATH, APP_LOG_PATH, APP_PORT)
– Mounted volumes for data & logs
f. Persistent Storage
– Docker volumes or host paths for /data and /log
Interactions & Data Flows
• User → HTTP Request → Load Balancer (ECS) → Container:Gunicorn → Flask route handler → possibly write/read a file on volume → render template or JSON → Response → User
• CI/CD: Git push → GitHub Actions → test/build/push → ECS deployment API → new task revision
Architectural Patterns & Principles
• Twelve-factor app: stateless container, config via env vars, port binding.
• Single‐responsibility microservice: each endpoint in its own module.
• Infrastructure as code: ECS task template + Docker Compose for dev parity.
• Automated CI/CD promoting build→test→deploy in one flow.