2025-08-21 10:28:10 -07:00
|
|
|
# Docker Guide for MTG Python Deckbuilder
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
A comprehensive guide for running the MTG Python Deckbuilder in Docker containers with full file persistence and cross-platform support.
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
## 🚀 Quick Start
|
|
|
|
|
|
|
|
### Linux/macOS/Remote Host
|
2025-08-21 09:35:32 -07:00
|
|
|
```bash
|
|
|
|
# Make scripts executable (one time only)
|
2025-08-21 10:32:36 -07:00
|
|
|
chmod +x quick-start.sh run-docker.sh
|
2025-08-21 09:35:32 -07:00
|
|
|
|
|
|
|
# Simplest method - just run this:
|
|
|
|
./quick-start.sh
|
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
# Or use the full script with options:
|
2025-08-21 10:32:36 -07:00
|
|
|
./run-docker.sh compose
|
2025-08-21 09:35:32 -07:00
|
|
|
```
|
|
|
|
|
2025-08-21 09:19:20 -07:00
|
|
|
### Windows (PowerShell)
|
|
|
|
```powershell
|
2025-08-21 10:28:10 -07:00
|
|
|
# Run with Docker Compose (recommended)
|
2025-08-21 09:19:20 -07:00
|
|
|
.\run-docker.ps1 compose
|
2025-08-21 10:28:10 -07:00
|
|
|
|
|
|
|
# Or manual Docker run
|
|
|
|
docker run -it --rm `
|
|
|
|
-v "${PWD}/deck_files:/app/deck_files" `
|
|
|
|
-v "${PWD}/logs:/app/logs" `
|
|
|
|
-v "${PWD}/csv_files:/app/csv_files" `
|
|
|
|
mtg-deckbuilder
|
2025-08-21 09:19:20 -07:00
|
|
|
```
|
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
## 📋 Prerequisites
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
- **Docker** installed and running
|
|
|
|
- **Docker Compose** (usually included with Docker)
|
|
|
|
- Basic terminal/command line knowledge
|
2025-08-21 09:35:32 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
## 🔧 Available Commands
|
2025-08-21 09:35:32 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
### Quick Start Scripts
|
2025-08-21 09:35:32 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
| Script | Platform | Description |
|
|
|
|
|--------|----------|-------------|
|
|
|
|
| `./quick-start.sh` | Linux/macOS | Simplest way to run the application |
|
|
|
|
| `.\run-docker.ps1 compose` | Windows | PowerShell equivalent |
|
2025-08-21 09:35:32 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
### Full Featured Scripts
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
| Command | Description |
|
|
|
|
|---------|-------------|
|
2025-08-21 10:32:36 -07:00
|
|
|
| `./run-docker.sh setup` | Create directories and check Docker installation |
|
|
|
|
| `./run-docker.sh build` | Build the Docker image |
|
|
|
|
| `./run-docker.sh compose` | Run with Docker Compose (recommended) |
|
|
|
|
| `./run-docker.sh run` | Run with manual volume mounting |
|
|
|
|
| `./run-docker.sh clean` | Remove containers and images |
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
## 🗂️ File Persistence
|
|
|
|
|
|
|
|
Your files are automatically saved to local directories that persist between runs:
|
2025-08-21 09:19:20 -07:00
|
|
|
|
|
|
|
```
|
2025-08-21 10:28:10 -07:00
|
|
|
mtg_python_deckbuilder/
|
|
|
|
├── deck_files/ # Your saved decks (CSV and TXT files)
|
|
|
|
├── logs/ # Application logs and debug info
|
|
|
|
├── csv_files/ # Card database and color-sorted files
|
|
|
|
└── ...
|
|
|
|
```
|
|
|
|
|
|
|
|
### How It Works
|
|
|
|
|
|
|
|
The Docker container uses **volume mounting** to map container directories to your local filesystem:
|
|
|
|
|
|
|
|
- Container path `/app/deck_files` ↔ Host path `./deck_files`
|
|
|
|
- Container path `/app/logs` ↔ Host path `./logs`
|
|
|
|
- Container path `/app/csv_files` ↔ Host path `./csv_files`
|
|
|
|
|
|
|
|
When the application saves files, they appear in your local directories and remain there after the container stops.
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
## 🎮 Interactive Application Requirements
|
|
|
|
|
|
|
|
The MTG Deckbuilder is an **interactive application** that uses menus and requires keyboard input.
|
|
|
|
|
|
|
|
### ✅ Commands That Work
|
|
|
|
- `docker compose run --rm mtg-deckbuilder`
|
|
|
|
- `docker run -it --rm mtg-deckbuilder`
|
|
|
|
- `./quick-start.sh`
|
|
|
|
- Helper scripts with `compose` command
|
|
|
|
|
|
|
|
### ❌ Commands That Don't Work
|
|
|
|
- `docker compose up` (runs in background, no interaction)
|
|
|
|
- `docker run` without `-it` flags
|
|
|
|
- Any command without proper TTY allocation
|
|
|
|
|
|
|
|
### Why the Difference?
|
|
|
|
- **`docker compose run`**: Creates new container with terminal attachment
|
|
|
|
- **`docker compose up`**: Starts service in background without terminal
|
|
|
|
|
|
|
|
## 🔨 Manual Docker Commands
|
|
|
|
|
|
|
|
### Build the Image
|
2025-08-21 09:19:20 -07:00
|
|
|
```bash
|
|
|
|
docker build -t mtg-deckbuilder .
|
2025-08-21 10:28:10 -07:00
|
|
|
```
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
### Run with Full Volume Mounting
|
|
|
|
|
|
|
|
**Linux/macOS:**
|
|
|
|
```bash
|
2025-08-21 09:19:20 -07:00
|
|
|
docker run -it --rm \
|
|
|
|
-v "$(pwd)/deck_files:/app/deck_files" \
|
|
|
|
-v "$(pwd)/logs:/app/logs" \
|
|
|
|
-v "$(pwd)/csv_files:/app/csv_files" \
|
|
|
|
mtg-deckbuilder
|
|
|
|
```
|
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
**Windows PowerShell:**
|
|
|
|
```powershell
|
|
|
|
docker run -it --rm `
|
|
|
|
-v "${PWD}/deck_files:/app/deck_files" `
|
|
|
|
-v "${PWD}/logs:/app/logs" `
|
|
|
|
-v "${PWD}/csv_files:/app/csv_files" `
|
|
|
|
mtg-deckbuilder
|
|
|
|
```
|
|
|
|
|
|
|
|
## 📁 Docker Compose Files
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
The project includes two Docker Compose configurations:
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
### `docker-compose.yml` (Main)
|
|
|
|
- Standard configuration
|
|
|
|
- Container name: `mtg-deckbuilder-main`
|
|
|
|
- Use with: `docker compose run --rm mtg-deckbuilder`
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
Both files provide the same functionality and file persistence.
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
## 🐛 Troubleshooting
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
### Files Not Saving?
|
|
|
|
|
|
|
|
1. **Check volume mounts**: Ensure you see `-v` flags in your docker command
|
|
|
|
2. **Verify directories exist**: Scripts automatically create needed directories
|
|
|
|
3. **Check permissions**: Ensure you have write access to the project directory
|
|
|
|
4. **Use correct command**: Use `docker compose run`, not `docker compose up`
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
### Application Won't Start Interactively?
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
1. **Use the right command**: `docker compose run --rm mtg-deckbuilder`
|
|
|
|
2. **Check TTY allocation**: Ensure `-it` flags are present in manual commands
|
|
|
|
3. **Avoid background mode**: Don't use `docker compose up` for interactive apps
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
### Permission Issues?
|
|
|
|
|
|
|
|
Files created by Docker may be owned by `root`. This is normal on Linux systems.
|
|
|
|
|
|
|
|
### Container Build Fails?
|
|
|
|
|
|
|
|
1. **Update Docker**: Ensure you have a recent version
|
|
|
|
2. **Clear cache**: Run `docker system prune -f`
|
|
|
|
3. **Check network**: Ensure Docker can download dependencies
|
2025-08-21 09:19:20 -07:00
|
|
|
|
|
|
|
### Starting Fresh
|
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
**Complete cleanup:**
|
|
|
|
```bash
|
|
|
|
# Stop all containers
|
|
|
|
docker compose down
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
# Remove image
|
2025-08-21 09:19:20 -07:00
|
|
|
docker rmi mtg-deckbuilder
|
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
# Clean up system
|
|
|
|
docker system prune -f
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
# Rebuild
|
|
|
|
docker compose build
|
|
|
|
```
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
## 🔍 Verifying Everything Works
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
After running the application:
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
1. **Create or modify some data** (run setup, build a deck, etc.)
|
|
|
|
2. **Exit the container** (Ctrl+C or select Quit)
|
|
|
|
3. **Check your local directories**:
|
|
|
|
```bash
|
|
|
|
ls -la deck_files/ # Should show any decks you created
|
|
|
|
ls -la logs/ # Should show log files
|
|
|
|
ls -la csv_files/ # Should show card database files
|
|
|
|
```
|
|
|
|
4. **Run again** - your data should still be there!
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
## 🎯 Best Practices
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
1. **Use the quick-start script** for simplest experience
|
|
|
|
2. **Always use `docker compose run`** for interactive applications
|
|
|
|
3. **Keep your project directory organized** - files persist locally
|
|
|
|
4. **Regularly backup your `deck_files/`** if you create valuable decks
|
|
|
|
5. **Use `clean` commands** to free up disk space when needed
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
## 🌟 Benefits of Docker Approach
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
- ✅ **Consistent environment** across different machines
|
|
|
|
- ✅ **No Python installation required** on host system
|
|
|
|
- ✅ **Isolated dependencies** - won't conflict with other projects
|
|
|
|
- ✅ **Easy sharing** - others can run your setup instantly
|
|
|
|
- ✅ **Cross-platform** - works on Windows, macOS, and Linux
|
|
|
|
- ✅ **File persistence** - your work is saved locally
|
|
|
|
- ✅ **Easy cleanup** - remove everything with one command
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
---
|
2025-08-21 09:19:20 -07:00
|
|
|
|
2025-08-21 10:28:10 -07:00
|
|
|
**Need help?** Check the troubleshooting section above or refer to the helper script help:
|
|
|
|
```bash
|
2025-08-21 10:32:36 -07:00
|
|
|
./run-docker.sh help
|
2025-08-21 10:28:10 -07:00
|
|
|
```
|