Snake game with Docker setup
- HTML 97.1%
- Dockerfile 2.9%
- Single-file canvas Snake game (dark theme, animated food, directional eyes) - Speed increases as score grows; high score saved in localStorage - Dockerfile using nginx:alpine to serve the game - docker-compose.yml mapping port 8080 - Custom nginx.conf with gzip and security headers - README with usage instructions |
||
|---|---|---|
| docker-compose.yml | ||
| Dockerfile | ||
| index.html | ||
| nginx.conf | ||
| README.md | ||
🐍 Snake Game
A classic Snake game served via Docker + nginx. Dark theme, canvas-based renderer, smooth gameplay, and high score persistence.
Quick Start
With Docker Compose (recommended)
docker compose up --build
Then open http://localhost:8080 in your browser.
To stop:
docker compose down
With Docker only
docker build -t snake-game .
docker run -d -p 8080:80 --name snake-game snake-game
Stop and remove:
docker stop snake-game && docker rm snake-game
Controls
| Key | Action |
|---|---|
↑ ↓ ← → or W A S D |
Move the snake |
P |
Pause / Resume |
R |
Restart (after game over) |
Features
- Canvas-based renderer with a dark theme
- Smooth food glow / pulse animation
- Snake head with directional "eyes"
- Speed increases as you eat more food
- High score stored in
localStorage(persists across page reloads) - Lightweight — single HTML file, zero dependencies, served by nginx:alpine
Project Structure
snake-game/
├── index.html # The complete game (HTML + CSS + JS)
├── Dockerfile # nginx:alpine image
├── nginx.conf # nginx server config (gzip, headers)
├── docker-compose.yml
└── README.md