FROM python:3.12-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 ENV NSEDASH_BASE_DIR=/app ENV PYTHONPATH=/app WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* # Download and install precompiled TA-Lib binary wheel based on architecture RUN ARCH=$(uname -m) && \ if [ "$ARCH" = "x86_64" ]; then \ WHL_URL="https://github.com/quantmew/talib-prebuilt/releases/download/v0.6.4/ta_lib-0.6.4-cp312-cp312-manylinux_2_28_x86_64.whl"; \ elif [ "$ARCH" = "aarch64" ]; then \ WHL_URL="https://github.com/quantmew/talib-prebuilt/releases/download/v0.6.4/ta_lib-0.6.4-cp312-cp312-manylinux_2_28_aarch64.whl"; \ else \ echo "Unsupported architecture: $ARCH" && exit 1; \ fi && \ pip install --no-cache-dir "$WHL_URL" # Copy requirements and install python packages COPY requirements.txt /app/ RUN pip install --no-cache-dir -r requirements.txt # Create a user with UID 1000 and ensure workdir is owned by user RUN useradd -m -u 1000 user && mkdir -p /app && chown -R user:user /app ENV HOME=/home/user # Copy application files and change ownership to user COPY --chown=user . /app/ # Switch to the non-root user USER user # Expose HF Spaces port EXPOSE 7860 # Run Flask dashboard CMD ["python", "nsedash_app.py"]