Overview
The deployment pipeline flows:Bitbucket Pipelines
File:bitbucket-pipelines.yml
Simple CI pipeline that runs on all branches:
AWS CodeBuild — Staging
File:buildspec-staging.yml
Pre-build
- Downloads
.envfroms3://tutorbloc-app/env-configurations/staging/.env - Downloads
APNS-Key.p8from S3 (push notification certificate) - Downloads
AAACertificateServices.crtfrom S3 (SSL certificate) - Logs in to ECR
- Pulls BlackBox Docker image from ECR
Build
- Logs in to Docker Hub (for base images)
- Runs
docker-compose up -d(builds and starts all services)
Post-build
- Waits for
mysql-db-testto be ready (120s timeout via Dockerize) - Runs database migrations on test database:
- Runs full test suite:
- Tags Docker images:
tutorbloc.app:stagingandtutorbloc.app:staging-{BUILD_NUMBER}tutorbloc.app.nginx:stagingandtutorbloc.app.nginx:staging-{BUILD_NUMBER}redis:staging
- Pushes all images to ECR
appspec.yaml, staging-taskdef.json
AWS CodeBuild — Production
File:buildspec-production.yml
Same structure as staging with key differences:
| Aspect | Staging | Production |
|---|---|---|
| APP_ENV | staging | production |
| Runs migrations | Yes (test DB) | No |
| Runs tests | Yes | No |
| Image tags | staging-* | production-* |
| Artifacts | staging-taskdef.json | production-taskdef.json |
ECS deployment
App spec
File:appspec.yaml
Task definitions
Production (production-taskdef.json):
- 3 containers: app, nginx, blackbox
- All with 128MB memory reservation
- Bridge networking mode
- Environment loaded from S3
- CloudWatch logging to
/ecs/production-app-ec2
staging-taskdef.json):
- Same structure
- Nginx exposes ports 80 AND 443 (vs only 80 in production)
- CloudWatch logging to
/ecs/staging-app-ec2
Container startup order
- blackbox starts first (no dependencies)
- app starts and links to blackbox
- Runs
php artisan migrate --force - Starts cron daemon
- Starts PHP-FPM
- Runs
- nginx starts and links to app
- Proxies HTTP requests to app:9000
ECR images
{environment}— latest for that environment (e.g.,production){environment}-{build_number}— specific build (e.g.,production-42)
Legacy: Elastic Beanstalk
File:Dockerrun.aws.json
An older single-container EB config exists:
.ebextensions/01_server.config with Nginx configuration. This appears to be a legacy setup — current deployment uses ECS.