Spaces:
Paused
Paused
File size: 1,670 Bytes
4b241b9 6775fef 4b241b9 351dbbe 4b241b9 351dbbe 4b241b9 351dbbe 4b241b9 | 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 | # ----------------------------------------------------------------------
# Stage 1: Build Stage
# ----------------------------------------------------------------------
FROM python:3.12-alpine AS builder
# Install build dependencies
RUN apk add --no-cache \
bash \
build-base \
libffi-dev \
openssl-dev \
git
# Set the working directory
WORKDIR /app
# Clone the Surf-TG repository directly
RUN git clone https://github.com/weebzone/Surf-TG.git /app
# Install pip and uv
RUN pip install -U pip uv
# Install Python dependencies
RUN uv pip install --system --no-cache-dir -r requirements.txt
# ----------------------------------------------------------------------
# Stage 2: Final Stage (Minimal Runtime Image for Hugging Face)
# ----------------------------------------------------------------------
FROM python:3.12-alpine
# Install necessary runtime dependencies
RUN apk add --no-cache bash git
# Set up a non-root user for Hugging Face compatibility using adduser (Alpine specific)
RUN addgroup -g 1000 usergroup && \
adduser -D -u 1000 -G usergroup user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Set the working directory
WORKDIR $HOME/app
# Copy the installed Python dependencies from the builder
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
# Copy the application source code from the builder and set ownership
COPY --from=builder --chown=user:usergroup /app $HOME/app
# Hugging Face exposes port 7860 by default
EXPOSE 7860
# Command to run the application using honcho
RUN pip install --user honcho
CMD ["honcho", "start"] |