# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ # ┃ 🐳 Dockerfile: Multi-Stage Build for Python + SSH App /(dev) ┃ # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ # ──────────────── Stage 1: Base ──────────────── # Base image using Debian Bullseye FROM debian:bullseye as base # Suppress interactive prompts during package installation ENV DEBIAN_FRONTEND=noninteractive # Install core dependencies: # - Python 3 and pip # - OpenSSH server for remote access # - sudo for privilege escalation RUN apt-get update && \ apt-get install -y \ python3 \ python3-pip \ openssh-server \ curl && \ yq && \ mkdir /var/run/sshd && \ apt-get clean # Create config directory for app (can be used by dev/prod stages) RUN mkdir -p /etc/app/config # ──────────────── Stage 2: Dev ──────────────── # Development stage inherits from base FROM base AS dev # Install debugging tools (e.g. debugpy for remote debugging) RUN echo "Installing debug tools..." && \ pip install debugpy # Set working directory WORKDIR /app # Install Python dependencies from requirements.txt COPY app/requirements.txt requirements.txt # This allows caching of dependencies even if app code is mounted RUN pip install --no-cache-dir -r requirements.txt EXPOSE 5678 # runtime environment ENV CONFIGURATION=Debug ENV DEBUG=True ENV SSH_SERVER_ENABLED=False # Default command for dev container CMD ["python3","-u", "/app/main.py"] # ──────────────── Optional: User & SSH Setup ──────────────── # Uncomment below to create a non-root user and configure SSH access # Create a non-root user with sudo privileges # RUN useradd -m -s /bin/bash devuser && \ # echo "devuser:devpass" | chpasswd && \ # usermod -aG sudo devuser # Configure SSH server to allow password login and specific users # RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config && \ # sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \ # echo "AllowUsers devuser" >> /etc/ssh/sshd_config # Expose SSH port