This document explains how to run the FitGirl Repacks application using Docker containers with Redis for data storage.
The application consists of:
- Next.js App: Frontend and API server
- Redis: Data storage for game information
- Data Loader: Script to import JSON data into Redis
- Docker and Docker Compose installed
- Results directory with JSON files (results_page_*.json)
-
Start the development environment:
docker-compose -f docker/docker-compose.dev.yml up --build
-
Load data into Redis:
# In a new terminal, run the data loader docker-compose -f docker-compose.dev.yml run --rm data-loader -
Access the application:
- Frontend: http://localhost:3000
- Redis: localhost:6379
-
Start the production environment:
docker-compose up --build
-
Load data into Redis:
# The data loader will run automatically # You can also run it manually: docker-compose run --rm data-loader
-
Access the application:
- Frontend: http://localhost:3000
- Redis: localhost:6379
βββ docker/
β βββ Dockerfile # Production Docker image
β βββ Dockerfile.dev # Development Docker image
β βββ docker-compose.yml # Production services
β βββ docker-compose.dev.yml # Development services
βββ scripts/
β βββ load-data.js # Data loader script (CommonJS)
β βββ load-data.mjs # Data loader script (ES Modules)
βββ src/
β βββ app/
β β βββ api/ # API routes
β βββ lib/
β β βββ redis.ts # Redis client and operations
β βββ components/ # React components
βββ results/ # JSON data files
REDIS_URL: Redis connection string (default: redis://localhost:6379)NODE_ENV: Environment mode (development/production)
- app: Next.js application (production build)
- redis: Redis database
- data-loader: One-time data import service
- app: Next.js application (development mode with hot reload)
- redis: Redis database
- data-loader: Data import service
The application loads game data from JSON files in the results/ directory into Redis.
Each JSON file should contain an array of game objects with the following structure:
[
{
"title": "Game Title",
"image": "image_url",
"tags": ["Action", "RPG"],
"description": "Game description",
"url": "game_url",
"metadata": {
"companies": "Developer, Publisher",
"languages": "ENG/MULTI",
"originalSize": "50 GB",
"repackSize": "25 GB"
},
"repackFeatures": ["Feature 1", "Feature 2"]
}
]- Automatic Loading: The data loader runs automatically when starting the containers
- Manual Loading: Run the data loader manually:
# Development docker-compose -f docker/docker-compose.dev.yml run --rm data-loader # Production docker-compose run --rm data-loader
GET /api/games- Get all games with filtering and paginationGET /api/games/[id]- Get a specific game by IDGET /api/games/stats- Get game statistics
q: Search querygenre: Filter by genre (comma-separated)size: Filter by maximum sizelanguage: Filter by language (comma-separated)sortBy: Sort field (title, releaseDate, size)sortOrder: Sort order (asc, desc)page: Page number for paginationlimit: Number of items per page
-
Install dependencies:
npm install
-
Start Redis:
docker-compose -f docker/docker-compose.dev.yml up redis -d
-
Load data:
node scripts/load-data.js
-
Start development server:
npm run dev
# Production image
docker build -t fitgirl-repacks:latest .
# Development image
docker build -f docker/Dockerfile.dev -t fitgirl-repacks:dev .-
Build and start services:
docker-compose up --build -d
-
Verify services are running:
docker-compose ps
-
Check logs:
docker-compose logs -f app
To scale the application:
# Scale the app service
docker-compose up --scale app=3 -d
# Use a load balancer (nginx, traefik, etc.)- Application: http://localhost:3000/api/health
- Redis:
docker-compose exec redis redis-cli ping
# View all logs
docker-compose logs
# View specific service logs
docker-compose logs app
docker-compose logs redis
# Follow logs in real-time
docker-compose logs -f# Clear Redis data
docker-compose exec redis redis-cli FLUSHALL
# Reload data
docker-compose run --rm data-loader
# Backup Redis data
docker-compose exec redis redis-cli BGSAVE# Stop all services
docker-compose down
# Stop and remove volumes
docker-compose down -v
# Rebuild and restart
docker-compose up --build --force-recreate
# Clean up unused resources
docker system prune -a-
Redis Connection Error
- Check if Redis container is running:
docker-compose ps - Verify Redis URL in environment variables
- Check Redis logs:
docker-compose logs redis
- Check if Redis container is running:
-
Data Loading Issues
- Ensure JSON files are in the
results/directory - Check file permissions
- Verify JSON format is correct
- Ensure JSON files are in the
-
Application Not Starting
- Check application logs:
docker-compose logs app - Verify port 3000 is not in use
- Check environment variables
- Check application logs:
-
Performance Issues
- Monitor Redis memory usage
- Consider Redis persistence configuration
- Check application resource usage
# Access Redis CLI
docker-compose exec redis redis-cli
# Access application container
docker-compose exec app sh
# Check Redis data
docker-compose exec redis redis-cli KEYS "*"
# Monitor Redis operations
docker-compose exec redis redis-cli MONITORFor production, consider:
- Redis persistence (RDB/AOF)
- Memory limits
- Connection pooling
- Redis clustering for high availability
- Enable Next.js caching
- Use Redis for session storage
- Implement API response caching
- Optimize database queries
- Use Redis authentication
- Configure firewall rules
- Use HTTPS in production
- Implement rate limiting
- Regular security updates
Store sensitive data in environment variables:
# .env file
REDIS_URL=redis://:password@redis:6379
NODE_ENV=production