Spaces:
Running
Running
Lets try this dockerfile
Browse files- Dockerfile +10 -16
Dockerfile
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
-
# Stage 1: Builder
|
| 2 |
-
FROM python:3.12
|
| 3 |
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
-
# Install
|
| 7 |
RUN apt-get update && apt-get install -y cmake g++ make build-essential && rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
RUN python -m venv venv
|
|
@@ -11,23 +11,17 @@ ENV VIRTUAL_ENV=/app/venv
|
|
| 11 |
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
| 12 |
|
| 13 |
COPY requirements.txt .
|
| 14 |
-
|
| 15 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
USER user
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
# Set the working directory to the user's home directory
|
| 26 |
-
WORKDIR $HOME/app
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
|
| 31 |
EXPOSE 7860
|
| 32 |
-
|
| 33 |
CMD ["python", "app.py"]
|
|
|
|
| 1 |
+
# Stage 1: Builder (using a full base image)
|
| 2 |
+
FROM python:3.12 AS builder
|
| 3 |
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
+
# Install build dependencies
|
| 7 |
RUN apt-get update && apt-get install -y cmake g++ make build-essential && rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
RUN python -m venv venv
|
|
|
|
| 11 |
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
| 12 |
|
| 13 |
COPY requirements.txt .
|
|
|
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
| 16 |
+
# Stage 2: Runner (you can choose a slim image if the built wheels are portable)
|
| 17 |
+
FROM python:3.12-slim AS runner
|
|
|
|
| 18 |
|
| 19 |
+
WORKDIR /app
|
| 20 |
+
COPY --from=builder /app/venv venv
|
| 21 |
+
COPY --from=builder /app /app
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
ENV VIRTUAL_ENV=/app/venv
|
| 24 |
+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
| 25 |
|
| 26 |
EXPOSE 7860
|
|
|
|
| 27 |
CMD ["python", "app.py"]
|