Skip to content

dikag0d/cobaa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐳 Docker + GitHub Codespaces Demo

Project demo untuk belajar menggunakan Docker di GitHub Codespaces lengkap dengan automated testing via GitHub Actions.

πŸ“ Struktur Project

cobaa/
β”œβ”€β”€ app.js                 # Express API server
β”œβ”€β”€ test.js                # Automated test suite
β”œβ”€β”€ package.json           # Node.js dependencies
β”œβ”€β”€ Dockerfile             # Multi-stage Docker build
β”œβ”€β”€ docker-compose.yml     # Docker Compose (app + test)
β”œβ”€β”€ .dockerignore
β”œβ”€β”€ .gitignore
β”œβ”€β”€ .devcontainer/
β”‚   └── devcontainer.json  # GitHub Codespaces config
└── .github/
    └── workflows/
        └── docker-test.yml # CI/CD pipeline

πŸš€ Cara Pakai

Option 1: Buka di GitHub Codespaces

  1. Push repo ini ke GitHub
  2. Buka repository di GitHub
  3. Klik tombol <> Code β†’ Codespaces β†’ Create codespace on main
  4. Tunggu environment siap (Docker sudah otomatis tersedia!)
  5. Di terminal Codespaces, jalankan:
# Build & run
docker compose up --build

# Buka tab baru, test
docker compose --profile test run --rm test

Option 2: Run Lokal (butuh Docker terinstall)

# Clone repo
git clone https://github.com/USERNAME/cobaa.git
cd cobaa

# Build & run app
docker compose up --build -d

# Jalankan test
docker compose --profile test run --rm test

# Stop
docker compose down

Option 3: Tanpa Docker (Node.js langsung)

npm install
npm start          # Start server di port 3000
# Buka terminal baru:
npm test           # Jalankan test suite

πŸ§ͺ Testing

Manual Test (curl)

# Health check
curl http://localhost:3000/health

# Info endpoint
curl http://localhost:3000/info

# Echo endpoint
curl -X POST http://localhost:3000/echo \
  -H "Content-Type: application/json" \
  -d '{"hello": "docker"}'

Automated Test via Docker Compose

# Ini akan build app, tunggu healthy, lalu jalankan test suite
docker compose --profile test run --rm test

Automated Test via GitHub Actions

Setiap kali kamu push atau buat Pull Request, GitHub Actions akan otomatis:

  1. βœ… Build Docker image
  2. βœ… Start container & tunggu healthy
  3. βœ… Jalankan test suite
  4. βœ… Cleanup

Cek hasilnya di tab Actions di repository GitHub kamu.

πŸ“‹ API Endpoints

Method Path Deskripsi
GET / Info tentang API
GET /health Health check (untuk Docker)
GET /info System info (Node, memory)
POST /echo Echo back request body

πŸ”§ Setup GitHub Repository

# Init git repo
git init
git add .
git commit -m "🐳 Initial: Docker + Codespaces demo"

# Push ke GitHub
git remote add origin https://github.com/USERNAME/cobaa.git
git branch -M main
git push -u origin main

Note: Ganti USERNAME dengan username GitHub kamu.

πŸ“– Cara Kerja

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  GitHub Codespaces                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  devcontainer (Node.js 20)            β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚  β”‚  Docker-in-Docker               β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  β”‚  web:3000  β”‚  β”‚   test    β”‚   β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  β”‚  (app.js)  β”‚β†’ β”‚ (test.js) β”‚   β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  GitHub Actions (CI/CD)                     β”‚
β”‚  push/PR β†’ build image β†’ run β†’ test β†’ βœ…    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

About

🐳 Docker + GitHub Codespaces Demo with Automated Testing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors