50 lines
1.6 KiB
Docker
50 lines
1.6 KiB
Docker
# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
# ┃ 🐳 Dockerfile: Multi-Stage Build for Python + SSH App ┃
|
|
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
|
|
# ──────────────── 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: Prod ────────────────
|
|
# Production stage inherits from base
|
|
FROM base AS prod
|
|
|
|
# Copy full app code into image (self-contained)
|
|
COPY app/ /app
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
ENV CONFIGURATION=Production
|
|
ENV DEBUG=False
|
|
|
|
# Default command for production container
|
|
CMD ["python3", "-u", "/app/main.py"]
|
|
|
|
|
|
#EXPOSE 22
|