DEPLOYMENT.md
md2 kBIn php-student-app.zip
Docker Hub Deployment Workflow - Quick Reference
Overview
Instead of building the Docker image on EC2, you build it locally, push it to Docker Hub, and pull it from EC2. This is simpler and faster.
Step-by-Step Process
On Your Local Machine
-
Edit
index.php- Update hardcoded credentials:$host = "your-rds-endpoint.amazonaws.com"; $database = "labdb"; $username = "admin"; $password = "your-password"; -
Build the image:
cd php-student-app docker build -t your-dockerhub-username/php-student-app:latest . -
Login to Docker Hub:
docker login -
Push to Docker Hub:
docker push your-dockerhub-username/php-student-app:latest
On EC2 Instance
-
Install Docker (if not already installed):
sudo yum update -y sudo yum install -y docker sudo systemctl start docker sudo usermod -a -G docker ec2-user newgrp docker -
Pull your image:
docker pull your-dockerhub-username/php-student-app:latest -
Run the container:
docker run -d --name student-app -p 8080:80 your-dockerhub-username/php-student-app:latest -
Verify it's running:
docker ps -
Access in browser:
http://your-ec2-public-ip:8080
Benefits
✅ No file transfer needed
✅ Build once, deploy anywhere
✅ Faster deployment (no compilation on EC2)
✅ Version control for images
✅ Easy rollbacks (pull different tags)
Security Group Requirements
- EC2 → RDS: Allow outbound to RDS on port 3306
- RDS: Allow inbound from EC2 security group on port 3306
- EC2: Allow inbound HTTP on port 8080 from your IP (or 0.0.0.0/0 for testing)