0
0
Flaskframework~10 mins

CI/CD pipeline for Flask - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - CI/CD pipeline for Flask
Code Commit to Repo
Trigger CI Pipeline
Run Tests
Build Docker Image
Push Image to Registry
Trigger CD Pipeline
Deploy to Server
Run Smoke Tests
Release Live
This flow shows how code changes trigger automated testing, building, and deployment steps to safely update a Flask app.
Execution Sample
Flask
git push origin main
# CI pipeline runs tests
# Build Docker image
# Push image to registry
# Deploy to server
# Run smoke tests
This sequence shows pushing code triggers tests, build, deploy, and verification steps automatically.
Execution Table
StepActionResultNext Step
1Code pushed to repoTrigger CI pipelineRun tests
2Run testsTests passBuild Docker image
3Build Docker imageImage built successfullyPush image to registry
4Push image to registryImage pushedTrigger CD pipeline
5Trigger CD pipelineStart deploymentDeploy to server
6Deploy to serverApp deployedRun smoke tests
7Run smoke testsSmoke tests passRelease live
8Release liveApp live with new versionEnd
9If tests fail at step 2Pipeline stopsNotify developer
10If smoke tests fail at step 7Rollback deploymentNotify ops
💡 Pipeline ends after successful release or stops on test failures.
Variable Tracker
VariableStartAfter Step 2After Step 4After Step 6Final
Code Versionv1.0v1.1 (pushed)v1.1 (image pushed)v1.1 (deployed)v1.1 (live)
Test StatusN/APassN/AN/AN/A
Deployment StatusNot deployedNot deployedNot deployedDeployedLive
Smoke Test StatusN/AN/AN/APassPass
Key Moments - 3 Insights
Why does the pipeline stop if tests fail at step 2?
Because failing tests mean the code is not ready, so the pipeline stops to prevent bad code from deploying, as shown in execution_table row 9.
What happens if smoke tests fail after deployment?
The pipeline triggers a rollback to the previous stable version to avoid downtime, as shown in execution_table row 10.
Why do we build a Docker image after tests pass?
Building a Docker image packages the app consistently for deployment, ensuring the tested code is what runs live, as shown in execution_table row 3.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the result after step 4?
AImage pushed to registry
BTests fail
CApp deployed
DRollback triggered
💡 Hint
Check the 'Result' column for step 4 in the execution_table.
At which step does the pipeline stop if tests fail?
AStep 7
BStep 3
CStep 2
DStep 6
💡 Hint
Look for the failure condition related to tests in the execution_table rows.
If smoke tests fail, what is the immediate next action?
ARelease live
BRollback deployment
CNotify developer
DBuild Docker image
💡 Hint
Refer to the execution_table row describing smoke test failure.
Concept Snapshot
CI/CD pipeline for Flask:
- Code push triggers CI pipeline
- Run automated tests; stop if fail
- Build Docker image if tests pass
- Push image to registry
- Deploy image to server
- Run smoke tests; rollback if fail
- Release live if all pass
Full Transcript
A CI/CD pipeline for a Flask app starts when code is pushed to the repository. This triggers the continuous integration pipeline, which runs automated tests. If tests pass, the pipeline builds a Docker image of the app and pushes it to a container registry. Then, the continuous deployment pipeline deploys the image to the server. After deployment, smoke tests run to verify the app is working. If smoke tests pass, the new version is released live. If any tests fail, the pipeline stops or rolls back to keep the app stable.