Spaces:
Paused
Paused
File size: 3,590 Bytes
a5784e9 549d337 a5784e9 | 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | # Hugging Face Spaces Dockerfile.
# The original Docker setup lives in docker/Dockerfile; this root Dockerfile is
# required by Spaces and keeps the public HTTP service on port 7860.
FROM python:3.10-slim-bookworm AS builder
ARG DEBIAN_FRONTEND=noninteractive
ARG PROXY_ADDR
RUN if [ -n "$PROXY_ADDR" ]; then \
printf 'Acquire::http::Proxy "%s";\nAcquire::https::Proxy "%s";\n' "$PROXY_ADDR" "$PROXY_ADDR" > /etc/apt/apt.conf.d/99proxy; \
fi && \
apt-get update && \
apt-get install -y --no-install-recommends curl && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
if [ -n "$PROXY_ADDR" ]; then rm -f /etc/apt/apt.conf.d/99proxy; fi
ENV HTTP_PROXY=${PROXY_ADDR}
ENV HTTPS_PROXY=${PROXY_ADDR}
ENV POETRY_HOME="/opt/poetry"
ENV POETRY_VERSION=1.8.3
ENV PATH="${POETRY_HOME}/bin:${PATH}"
RUN curl -sSL https://install.python-poetry.org | python3 - --version ${POETRY_VERSION}
WORKDIR /app_builder
COPY pyproject.toml poetry.lock ./
RUN poetry config virtualenvs.create false --local && \
poetry install --only main --no-root --no-interaction --no-ansi
FROM python:3.10-slim-bookworm
ARG DEBIAN_FRONTEND=noninteractive
ARG PROXY_ADDR
ENV HTTP_PROXY=${PROXY_ADDR}
ENV HTTPS_PROXY=${PROXY_ADDR}
RUN if [ -n "$PROXY_ADDR" ]; then \
printf 'Acquire::http::Proxy "%s";\nAcquire::https::Proxy "%s";\n' "$PROXY_ADDR" "$PROXY_ADDR" > /etc/apt/apt.conf.d/99proxy; \
fi && \
apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates curl fonts-liberation \
libasound2 libatk-bridge2.0-0 libatk1.0-0 libcups2 libdbus-1-3 \
libdrm2 libgbm1 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 \
libpangocairo-1.0-0 libu2f-udev libx11-6 libx11-xcb1 libxcb1 \
libxcomposite1 libxdamage1 libxext6 libxfixes3 libxrandr2 \
libxrender1 libxtst6 && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
if [ -n "$PROXY_ADDR" ]; then rm -f /etc/apt/apt.conf.d/99proxy; fi
RUN groupadd -r appgroup && useradd -r -g appgroup -s /bin/bash -d /app appuser
WORKDIR /app
COPY --from=builder /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/site-packages/
COPY --from=builder /usr/local/bin/ /usr/local/bin/
COPY --from=builder /opt/poetry/bin/poetry /usr/local/bin/poetry
COPY . .
RUN camoufox fetch && \
python -m playwright install firefox && \
python scripts/update_browserforge_data.py
RUN mkdir -p /var/cache/camoufox && \
if [ -d /root/.cache/camoufox ]; then cp -a /root/.cache/camoufox/. /var/cache/camoufox/; fi && \
mkdir -p /app/.cache && \
ln -s /var/cache/camoufox /app/.cache/camoufox && \
mkdir -p /app/logs \
/app/auth_profiles/active \
/app/auth_profiles/saved \
/app/auth_profiles/emergency \
/app/certs \
/app/browser_utils/custom_scripts \
/home/appuser/.cache/ms-playwright \
/home/appuser/.mozilla && \
chown -R appuser:appgroup /app /home/appuser /var/cache/camoufox
USER appuser
ENV HOME=/app
ENV PLAYWRIGHT_BROWSERS_PATH=/home/appuser/.cache/ms-playwright
ENV PYTHONUNBUFFERED=1
ENV PORT=7860
ENV SERVER_PORT=7860
ENV DEFAULT_FASTAPI_PORT=7860
ENV DEFAULT_CAMOUFOX_PORT=9222
# Hugging Face Spaces may pause apps that expose an HTTP CONNECT proxy.
# Disable the internal stream proxy by default for Spaces deployments.
ENV STREAM_PORT=0
ENV SERVER_LOG_LEVEL=INFO
ENV DEBUG_LOGS_ENABLED=false
ENV AUTO_CONFIRM_LOGIN=true
ENV INTERNAL_CAMOUFOX_PROXY=""
ENV HTTP_PROXY=""
ENV HTTPS_PROXY=""
EXPOSE 7860
CMD ["python", "scripts/huggingface/entrypoint.py"]
|