File size: 1,508 Bytes
32199b1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# Dockerfile - build this image locally and push it to Hugging Face registry
FROM python:3.10-slim
# Avoid .pyc and unbuffered stdout for logs
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Set HF/transformers cache to a folder we control (avoid permission issues)
ENV HF_HOME=/app/.cache/huggingface
ENV TRANSFORMERS_CACHE=/app/.cache/transformers
ENV XDG_CACHE_HOME=/app/.cache
# The port your Flask app will listen on inside container
ENV PORT=7860
WORKDIR /app
# Install small system deps that commonly help (adjust if not needed)
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential curl git ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first so Docker caches dependency installation
COPY requirements.txt /app/requirements.txt
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r /app/requirements.txt
# Copy app sources (all files including out_index, images, templates)
COPY . /app
# Make sure cache dir exists and is writable
RUN mkdir -p /app/.cache/huggingface /app/.cache/transformers \
&& chmod -R 777 /app/.cache
# Expose the port used by Hugging Face Docker Spaces
EXPOSE 7860
# Do NOT put secrets here. They will be set in env at runtime (HF settings or docker run).
ENV GMAIL_USER=""
ENV GMAIL_PASSWORD=""
ENV TELEGRAM_BOT_TOKEN=""
ENV TELEGRAM_CHAT_ID=""
ENV JSON_URL=""
# Run the Flask app (your app uses os.environ.get("PORT"))
CMD ["python", "app.py"]
|