Spaces:
Runtime error
Runtime error
Download Dockerfile from dpadhan/Testingpot: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/spaces/dpadhan/Testingpot/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/dpadhan/Testingpot/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/dpadhan/Testingpot/resolve/main/Dockerfile
1.54 kB
| # ========================================== | |
| # STAGE 1: Build & Compile Dependencies | |
| # ========================================== | |
| FROM python:3.11-slim AS builder | |
| WORKDIR /app | |
| # Install system compilation tools required for premium crypto libraries (TGCrypto) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| gcc \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Upgrade pip and copy requirements | |
| RUN python -m pip install --no-cache-dir --upgrade pip | |
| COPY requirements.txt . | |
| # Install dependencies into a localized wheels folder | |
| RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt | |
| # ========================================== | |
| # STAGE 2: Final Runtime Environment | |
| # ========================================== | |
| FROM python:3.11-slim AS runner | |
| WORKDIR /app | |
| # Create a secure, non-privileged system user to prevent container breakout exploits | |
| RUN useradd -u 8888 appuser && chown -R appuser:appuser /app | |
| # Copy compiled wheels from the builder stage | |
| COPY --from=builder /app/wheels /wheels | |
| COPY --from=builder /app/requirements.txt . | |
| # Install the pre-compiled packages safely | |
| RUN pip install --no-cache /wheels/* | |
| # Copy the actual application source code into the container | |
| COPY --chown=appuser:appuser bot.py . | |
| # Drop root privileges and switch to our secure user | |
| USER appuser | |
| # Enforce Python logs to flush directly to stdout/stderr without buffering | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| # Execute the application engine | |
| CMD ["python", "bot.py"] | |