From 1b07d4d4e035441f4fe3d8dff195524e36430ae0 Mon Sep 17 00:00:00 2001 From: mwisnowski Date: Thu, 21 Aug 2025 09:35:32 -0700 Subject: [PATCH] docker test 3 --- DOCKER.md | 37 ++++++++++++++++----- docker-compose.interactive.yml | 20 +++++++++++ docker-compose.yml | 6 ++-- quick-start.sh | 32 ++++++++++++++++++ run-docker-linux.sh | 61 ++++++++++++++++++++++++++++++---- 5 files changed, 139 insertions(+), 17 deletions(-) create mode 100644 docker-compose.interactive.yml create mode 100644 quick-start.sh diff --git a/DOCKER.md b/DOCKER.md index ea770f1..83602e3 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -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 diff --git a/docker-compose.interactive.yml b/docker-compose.interactive.yml new file mode 100644 index 0000000..534772d --- /dev/null +++ b/docker-compose.interactive.yml @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 4c59b8e..fa82fc2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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" diff --git a/quick-start.sh b/quick-start.sh new file mode 100644 index 0000000..60722c8 --- /dev/null +++ b/quick-start.sh @@ -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 diff --git a/run-docker-linux.sh b/run-docker-linux.sh index 640f43e..8f91133 100644 --- a/run-docker-linux.sh +++ b/run-docker-linux.sh @@ -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 ;;