telegram-summary-bot / Dockerfile
fmab777's picture
Update Dockerfile
76be54d verified
raw
history blame
1.62 kB
# Use an official Python runtime as a parent image
FROM python:3.10-slim
# Set the working directory in the container
WORKDIR /app
# Copy the requirements file into the container at /app
COPY requirements.txt .
# Install any needed system dependencies (if any - bs4, requests usually don't need much)
# RUN apt-get update && apt-get install -y --no-install-recommends some-package && rm -rf /var/lib/apt/lists/*
# For this bot, we likely don't need extra apt packages currently.
# Install Python dependencies
# Using --no-cache-dir reduces image size slightly
RUN pip install --no-cache-dir -r requirements.txt
# Install crawl4ai dependencies (Playwright browsers)
# Needs to run *after* pip install and requires system dependencies installed by playwright itself
# Using --with-deps installs necessary browser dependencies like fonts, libs etc.
RUN crawl4ai-setup
RUN python -m playwright install --with-deps chromium
# Copy the rest of the application code into the container at /app
COPY . .
# Make port defined by PORT env var (default 7860) available
# Hugging Face Spaces typically expect apps to run on port 7860
EXPOSE ${PORT:-7860}
# Define environment variable to ensure Python output is sent straight to logs
ENV PYTHONUNBUFFERED=1
# Command to run the application using Gunicorn
# It will run the Starlette 'app' object found in the 'main' module (main.py)
# Listen on all interfaces (0.0.0.0) on the port specified by HF/env var (usually 7860)
# Using environment variable expansion for port binding
CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:${PORT:-7860}", "main:app"]