Sign inSign up

bidhe1/simple-weather-api

By bidhe1

Updated over 1 year ago

A lightweight Node.js weather API service with a beautiful web interface

Image
Web servers
0

471

bidhe1/simple-weather-api repository overview

Simple Weather API 🌤️

A lightweight, containerized Node.js weather API service with a beautiful web interface. Perfect for learning Docker, API development, and modern web technologies.

🚀 Quick Start

# Pull and run the container
docker run -d -p 3000:3000 --name weather-api bidhe1/simple-weather-api:latest

# Access the application
# Web Interface: http://localhost:3000
# API Endpoint: http://localhost:3000/api/weather/london

✨ Features

  • 🌐 REST API - Clean JSON endpoints for weather data
  • 💫 Web Interface - Beautiful, responsive UI with gradient design
  • 💚 Health Monitoring - Built-in health check endpoint
  • 🔒 Security First - Runs as non-root user, Alpine-based
  • 📦 Lightweight - ~50MB optimized Docker image
  • 🏥 Container Health - Built-in Docker health checks

🌍 API Endpoints

Weather Data
GET /api/weather/:city

Available Cities: london, paris, tokyo, newyork, sydney

Example:

curl http://localhost:3000/api/weather/london

Response:

{
  "city": "london",
  "temperature": 15,
  "condition": "Cloudy",
  "humidity": 78,
  "timestamp": "2025-06-08T10:30:00.000Z"
}
Health Check
GET /health

🔧 Usage Examples

Basic Usage
docker run -p 3000:3000 bidhe1/simple-weather-api
With Custom Port
docker run -p 8080:3000 -e PORT=3000 bidhe1/simple-weather-api
Production Deployment
version: '3.8'
services:
  weather-api:
    image: bidhe1/simple-weather-api:latest
    ports:
      - "3000:3000"
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
      interval: 30s
      timeout: 10s
      retries: 3

🐳 Container Details

  • Base: node:18-alpine (secure & lightweight)
  • Size: ~50MB
  • Port: 3000
  • User: Non-root (nodejs:1001)
  • Health Check: ✅ Included

🌟 What You Get

  1. Interactive Web UI - Point your browser to the container and start exploring weather data immediately
  2. RESTful API - Integrate with your applications using clean JSON endpoints
  3. Production Ready - Security hardened with proper user permissions and health monitoring
  4. Zero Configuration - Works out of the box with sensible defaults

🛠️ Environment Variables

VariableDefaultDescription
PORT3000Server port

📚 Perfect For

  • Learning Docker - Clean, well-documented Dockerfile with best practices
  • API Development - Example of proper REST API structure
  • Frontend Integration - Ready-to-use API for your web applications
  • Container Orchestration - Health checks and proper signal handling
  • Development & Testing - Quick weather API for prototyping

🔍 Try It Now

# Quick test - get London weather
docker run --rm -p 3000:3000 bidhe1/simple-weather-api &
sleep 5
curl http://localhost:3000/api/weather/london

Repository: https://hub.docker.com/r/bidhe1/simple-weather-api

💡 This is a demonstration project with mock data made for devops ex 11.5 of mooc.fi

Tag summary

Content type

Image

Digest

sha256:be0e5daf2

Size

46.2 MB

Last updated

over 1 year ago

docker pull bidhe1/simple-weather-api