# VA-Remotecontrol NATIV auf Linux (kein Wine) — aus ORIGINAL-macOS-Bytecode.
#
# Kernidee: die App-Module (one_unit, child_unit, ...) liegen im macOS-.app als
# UNVERAENDERTES Python-2.7-Bytecode vor. CPython-Bytecode ist OS-unabhaengig,
# laeuft also direkt auf einem Linux-CPython-2.7 — KEINE Dekompilierung noetig.
# Nur die C-Extensions kommen nativ aus dem Distro (wxGTK3, numpy, scipy, ...).
#
# macOS-Build nutzt wxPython 3.0.3 (Classic) -> Linux-Pendant: python-wxgtk3.0
# (wxPython 3.0.2) aus Debian stretch. Stretch ist EOL -> archive.debian.org.
# Muss auf einer Maschine gebaut werden, die archive.debian.org erreicht.
FROM debian:stretch

ENV DEBIAN_FRONTEND=noninteractive

# stretch ist EOL -> Paketquellen auf archive.debian.org umbiegen.
# [trusted=yes] = Signaturpruefung aus (Release-Key ist abgelaufen/fehlt im
# Base-Keyring -> sonst exit 100). Check-Valid-Until aus = abgelaufenes Release ok.
# WICHTIG: debian-security MUSS mit rein - das Base-Image hat security-gepatchte
# Libs (z.B. libnettle6 ...deb9u1); ohne stretch/updates findet apt die passenden
# libhogweed4/libgnutls30/libcups2 (deb9u1) nicht -> "held broken packages".
RUN { echo 'deb [trusted=yes] http://archive.debian.org/debian stretch main contrib'; \
      echo 'deb [trusted=yes] http://archive.debian.org/debian-security stretch/updates main'; \
    } > /etc/apt/sources.list && \
    echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99no-check-valid && \
    apt-get update && \
    apt-get install -y --no-install-recommends \
        python-wxgtk3.0 \
        python-numpy \
        python-scipy \
        python-serial \
        python-pyaudio \
        python-imaging \
        xauth \
    && rm -rf /var/lib/apt/lists/*

# App-Baum: ORIGINAL Mac-.pyc + pure-Python-Libs + Assets + Linux-win32-Stubs.
# Enthaelt auch die vor-gerenderten Panel-Bitmaps (img.cache) - Laufzeit-PFLICHT,
# sonst "Failed to get image ..." (keine PNG-Quellen zum Regenerieren vorhanden).
COPY va /opt/va

# Nicht als root laufen
RUN useradd -m app && chown -R app /opt/va
USER app
ENV HOME=/home/app

WORKDIR /opt/va
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
