HEX
Server: Apache/2.4.63 (Unix)
System: Linux TOMS-220NAS 4.4.302+ #86009 SMP Wed Nov 26 18:19:17 CST 2025 x86_64
User: flavio87 (1026)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: /volume1/@appstore/WebStation/misc/python_dockerfile.mustache
FROM {{image_full_name}}

ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN=true

RUN mkdir -p /home/python/src
WORKDIR /home/python
RUN useradd -u {{user_id}} {{user}}

RUN if python -c "import sys; major, minor = sys.version_info[:2]; exit(0 if major == 3 and minor <= 2 else 1)" 2>/dev/null; then \
        echo "Using very legacy pip" && \
        pip install --upgrade "pip<8" "setuptools<30"; \
    elif python -c "import sys; major, minor = sys.version_info[:2]; exit(0 if (major == 3 and minor <= 4) or major == 2 else 1)" 2>/dev/null; then \
        echo "Using legacy pip" && \
        pip install --upgrade "pip<21" "setuptools<45"; \
    else \
        echo "Using modern pip for Python >= 3.5" && \
        pip install --upgrade pip setuptools; \
    fi
RUN apt-get update || { \
        echo "Standard repositories failed, switching to archive repositories..." && \
        sed -i 's/deb.debian.org/archive.debian.org/g' /etc/apt/sources.list && \
        sed -i 's/httpredir.debian.org/archive.debian.org/g' /etc/apt/sources.list && \
        sed -i 's|security.debian.org/debian-security|archive.debian.org/debian-security|g' /etc/apt/sources.list && \
        sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list && \
        sed -i '/stretch-updates\|jessie-updates\|buster-updates/d' /etc/apt/sources.list && \
        sed -i '/jessie\/updates/d' /etc/apt/sources.list && \
        echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/99allow-unauth && \
        echo 'DPkg::Options {"--force-confdef"; "--force-confold"; "--force-overwrite"; "--force-depends";}' > /etc/apt/apt.conf.d/99force-conf && \
        apt-get update; \
    } \
    && (apt-get install -y --allow-unauthenticated --no-upgrade gcc || { \
        echo "gcc install failed, checking if build tools are available..." && \
        which gcc > /dev/null 2>&1 && echo "gcc already available, continuing..." || { \
            echo "Installing build-essential..." && \
            apt-get install -y --allow-unauthenticated build-essential; \
        }; \
    }) \
    && (apt-get install -y --allow-unauthenticated mime-support || { \
        echo "mime-support not available, trying media-types and mailcap..." && \
        apt-get install -y --allow-unauthenticated media-types mailcap; \
    }) \
    && (python -c "import sys; sys.exit(0 if sys.version_info[:2] <= (3, 2) else 1)" && { \
        echo "Using uWSGI 1.9.x for compatibility..." && \
        pip install "uwsgi<2.0"; \
    } || { \
        echo "Installing modern uWSGI..." && \
        pip install uwsgi; \
    } || { \
        echo "uWSGI install failed, trying fallback methods..." && \
        python -c "import sys; sys.exit(0 if sys.version_info[:2] <= (3, 2) else 1)" && { \
            echo "Trying uWSGI 1.9.21..." && \
            pip install uwsgi==1.9.21; \
        } || { \
            echo "Retrying modern uWSGI with --no-deps..." && \
            pip install --no-deps uwsgi; \
        }; \
    })

# upload requirements.txt to bundle install
COPY requirements.txt /home/python/
RUN pip install -r requirements.txt

# bind python uwsgi folder to container by docker-compose
ENTRYPOINT uwsgi {{config_dir}}/user_settings.ini