
Capstone Part 4: Multi-Tier Deployment
The final stretch. Implement automated delivery to Staging and a manual-trigger, rolling update deployment to the Production environment for GlobalHealth Connect.
Capstone Part 4: Multi-Tier Deployment
In this final technical lesson, we ship the GlobalHealth Connect code to our users. We will use a Continuous Delivery model (Review Module 1).
1. Defining the Environments
.deploy_template: &deploy_def
stage: deploy
image: alpine:latest
script:
- echo "Updating infrastructure for $CI_ENVIRONMENT_NAME..."
- ssh root@$DEPLOY_IP "docker pull $BACKEND_IMAGE && docker-compose up -d"
deploy-staging:
<<: *deploy_def
environment:
name: staging
url: https://staging.globalhealth.test
rules:
- if: $CI_COMMIT_BRANCH == "develop"
deploy-prod:
<<: *deploy_def
environment:
name: production
url: https://www.globalhealth.com
rules:
- if: $CI_COMMIT_BRANCH == "main"
when: manual # Human intervention required for the final push
2. Environment Variables (Scoping)
Remember Module 10: The DEPLOY_IP for Staging is different from Production.
- Staging IP:
10.0.0.50 - Production IP:
44.55.66.77We configure these in Settings -> CI/CD -> Variables, scoped to the correct environment.
3. Post-Deployment Verification
After the deploy-prod job finishes, we add a "Smoke Test" to ensure the site is up.
smoke-test:
stage: deploy
needs: [deploy-prod]
script:
- curl -f https://www.globalhealth.com/healthcheck
4. Why "Manual" for Production?
Even with 1,000 tests, a human should decide WHEN to deploy.
- Maybe the marketing team isn't ready for the "New Feature" yet.
- Maybe there is a major surgery scheduled at the hospital today, and we want to avoid any risk until tomorrow.
Exercise: The Deployment Master
- If the
smoke-testfails, what is the fastest way to revert? (Review Module 6). - Write a job
delete-stagingthat runs only when a branch is deleted (usingwhen: on_stop). - Why is the
rules:section the most important part of this configuration? - Search: How do you add a "Deployment Notification" to Slack so the doctors know a new version of GlobalHealth is live?
Summary
You have built a full, enterprise-grade pipeline. From a developer's first commit to a secure production release, every step of the GlobalHealth Connect platform is now automated, verified, and protected.
Next Lesson: Part 5: Final Review & Professional Certification Path.