Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +46 -23
Dockerfile
CHANGED
|
@@ -1,48 +1,71 @@
|
|
| 1 |
# Use an official Python runtime as a parent image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
gnupg \
|
| 11 |
-
|
| 12 |
-
|
|
|
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
# Install repomix globally
|
| 20 |
RUN npm install -g repomix
|
| 21 |
|
| 22 |
# Install Poetry
|
| 23 |
RUN curl -sSL https://install.python-poetry.org | python3 -
|
| 24 |
-
|
| 25 |
-
# Add Poetry to PATH
|
| 26 |
ENV PATH="/root/.local/bin:$PATH"
|
| 27 |
|
| 28 |
-
#
|
| 29 |
RUN poetry config virtualenvs.create false
|
| 30 |
|
| 31 |
-
# Copy
|
| 32 |
COPY poetry.lock pyproject.toml /app/
|
| 33 |
|
| 34 |
-
# Install
|
| 35 |
RUN poetry install --no-root --no-interaction --no-ansi
|
| 36 |
|
| 37 |
-
# Copy the rest of
|
| 38 |
COPY . .
|
| 39 |
|
| 40 |
-
#
|
| 41 |
EXPOSE 7860
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
| 45 |
-
ENV GRADIO_SERVER_PORT="7860"
|
| 46 |
-
|
| 47 |
-
# Run app.py when the container launches
|
| 48 |
CMD ["python", "app.py"]
|
|
|
|
| 1 |
# Use an official Python runtime as a parent image
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
ENV DEBIAN_FRONTEND=noninteractive \
|
| 5 |
+
PYTHONDONTWRITEBYTECODE=1 \
|
| 6 |
+
PYTHONUNBUFFERED=1
|
| 7 |
+
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
+
# Base OS deps (curl, git, fonts, and shared libs wkhtmltopdf needs)
|
| 11 |
+
# + NodeSource setup prereqs
|
| 12 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 13 |
+
ca-certificates curl gnupg git xz-utils \
|
| 14 |
+
fontconfig fonts-dejavu-core \
|
| 15 |
+
libfreetype6 libjpeg62-turbo libpng16-16 \
|
| 16 |
+
libx11-6 libxext6 libxrender1 libxcb1 \
|
| 17 |
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
|
| 19 |
+
# Install wkhtmltopdf from official .deb matching the Debian codename
|
| 20 |
+
# (tries bookworm first; falls back to bullseye)
|
| 21 |
+
ARG WKHTML_VER=0.12.6-1
|
| 22 |
+
RUN set -eux; \
|
| 23 |
+
. /etc/os-release; \
|
| 24 |
+
arch="$(dpkg --print-architecture)"; \
|
| 25 |
+
codename="${VERSION_CODENAME:-bookworm}"; \
|
| 26 |
+
url="https://github.com/wkhtmltopdf/packaging/releases/download/${WKHTML_VER}/wkhtmltox_${WKHTML_VER}.${codename}_${arch}.deb"; \
|
| 27 |
+
echo "Fetching $url"; \
|
| 28 |
+
curl -fsSL "$url" -o /tmp/wkhtml.deb || { \
|
| 29 |
+
codename="bullseye"; \
|
| 30 |
+
url="https://github.com/wkhtmltopdf/packaging/releases/download/${WKHTML_VER}/wkhtmltox_${WKHTML_VER}.${codename}_${arch}.deb"; \
|
| 31 |
+
echo "Fallback fetching $url"; \
|
| 32 |
+
curl -fsSL "$url" -o /tmp/wkhtml.deb; \
|
| 33 |
+
}; \
|
| 34 |
+
apt-get update && apt-get install -y --no-install-recommends /tmp/wkhtml.deb && \
|
| 35 |
+
rm -f /tmp/wkhtml.deb && \
|
| 36 |
+
rm -rf /var/lib/apt/lists/*
|
| 37 |
+
|
| 38 |
+
# Optional: verify install
|
| 39 |
+
RUN wkhtmltopdf --version
|
| 40 |
+
|
| 41 |
+
# Install Node.js LTS (for repomix)
|
| 42 |
+
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
|
| 43 |
+
apt-get update && apt-get install -y --no-install-recommends nodejs && \
|
| 44 |
+
rm -rf /var/lib/apt/lists/*
|
| 45 |
|
| 46 |
+
# Install repomix globally
|
| 47 |
RUN npm install -g repomix
|
| 48 |
|
| 49 |
# Install Poetry
|
| 50 |
RUN curl -sSL https://install.python-poetry.org | python3 -
|
|
|
|
|
|
|
| 51 |
ENV PATH="/root/.local/bin:$PATH"
|
| 52 |
|
| 53 |
+
# Keep Poetry in the system env (no venvs)
|
| 54 |
RUN poetry config virtualenvs.create false
|
| 55 |
|
| 56 |
+
# Copy dep files first to leverage Docker layer caching
|
| 57 |
COPY poetry.lock pyproject.toml /app/
|
| 58 |
|
| 59 |
+
# Install Python deps
|
| 60 |
RUN poetry install --no-root --no-interaction --no-ansi
|
| 61 |
|
| 62 |
+
# Copy the rest of your app
|
| 63 |
COPY . .
|
| 64 |
|
| 65 |
+
# HF Spaces / Gradio ports
|
| 66 |
EXPOSE 7860
|
| 67 |
+
ENV GRADIO_SERVER_NAME="0.0.0.0" \
|
| 68 |
+
GRADIO_SERVER_PORT="7860"
|
| 69 |
|
| 70 |
+
# Start your app
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
CMD ["python", "app.py"]
|