☁️ Final Project: Cloud Full-Stack Deployment
Proyek ini mendokumentasikan proses deployment aplikasi web (Node.js + Nginx) ke AWS EC2 menggunakan Docker, CI/CD GitHub Actions, Reverse Proxy dengan SSL otomatis (Let's Encrypt), serta monitoring stack (Prometheus & Grafana).
🛠 Tech Stack
| Kategori | Teknologi |
|---|---|
| Runtime/Build | Node.js 22 (Alpine) |
| Web Server | Nginx (Alpine) |
| Container | Docker & Docker Compose |
| CI/CD | GitHub Actions |
| Cloud | AWS EC2 (Ubuntu 24.04 LTS, t3.micro) |
| Security/Proxy | Nginx Reverse Proxy, Let's Encrypt |
| Monitoring | Prometheus, Grafana, Node Exporter |
📋 Prerequisites
- ✅ Akun GitHub & Repository
- ✅ Akun DockerHub & Access Token
- ✅ Akun AWS & Key Pair (
.pem) - ✅ Domain yang sudah diarahkan ke IP EC2 (
A Record) - ✅ Docker, Git, dan Node.js 22 terinstall di mesin lokal
🚀 Local Development & Testing
Clone repository
git clone https://github.com/codebucks27/wibe-studio.git
cd repo
Build & Run Docker container
docker build -t wibe-studio .
docker run -d -p 8080:80 wibe-studio
Akses aplikasi
Buka browser:http://localhost:8080
🔹 Push ke GitHub
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/devrama404/wibe-studio.git
git push -u origin main
☁️ AWS EC2 Setup
Launch Instance
OS:Ubuntu Server 24.04 LTS| Tipe:t3.micro| Key Pair: Buat & simpan.pem
SSH ke Server
chmod 400 key.pem
ssh -i key.pem ubuntu@<EC2_PUBLIC_IP>
Install Docker & Git
sudo apt update && sudo apt install -y ca-certificates curl git
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker
🔄 CI/CD Pipeline (GitHub Actions)
1. Setup Secrets
Masuk ke GitHub Repo → Settings → Secrets and variables → Actions dan tambahkan:
| Secret Name | Value Contoh |
|----------------------|----------------------------|
| DOCKERHUB_USERNAME | devrama404 |
| DOCKERHUB_TOKEN | dckr_pat_xxxxxxxxxxxxx |
| EC2_HOST | <IP_EC2> |
| EC2_USER | ubuntu |
| SSH_PRIVATE_KEY | Isi lengkap key.pem Anda |
Cek Hasilnya
📊 Monitoring Stack
Buat Folder & File Konfigurasi
mkdir monitoring && cd monitoring
nano docker-compose.yml
nano prometheus.yml
Jalankan Stack
docker compose up -d
Akses Dashboard
- 📈 Grafana:
http://<EC2_IP>:3001| Default:admin/admin
- 🕵️ Prometheus:
http://<EC2_IP>:9090
- 📈 Grafana:
Hubungkan Grafana ke Prometheus
Settings → Data Sources → Add Prometheus → URL: http://prometheus:9090 → Save & Test
Buat Panel Dashboard (Contoh PromQL)
- CPU:
node_cpu_seconds_total
- RAM:
node_memory_MemAvailable_bytes
- Load:
node_load1
- CPU:
📁 Project Structure
📦 repo-root
├── 📂 .github/workflows/
│ └── deploy.yml # CI/CD Pipeline
├── 📄 Dockerfile # Node.js Builder → Nginx
├── 📂 monitoring/
│ ├── docker-compose.yml # Monitoring Stack
│ └── prometheus.yml # Prometheus Config
└── 📂 src/ # Source Code Aplikasi
⚠️ Troubleshooting & Catatan
- 🔐 Pastikan Security Group EC2 membuka port:
80,443,8080,3001,9090. - 🔄 Port
proxy_passdi Nginx (8080) harus sesuai dengan port mapping container lokal. Di EC2, CI/CD langsung map ke port80. - 🐳 Token DockerHub bisa dibuat di: DockerHub → Settings → Security → Access Tokens.
- 🔑
SSH_PRIVATE_KEYdi GitHub Secrets harus berisi seluruh isi file.pem(termasuk-----BEGIN...dan-----END...).

SOCIAL SHARE CARD GENERATOR