A synchronized chess clock on Web.
リアルタイムで同期する対局時計(チェスクロック)を複数人がインターネット経由で操作できるWebアプリです。スマートフォン、タブレット対応(レスポンシブ)。
Before setting up the project, ensure you have the following installed:
- Node.js (version 12 or higher)
- npm (comes with Node.js)
- Redis (for real-time synchronization)
- Local installation: Redis Download
- Docker:
docker run -d -p 6379:6379 redis:alpine - Cloud options: Upstash, Redis Cloud, AWS ElastiCache
# Clone the repository
git clone <repository-url>
cd webchessclock
# Install dependencies
npm install
# Copy environment variables template
cp .env.example .env# Option 1: Use local Redis (requires Redis running on localhost:6379)
npm run dev:local
# Option 2: Use custom Redis URL (configure REDIS_URL in .env)
npm run devThe application will be available at http://localhost:3000
If you prefer using Docker for development:
# Start development environment with Docker
npm run dev:dockerThis will start both the application and Redis using Docker Compose.
The application uses environment variables for configuration. Copy .env.example to .env and update the values:
NODE_ENV: Environment mode (development,production,test)REDIS_URL: Redis connection URL for real-time synchronization
PORT: Server port (default: 3000)HOST: Server host (default: localhost for development, 0.0.0.0 for production)MAX_PLAYERS_PER_ROOM: Maximum players per roomSESSION_TIMEOUT: Redis key expiration time in secondsDEBUG: Enable debug logging (true/false)CORS_ORIGINS: Comma-separated list of allowed origins for production
See .env.example for detailed configuration options and examples.
# Start development server with Docker (RECOMMENDED)
npm run dev
# Start Docker development in background
npm run dev:detached
# Start native development (requires Node.js 14-18)
npm run dev:native
# Start native with local Redis (requires Node.js 14-18)
npm run dev:native:redis# Build for production
npm run build
# Start production server (requires build first)
npm run start
# Generate static files
npm run generate# Build Docker image
npm run docker:build
# Run Docker container
npm run docker:run
# Start services (detached)
npm run docker:up
# Stop services
npm run docker:down
# Rebuild development environment
npm run dev:docker:rebuild# Deploy to Fly.io
npm run deploy:fly
# Setup Fly.io deployment
npm run deploy:setup# Test Redis connection
npm run test:redis
# Clean build artifacts and cache
npm run cleanThis project uses GitHub Actions for automated testing, building, and deployment:
- Automated Testing: Runs tests on Node.js 18 and 20
- Docker Build: Builds and pushes to GitHub Container Registry
- Security Scanning: Vulnerability scanning with Trivy
- Automated Deployment: Deploys to Fly.io on master branch
- Rollback Support: Automatic rollback on deployment failure
For CI/CD to work, configure these secrets in your GitHub repository:
FLY_API_TOKEN=your_fly_api_token
Get your Fly.io API token with: flyctl auth token
Push to master branch triggers automatic deployment:
git push origin masterTrigger deployment manually via GitHub Actions or:
This application is configured for easy deployment to Fly.io:
-
Install Fly CLI: Follow Fly.io installation guide
-
Setup deployment:
npm run deploy:setup
-
Configure environment variables:
fly secrets set REDIS_URL=rediss://your-redis-url fly secrets set NODE_ENV=production
-
Deploy:
npm run deploy:fly
For Docker-based deployments:
-
Build the image:
npm run docker:build
-
Run with environment file:
npm run docker:run
-
Or use Docker Compose:
npm run docker:up
- Ensure Redis instance has persistence enabled
- Configure CORS origins for your domain
- Set appropriate session timeouts
- Use HTTPS in production
- Monitor Redis memory usage
For detailed explanation on how things work, check out Nuxt.js docs.
MIT License. See LICENSE for details.