Thanks to visit codestin.com
Credit goes to github.com

Skip to content

UberMetroid/snake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

73 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Snake β€” Traditional Arcade Game snake logo

Snake is a self-hosted traditional arcade-style snake game application designed for home servers and NAS systems. Built with a high-performance Rust (Axum/Tokio) backend and a WebAssembly (Yew) frontend.


πŸ›οΈ Architecture & Stack

  • Frontend: Yew (WASM)
  • Backend: Axum (Rust) / Tokio
  • Deployment: UBI container (Red Hat UBI9) on Docker Hub / Unraid / Podman / Docker Compose

🟒 Key Features

  • Traditional Arcade Loop: Classic gameplay with grid rendering, score tracking, and persistent high scores.
  • Gold Food Mode: Flashing Gold Food that expires in 5 seconds (with a dynamic visual countdown bar) and awards +30 points.
  • High Score Leaderboard: Persists the Top 10 player scores using simple file-based JSON storage (leaderboard.json).
  • Sleek Neon Theme: Dark retro-futuristic styling matching the Super Metroid theme design system.
  • Mobile-Friendly D-Pad: Integrated touch/D-Pad controls overlay for easy play on mobile and tablets.
  • Access PIN Security: Lock down the interface with an optional numerical PIN for absolute privacy.

πŸ’Ύ Deployment & Installation

Container images (Docker Hub)

Images are UBI9-minimal based (Red Hat Universal Base Image). Tags:

Tag Meaning
latest Current recommended build
ubi Explicit UBI image (same lineage as latest)
1.0.43 Immutable release pin
# Pull examples
podman pull docker.io/ubermetroid/snake:latest
podman pull docker.io/ubermetroid/snake:ubi
podman pull docker.io/ubermetroid/snake:1.0.43

Hub: https://hub.docker.com/r/ubermetroid/snake

Docker Compose

Create a docker-compose.yml file with the following service definition:

services:
  snake:
    image: ubermetroid/snake:latest
    container_name: snake
    restart: unless-stopped
    volumes:
      - ${SNAKE_DATA_PATH:-./data}:/app/data
    ports:
      - ${PORT:-4501}:4501
    environment:
      PORT: 4501
      BASE_URL: ${SNAKE_BASE_URL:-http://localhost:4501}
      SNAKE_PIN: ${SNAKE_PIN:-}
      ALLOWED_ORIGINS: ${SNAKE_ALLOWED_ORIGINS:-*}
      MAX_ATTEMPTS: ${MAX_ATTEMPTS:-5}
      SITE_TITLE: ${SNAKE_SITE_TITLE:-Snake}
      ENABLE_TRANSLATION: ${ENABLE_TRANSLATION:-true}
      ENABLE_THEMES: ${ENABLE_THEMES:-true}
      ENABLE_PRINT: ${ENABLE_PRINT:-true}
      TZ: ${TZ:-UTC}

Build the UBI image locally

Requires Podman (or Docker) and network access to pull base images and crates.

# From the repository root
podman build --format docker -f Containerfile.ubi \
  -t docker.io/ubermetroid/snake:1.0.43 \
  -t docker.io/ubermetroid/snake:latest \
  -t docker.io/ubermetroid/snake:ubi \
  .

# Optional: push all three tags
podman push docker.io/ubermetroid/snake:1.0.43
podman push docker.io/ubermetroid/snake:latest
podman push docker.io/ubermetroid/snake:ubi

βš™οΈ Configuration Options

Environment Variable Description Default
PORT The port number the backend HTTP server will bind to inside the container. 4501
SITE_TITLE Custom website title rendered in navigation headers, browser tabs, and PWA manifest. Snake
BASE_URL Application base URL. http://localhost:4501
ALLOWED_ORIGINS Comma-separated list of allowed HTTP request origins (CORS filter). *
SNAKE_PIN Optional numerical PIN to lock access to the interface. None
TZ Timezone for the container processes and logs. UTC
ENABLE_TRANSLATION Enable the multi-language / translation selector in the navigation header. true
ENABLE_THEMES Enable the Super Metroid theme selector in the navigation header. true
ENABLE_PRINT Enable the print button in the navigation header. true
MAX_ATTEMPTS Maximum PIN auth attempts allowed before rate lockout. 5
SNAKE_DATA_DIR Directory where runtime state is persisted (leaderboard.json). ./data
SNAKE_FRONTEND_DIR Path to the prebuilt Trunk SPA bundle. ./frontend/dist

πŸ› οΈ Local Development

Ensure you have the Rust toolchain and Trunk installed.

# 1. Run workspace tests
cargo test

# 2. Run clippy workspace checks
cargo clippy --workspace --all-targets

# 3. Start frontend Yew dev server (from frontend/)
cd frontend && trunk serve

# 4. Start backend Axum server (from backend/)
cd backend && cargo run

πŸ“„ License

Licensed under the Apache License, Version 2.0. Copyright 2026 UberMetroid.

About

Snake is a self-hosted, lightweight traditional snake game application built in Rust with Yew and Axum.

Resources

License

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Sponsor this project

Contributors