Spaces:
Paused
Paused
| # ---------------------------------------------------------------------- | |
| # 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"] |