From d74ec5ac7326fd0aa55d71cb364a712c919145b9 Mon Sep 17 00:00:00 2001 From: Iain Bradley Date: Sun, 26 Apr 2026 19:32:53 +0100 Subject: [PATCH] Uploading default template --- Dockerfile | 21 +++++ READ_ME.md | 150 ++++++++++++++++++++++++++++++++++++ docker-compose.override.yml | 9 +++ docker-compose.yml | 4 + requirements.txt | 0 5 files changed, 184 insertions(+) create mode 100644 Dockerfile create mode 100644 READ_ME.md create mode 100644 docker-compose.override.yml create mode 100644 docker-compose.yml create mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7b6d261 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.14-slim + +WORKDIR /usr/src/app + +# System upgrades and tmux installation +RUN apt-get update && apt-get upgrade -y && \ + apt-get install -y tmux && \ + rm -rf /var/lib/apt/lists/* + +# Upgrade pip and install requirements +COPY requirements.txt ./ +RUN pip install --no-cache-dir --upgrade pip +RUN pip install --no-cache-dir -r requirements.txt debugpy + +# Copy your tmux config to the container's home directory +COPY .tmux.conf /root/.tmux.conf + +COPY . . + +# Default production command +CMD [ "python", "./main.py" ] diff --git a/READ_ME.md b/READ_ME.md new file mode 100644 index 0000000..6711996 --- /dev/null +++ b/READ_ME.md @@ -0,0 +1,150 @@ +# Docker Python Development & Debugging Guide + +This guide outlines the setup for a lean, telemetry-free development environment using **VSCodium**, **Docker**, and **tmux**. It is designed to be consistent across Windows, Mac, and Linux. + +--- + +## 1. Project Structure +Create the following files in your project root to keep the configuration modular and "neat". + +```text +. +├── .tmux.conf # tmux customisation +├── .vscode/ +│ ├── launch.json # VSCodium debugger config +│ └── tasks.json # Automation for tmux attach +├── docker-compose.yml # Production base +├── docker-compose.override.yml # Development extensions +├── Dockerfile # Image definition +└── main.py # Your application code +``` + +--- + +## 2. The Configuration Files + +### Dockerfile +Ensures all tools (**tmux**, **debugpy**) and system upgrades are baked into the image. + +```dockerfile +FROM python:3.10-slim + +WORKDIR /usr/src/app + +# System upgrades and tmux installation +RUN apt-get update && apt-get upgrade -y && \ + apt-get install -y tmux && \ + rm -rf /var/lib/apt/lists/* + +# Upgrade pip and install requirements +COPY requirements.txt ./ +RUN pip install --no-cache-dir --upgrade pip +RUN pip install --no-cache-dir -r requirements.txt debugpy + +# Copy tmux config to root +COPY .tmux.conf /root/.tmux.conf + +COPY . . + +# Default production command +CMD [ "python", "./main.py" ] +``` + +### docker-compose.yml (Production Base) +```yaml +version: '3' +services: + bank_analysis_excel: + build: . + container_name: bank_analysis_excel +``` + +### docker-compose.override.yml (Development) +```yaml +version: '3' +services: + bank_analysis_excel: + volumes: + - .:/usr/src/app + ports: + - "5678:5678" + tty: true + stdin_open: true + # Overrides the Dockerfile CMD to keep the workshop open + command: tail -f /dev/null +``` + +### .tmux.conf +Enables mouse support and customises the interface. + +```bash +# Enable mouse mode for clicking/resizing +set -g mouse on + +# Visual improvements +set -g default-terminal "screen-256color" +set -g history-limit 10000 +set -g status-bg black +set -g status-fg white +set -g status-left "" +set -g status-right "#[fg=green]#H #[fg=white]%H:%M" +``` + +### .vscode/launch.json +```json +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Docker Attach", + "type": "debugpy", + "request": "attach", + "connect": { + "host": "localhost", + "port": 5678 + }, + "pathMappings": [ + { + "localRoot": "${workspaceFolder}", + "remoteRoot": "/usr/src/app" + } + ] + } + ] +} +``` + +--- + +## 3. The Daily Workflow + +### Step 1: Start the Container +Run in your host terminal (PowerShell, bash, or zsh): +```bash +docker compose up -d +``` + +### Step 2: Open VSCodium & Attach +If you set up the `tasks.json` automation, VSCodium will attach automatically. Otherwise, run: +```bash +docker compose exec bank_analysis_excel tmux +``` + +### Step 3: Start the Persistent Loop +In your primary **tmux** pane, run this loop so the debugger is always ready: +```bash +while true; do python3 -m debugpy --listen 0.0.0.0:5678 --wait-for-client main.py; done +``` + +### Step 4: Split and Work +* **Prefix Key**: `Ctrl + b` +* **Split Vertically**: `Prefix` then `%` +* **Switch Panes**: `Prefix` then `Arrow Keys` (or just click with your mouse). + +--- + +## 4. Deploying to Production +When the code is fixed and ready for a live environment: +1. Copy only `docker-compose.yml`, `Dockerfile`, and your code. +2. **Do not** copy `docker-compose.override.yml`. +3. Run `docker compose up -d`. The container will automatically execute `main.py` and close when finished. diff --git a/docker-compose.override.yml b/docker-compose.override.yml new file mode 100644 index 0000000..a394683 --- /dev/null +++ b/docker-compose.override.yml @@ -0,0 +1,9 @@ +services: + bank_analysis_excel: + volumes: + - .:/usr/src/app # Syncs your code for live editing + ports: + - "5678:5678" # Opens the debugger 'door' + tty: true # Keeps terminal active + stdin_open: true # Allows interactive input + command: tail -f /dev/null # Keeps the workshop open diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fd0efb9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,4 @@ +services: + bank_analysis_excel: + build: . + container_name: bank_analysis_excel diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29