How sohailsajid79/azure-tetris-deployment works
Main Components
• Infrastructure as Code (Terraform): Components include the Azure Resource Group, VNet, Subnet, Network Interface, Network Security Group (NSG), Public IP, and the Linux Virtual Machine.
• Virtual Machine: Hosts the Dockerized Tetris web application. The VM setup (and provisioning) is orchestrated by Terraform.
• Docker Container: Runs the Tetris application. The Docker image is pulled from Docker Hub (sajid79/tetris-js-app:amd64) and hosted on port 8080.
• NGINX Reverse Proxy: Installed on the VM to manage HTTP/HTTPS traffic and forward requests to the Docker container. It handles SSL redirection (from HTTP port 80 to HTTPS port 443), and proxies traffic internally to the Tetris application.
• SSL/TLS Security: Managed with Certbot and Let’s Encrypt, which provides the necessary certificates for securing communication.
• GitHub Actions Pipeline: Automates the deployment process by validating the deployment environment, scanning for vulnerabilities, pulling the Docker image, and updating the deployment through CI/CD.
• DNS and Cloudflare: Integrates with Cloudflare DNS to map the subdomain (tetris.sohailsajid.dev) to the VM’s public IP for public accessibility.
Relationships and Data/Control Flows
• Terraform initiates and orchestrates the provisioning of all Azure infrastructure components.
• After the VM is provisioned, a Docker container (running the Tetris app) is started on the VM.
• NGINX running on the VM receives incoming traffic on ports 80/443. HTTP traffic is automatically redirected to HTTPS.
• Requests reaching NGINX are proxied to the Docker container on port 8080.
• SSL/TLS certificates are automatically managed by Certbot, ensuring that communication is secure.
• GitHub Actions coordinate the deployment process (triggered by pushes) to ensure that updates are automatically rolled out and verified.
• Cloudflare DNS ensures that requests to tetris.sohailsajid.dev resolve to the correct VM public IP.
Architectural Patterns and Design Principles
• Infrastructure as Code (IaC): Using Terraform to set up repeatable and scalable cloud resources.
• Containerization: Docker ensures consistent application packaging and deployment.
• Reverse Proxy Pattern: NGINX serves static content, manages HTTPS redirection, and routes traffic to the application container.
• CI/CD Pipeline: GitHub Actions automates testing, deployment, and environmental consistency.
• Security Best Practices: The use of SSL/TLS certificates managed by Certbot for secure communication and an NSG to restrict access to only necessary ports.