Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +53 -5
Dockerfile
CHANGED
|
@@ -1,6 +1,54 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
WORKDIR /app
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ----------------------------------------------------------------------
|
| 2 |
+
# Stage 1: Build Stage
|
| 3 |
+
# ----------------------------------------------------------------------
|
| 4 |
+
FROM python:3.12-alpine AS builder
|
| 5 |
+
|
| 6 |
+
# Install build dependencies
|
| 7 |
+
RUN apk add --no-cache \
|
| 8 |
+
bash \
|
| 9 |
+
build-base \
|
| 10 |
+
libffi-dev \
|
| 11 |
+
openssl-dev \
|
| 12 |
+
git
|
| 13 |
+
|
| 14 |
+
# Set the working directory
|
| 15 |
WORKDIR /app
|
| 16 |
+
|
| 17 |
+
# Clone the Surf-TG repository directly
|
| 18 |
+
RUN git clone https://github.com/weebzone/Surf-TG.git /app
|
| 19 |
+
|
| 20 |
+
# Install pip and uv
|
| 21 |
+
RUN pip install -U pip uv
|
| 22 |
+
|
| 23 |
+
# Install Python dependencies
|
| 24 |
+
RUN uv pip install --system --no-cache-dir -r requirements.txt
|
| 25 |
+
|
| 26 |
+
# ----------------------------------------------------------------------
|
| 27 |
+
# Stage 2: Final Stage (Minimal Runtime Image for Hugging Face)
|
| 28 |
+
# ----------------------------------------------------------------------
|
| 29 |
+
FROM python:3.12-alpine
|
| 30 |
+
|
| 31 |
+
# Install necessary runtime dependencies
|
| 32 |
+
RUN apk add --no-cache bash git
|
| 33 |
+
|
| 34 |
+
# Set up a non-root user for Hugging Face compatibility
|
| 35 |
+
RUN useradd -m -u 1000 user
|
| 36 |
+
USER user
|
| 37 |
+
ENV HOME=/home/user \
|
| 38 |
+
PATH=/home/user/.local/bin:$PATH
|
| 39 |
+
|
| 40 |
+
# Set the working directory
|
| 41 |
+
WORKDIR $HOME/app
|
| 42 |
+
|
| 43 |
+
# Copy the installed Python dependencies from the builder
|
| 44 |
+
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
|
| 45 |
+
|
| 46 |
+
# Copy the application source code from the builder and set ownership
|
| 47 |
+
COPY --from=builder --chown=user:user /app $HOME/app
|
| 48 |
+
|
| 49 |
+
# Hugging Face exposes port 7860 by default
|
| 50 |
+
EXPOSE 7860
|
| 51 |
+
|
| 52 |
+
# Command to run the application using honcho (since surf-tg.sh might need modifications)
|
| 53 |
+
RUN pip install --user honcho
|
| 54 |
+
CMD ["honcho", "start"]
|