zkt26/sk1/README.md

117 lines
3.6 KiB
Markdown

# Task Manager — Cloud Deployment (SK1)
A full-stack task management web application deployed to **Microsoft Azure** using Docker Compose.
## 🏗️ Architecture
![Architecture](docs/architecture.png)
| Container | Image | Port | Purpose |
|-----------|-------|------|---------|
| **Caddy** | caddy:2-alpine | 443, 80 | Reverse proxy + automatic HTTPS (Let's Encrypt) |
| **Frontend** | nginx:alpine | 80 | Static files + API reverse proxy |
| **API** | node:20-alpine | 3000 | Express REST API (CRUD) |
| **PostgreSQL** | postgres:16-alpine | 5432 | Persistent relational database |
| **Redis** | redis:7-alpine | 6379 | In-memory cache |
## 🚀 Quick Deploy
```bash
# 1. Login to Azure (requires Azure for Students subscription)
az login
# 2. Clone and configure
git clone git@git.kemt.fei.tuke.sk:gs699he/zkt26.git
cd zkt26/sk1
cp env.example .env
nano .env # Set POSTGRES_PASSWORD, optionally change DNS_LABEL
# 3. Deploy (creates VM, installs Docker, starts containers)
./prepare-app.sh
# 4. Visit: https://taskmanager-gs699he.westeurope.cloudapp.azure.com
```
## 🗑️ Remove (after exam)
```bash
./remove-app.sh # Deletes entire resource group (VM, IP, disk)
```
## 💾 Backup & Logs
```bash
./backup-db.sh # Download database dump
./view-logs.sh # All container logs
./view-logs.sh --api -f # Follow API logs in real-time
```
## 📁 Project Structure
```
sk1/
├── api/ # Node.js REST API
│ ├── Dockerfile
│ ├── server.js # Express + CRUD routes
│ ├── db.js # PostgreSQL pool
│ └── package.json
├── frontend/ # Web UI
│ ├── Dockerfile
│ ├── nginx.conf
│ └── public/ (index.html, style.css, app.js)
├── db/init.sql # Database schema
├── caddy/Caddyfile # HTTPS proxy config
├── docs/
│ ├── architecture.png # Architecture diagram
│ ├── documentation.tex # LaTeX source
│ └── documentation.pdf # 9-page PDF report
├── docker-compose.yaml # 5-service orchestration
├── cloud-init.yaml # VM bootstrap (Docker install)
├── prepare-app.sh # Azure deployment script
├── remove-app.sh # Azure teardown script
├── backup-db.sh # Database backup
├── view-logs.sh # Access log viewer
├── env.example # Environment template
├── .gitignore
└── README.md
```
## ⚙️ Configuration
| Variable | Description | Default |
|----------|-------------|---------|
| `POSTGRES_PASSWORD` | Database password | *(required)* |
| `AZURE_RESOURCE_GROUP` | Azure resource group | taskmanager-rg |
| `AZURE_LOCATION` | Azure region | westeurope |
| `AZURE_VM_SIZE` | VM size | Standard_B1s |
| `AZURE_DNS_LABEL` | DNS label for URL | taskmanager-gs699he |
## 💰 Cost (Azure for Students)
| Resource | Monthly Cost |
|----------|-------------|
| VM (Standard_B1s) | ~$7.59 |
| Public IP | ~$3.00 |
| Disk (30 GB) | ~$1.20 |
| TLS (Let's Encrypt) | Free |
| **Total** | **~$11.79/mo** |
> 💡 Azure for Students gives $100 free credit — enough for ~8 months.
## 🔒 Security
- HTTPS enforced (Caddy + Let's Encrypt)
- Databases on isolated Docker network (`backend-net`)
- Secrets via `.env` (gitignored)
- Security headers in Nginx
- Auto-restart on failure
## 🤖 AI Declaration
- **Google Antigravity (Gemini)**: Scripts, Docker config, LaTeX docs, diagram
- All code reviewed and adapted by student
---
*Technical University of Košice — KEMT FEI — Cloud Technologies — 2026*