# Build Dangerzone from source without Poetry for a simpler, reproducible build
# Stage 1: builder - install dependencies and build a wheel from the repo
FROM python:3.12.13-bookworm AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build tools and basic dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential git curl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the repository
COPY . .
# Upgrade pip and ensure wheel/build tools are present
RUN python -m pip install --upgrade pip \
&& python -m pip install --no-cache-dir wheel setuptools build
# Build a wheel from the project using setup.py
RUN python -m build --wheel --outdir dist
# Stage 2: runtime image - minimal Python runtime with the built wheel installed
FROM python:3.12.13-bookworm
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies for GUI stack (Qt/PySide6)
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libgl1 libxext6 libxrender1 libx11-6 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the built wheel from the builder stage and install it
COPY --from=builder /app/dist/*.whl /tmp/
RUN python -m pip install --no-cache-dir /tmp/*.whl
# Expose the default command to run Dangerzone. The CLI/GUI entrypoint is
# defined in setup.py/pyproject.toml as the "dangerzone" script.
CMD ["dangerzone"]