Skip to content

gujarathisampath/docker-heatmap

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐳 Docker Heatmap

Generate beautiful GitHub-style contribution heatmaps for your Docker Hub activity. Embed in your README and showcase your container contributions.

Docker Heatmap Preview

✨ Features

  • πŸ” GitHub OAuth - Secure authentication with your GitHub account
  • πŸ“Š Beautiful Heatmaps - GitHub-style SVG contribution graphs
  • πŸ”— Easy Embedding - Copy-paste URLs for README or any website
  • πŸ”’ Secure Storage - AES-256 encrypted token storage (zero plaintext)
  • ⚑ Auto Refresh - Background jobs keep data up-to-date
  • πŸ“‘ Public API - JSON endpoints for custom integrations

πŸ›  Tech Stack

Layer Technology
Frontend Next.js 14, TypeScript, Tailwind CSS, shadcn/ui, TanStack Query, Zod
Backend Go, GoFiber, GORM
Database PostgreSQL
Auth GitHub OAuth
Infrastructure Docker, Docker Compose

πŸ“ Project Structure

docker-heatmap/
β”œβ”€β”€ frontend/           # Next.js frontend
β”‚   β”œβ”€β”€ app/           # App router pages
β”‚   β”œβ”€β”€ components/    # UI components
β”‚   β”œβ”€β”€ lib/           # Utilities & API client
β”‚   β”œβ”€β”€ context/       # React contexts
β”‚   └── hooks/         # Custom hooks
β”œβ”€β”€ backend/           # Go backend
β”‚   β”œβ”€β”€ cmd/           # Entry point
β”‚   └── internal/
β”‚       β”œβ”€β”€ config/    # Configuration
β”‚       β”œβ”€β”€ database/  # Database connection
β”‚       β”œβ”€β”€ handlers/  # HTTP handlers
β”‚       β”œβ”€β”€ middleware/# Auth & rate limiting
β”‚       β”œβ”€β”€ models/    # GORM models
β”‚       β”œβ”€β”€ services/  # Business logic
β”‚       β”œβ”€β”€ utils/     # Utilities
β”‚       └── worker/    # Background jobs
β”œβ”€β”€ infra/             # Infrastructure
β”‚   β”œβ”€β”€ docker-compose.yml
β”‚   └── nginx/
└── .env.example       # Environment template

πŸš€ Quick Start

Prerequisites

  • Node.js 20+ (or Bun)
  • Go 1.21+
  • Docker & Docker Compose
  • PostgreSQL (or use Docker)

1. Clone & Setup

git clone https://github.com/yourusername/docker-heatmap.git
cd docker-heatmap

# Copy environment template
cp .env.example .env

2. Configure GitHub OAuth

  1. Go to GitHub Developer Settings
  2. Create a new OAuth App:
    • Homepage URL: http://localhost:3000
    • Callback URL: http://localhost:8080/api/auth/github/callback
  3. Copy Client ID and Secret to .env

3. Start Database & Backend (Docker)

cd infra
docker-compose up -d

4. Start Frontend

cd frontend
npm install  # or: bun install
npm run dev  # or: bun dev

5. Open App

Visit http://localhost:3000

πŸ”§ Configuration

Environment Variables

Variable Description Required
GITHUB_CLIENT_ID GitHub OAuth Client ID βœ…
GITHUB_CLIENT_SECRET GitHub OAuth Secret βœ…
JWT_SECRET Secret for JWT signing βœ…
ENCRYPTION_KEY 32-char key for AES-256 βœ…
DATABASE_URL PostgreSQL connection string βœ…
FRONTEND_URL Frontend URL for CORS βœ…
PORT Backend port (default: 8080) ❌

Generating Secrets

# JWT Secret
openssl rand -hex 32

# Encryption Key (exactly 32 characters)
openssl rand -base64 24 | head -c 32

πŸ“‘ API Endpoints

Authentication

Method Endpoint Description
GET /api/auth/github Start GitHub OAuth
GET /api/auth/github/callback OAuth callback
POST /api/auth/logout Logout

User

Method Endpoint Description
GET /api/user/me Get current user
PUT /api/user/me Update profile
GET /api/user/embed Get embed codes

Docker

Method Endpoint Description
POST /api/docker/connect Connect Docker Hub
GET /api/docker/account Get connected account
DELETE /api/docker/disconnect Disconnect account
POST /api/docker/sync Trigger sync

Public (Embeddable)

Method Endpoint Description
GET /api/heatmap/:username.svg SVG heatmap
GET /api/activity/:username.json Activity JSON
GET /api/profile/:username Profile data

🎨 Embedding Your Heatmap

Markdown (GitHub README)

![Docker Activity](https://api.dockerheatmap.dev/api/heatmap/your-docker-username.svg)

HTML

<img
  src="https://api.dockerheatmap.dev/api/heatmap/your-docker-username.svg"
  alt="Docker Activity"
/>

With Link

<a href="https://dockerheatmap.dev/profile/your-docker-username">
  <img
    src="https://api.dockerheatmap.dev/api/heatmap/your-docker-username.svg"
    alt="Docker Activity"
  />
</a>

πŸ— Development

Backend Only

cd backend
go mod download
go run cmd/main.go

Frontend Only

cd frontend
npm install
npm run dev

Full Stack (Docker)

cd infra
docker-compose up --build

🚒 Production Deployment

VPS with Docker

  1. Create and configure infra/.env.server:
    cp .env.example infra/.env.server
    # Edit infra/.env.server with production values
  2. Run Docker Compose:
    cd infra
    docker-compose up -d --build

Environment for Production

ENVIRONMENT=production
FRONTEND_URL=https://dockerheatmap.dev
GITHUB_CALLBACK_URL=https://api.dockerheatmap.dev/api/auth/github/callback

πŸ” Security

  • Token Encryption: Docker Hub tokens are encrypted with AES-256-GCM
  • OAuth State: CSRF protection with state tokens
  • Rate Limiting: Different tiers for API, auth, and public endpoints with memory protection
  • JWT Auth: Stateless authentication with 7-day expiry
  • Security Headers: X-Content-Type-Options, X-Frame-Options, HSTS, Referrer-Policy
  • Input Validation: Username format validation and token length checks
  • XSS Prevention: SVG output is sanitized to prevent script injection
  • Non-root Docker: Container runs as unprivileged user
  • Production Guards: App fails to start with default secrets in production
  • Request Limits: Body size limited to 1MB to prevent DoS

πŸ“„ License

MIT License - see LICENSE for details.

🀝 Contributing

Contributions are welcome! Please open an issue or submit a PR.


Made with ❀️ for the Docker community

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 52.1%
  • Go 44.9%
  • JavaScript 1.7%
  • Other 1.3%