docker test 3

This commit is contained in:
mwisnowski 2025-08-21 09:35:32 -07:00
parent ae608ed6a3
commit 1b07d4d4e0
5 changed files with 139 additions and 17 deletions

View file

@ -2,20 +2,41 @@
## Quick Start (Recommended)
### Linux/Remote Host (Interactive Applications)
```bash
# Make scripts executable (one time only)
chmod +x quick-start.sh run-docker-linux.sh
# Simplest method - just run this:
./quick-start.sh
# Or use the full script with more options:
./run-docker-linux.sh compose
```
### Windows (PowerShell)
```powershell
# Run with Docker Compose (easiest method)
# Run with Docker Compose
.\run-docker.ps1 compose
```
### Linux/macOS
```bash
# Make script executable (one time only)
chmod +x run-docker.sh
## Important: Interactive Applications & Docker Compose
# Run with Docker Compose
./run-docker.sh compose
```
**Your MTG Deckbuilder is an interactive application** that uses menus and requires keyboard input. This creates special requirements:
### ✅ What Works for Interactive Apps:
- `docker run -it` (manual)
- `docker-compose run` (recommended)
- `./quick-start.sh` (easiest)
### ❌ What Doesn't Work:
- `docker-compose up` (runs in background, no interaction)
- Running without `-it` flags
### Why the Difference?
- **`docker-compose up`**: Starts services in the background, doesn't attach to your terminal
- **`docker-compose run`**: Creates a new container and attaches to your terminal for interaction
## Manual Docker Commands

View file

@ -0,0 +1,20 @@
version: '3.8'
services:
mtg-deckbuilder-interactive:
build: .
container_name: mtg-deckbuilder-interactive
stdin_open: true
tty: true
volumes:
- ${PWD}/deck_files:/app/deck_files
- ${PWD}/logs:/app/logs
- ${PWD}/csv_files:/app/csv_files
environment:
- PYTHONUNBUFFERED=1
- TERM=xterm-256color
- DEBIAN_FRONTEND=noninteractive
# Don't restart automatically
restart: "no"
# Remove container when stopped
remove: true

View file

@ -4,8 +4,9 @@ services:
mtg-deckbuilder:
build: .
container_name: mtg-deckbuilder
stdin_open: true
tty: true
stdin_open: true # Equivalent to docker run -i
tty: true # Equivalent to docker run -t
profiles: ["interactive"] # Only run when specifically requested
volumes:
# Mount local directories to container for persistence (Linux paths)
- ${PWD}/deck_files:/app/deck_files
@ -14,5 +15,6 @@ services:
environment:
- PYTHONUNBUFFERED=1
- TERM=xterm-256color
- DEBIAN_FRONTEND=noninteractive
# Ensure proper cleanup
restart: "no"

32
quick-start.sh Normal file
View file

@ -0,0 +1,32 @@
#!/bin/bash
# Simple MTG Deckbuilder runner with proper interactivity
echo "MTG Deckbuilder - Quick Start"
echo "=============================="
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Create directories if they don't exist
echo -e "${GREEN}Setting up directories...${NC}"
mkdir -p deck_files logs csv_files
# Check which compose command is available
if command -v docker-compose &> /dev/null; then
COMPOSE_CMD="docker-compose"
elif docker compose version &> /dev/null; then
COMPOSE_CMD="docker compose"
else
echo "Error: Neither docker-compose nor 'docker compose' is available"
exit 1
fi
echo -e "${GREEN}Using: $COMPOSE_CMD${NC}"
echo -e "${YELLOW}Starting MTG Deckbuilder...${NC}"
echo "Press Ctrl+C to exit when done"
echo ""
# Run with the interactive compose file
$COMPOSE_CMD -f docker-compose.interactive.yml run --rm mtg-deckbuilder-interactive

View file

@ -33,14 +33,19 @@ print_debug() {
show_help() {
echo ""
echo -e "${YELLOW}Available commands:${NC}"
echo " ./run-docker-linux.sh setup - Initial setup (create directories, check Docker)"
echo " ./run-docker-linux.sh build - Build the Docker image"
echo " ./run-docker-linux.sh run - Run with manual volume mounting"
echo " ./run-docker-linux.sh compose - Use docker-compose (recommended)"
echo " ./run-docker-linux.sh debug - Run with debug info and volume verification"
echo " ./run-docker-linux.sh clean - Remove containers and images"
echo " ./run-docker-linux.sh help - Show this help"
echo " ./run-docker-linux.sh setup - Initial setup (create directories, check Docker)"
echo " ./run-docker-linux.sh build - Build the Docker image"
echo " ./run-docker-linux.sh run - Run with manual volume mounting"
echo " ./run-docker-linux.sh compose - Use docker-compose run (recommended for interactive)"
echo " ./run-docker-linux.sh compose-build - Build and run with docker-compose"
echo " ./run-docker-linux.sh compose-up - Use docker-compose up (not recommended for interactive)"
echo " ./run-docker-linux.sh debug - Run with debug info and volume verification"
echo " ./run-docker-linux.sh clean - Remove containers and images"
echo " ./run-docker-linux.sh help - Show this help"
echo ""
echo -e "${BLUE}For interactive applications like MTG Deckbuilder:${NC}"
echo -e "${BLUE} - Use 'compose' or 'run' commands${NC}"
echo -e "${BLUE} - Avoid 'compose-up' as it doesn't handle input properly${NC}"
}
setup_directories() {
@ -135,6 +140,48 @@ case "$1" in
print_debug "Using compose command: $COMPOSE_CMD"
print_debug "Working directory: $(pwd)"
print_status "Starting interactive session..."
print_warning "Use Ctrl+C to exit when done"
# Run with compose in interactive mode
$COMPOSE_CMD run --rm mtg-deckbuilder
;;
"compose-build")
print_status "Building and running MTG Deckbuilder with Docker Compose..."
# Ensure directories exist
setup_directories
# Check for compose command
check_docker
print_debug "Using compose command: $COMPOSE_CMD"
print_debug "Working directory: $(pwd)"
print_status "Building image and starting interactive session..."
print_warning "Use Ctrl+C to exit when done"
# Build and run with compose in interactive mode
$COMPOSE_CMD build
$COMPOSE_CMD run --rm mtg-deckbuilder
;;
"compose-up")
print_status "Running MTG Deckbuilder with Docker Compose UP (not recommended for interactive apps)..."
# Ensure directories exist
setup_directories
# Check for compose command
check_docker
print_debug "Using compose command: $COMPOSE_CMD"
print_debug "Working directory: $(pwd)"
print_warning "This may not work properly for interactive applications!"
print_warning "Use 'compose' command instead for better interactivity"
# Run with compose
$COMPOSE_CMD up --build
;;