A high-performance, containerized Weather API built with Django REST Framework.
This image is self-contained, running both the Django application and a Redis cache server inside a single container using Supervisor.
It fetches live weather data from Visual Crossing (or your provider) and caches the results in Redis to minimize latency and external API usage.
To run this container, you must provide the following environment variables:
| Variable | Description | Required | Default |
|---|---|---|---|
WEATHER_API_KEY | Your API Key from the weather provider | Yes | None |
SECRET_KEY | A random string for Django security | Yes | None |
DEBUG | Set to False for production | No | False |
REDIS_HOST | Hostname for Redis | No | 127.0.0.1 |
REDIS_PORT | Port for Redis | No | 6379 |
Run the container exposing port 8000. You must pass your API key:
docker run -d \
--name weather-api \
-p 8000:8000 \
-e WEATHER_API_KEY="YOUR_ACTUAL_API_KEY" \
-e SECRET_KEY="change-me-to-something-random" \
mohammed237/weather-api
Once the container is running, you can access the API at:
GET http://localhost:8000/weather/{city}/Example:
curl http://localhost:8000/weather/london/
This image uses a monolithic process approach for simplicity in deployment:
supervisordredis-server (starts first, listens on 127.0.0.1:6379)django runserver (starts after Redis, listens on 0.0.0.0:8000)If you want the Redis cache to survive container restarts, mount a volume:
docker run -d \
-p 8000:8000 \
-e WEATHER_API_KEY="YOUR_KEY" \
-v weather_cache:/var/lib/redis \
mohammed237/weather-api
Content type
Image
Digest
sha256:ad62891eb…
Size
51.9 MB
Last updated
11 months ago
docker pull mohammed237/weather-api