Spaces:
Running
on
Zero
Running
on
Zero
Merge branch 'main' of https://github.com/AI-Riksarkivet/htrflow_app
Browse files- .docker/dockerfile +62 -6
- uv.lock +0 -0
.docker/dockerfile
CHANGED
@@ -1,10 +1,66 @@
|
|
1 |
-
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
|
8 |
-
RUN
|
|
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Base image with CUDA 12.6.3 and cuDNN
|
2 |
+
FROM nvidia/cuda:12.6.3-cudnn-runtime-ubuntu22.04
|
3 |
|
4 |
+
# Set environment variables
|
5 |
+
ARG DEBIAN_FRONTEND=noninteractive
|
6 |
+
ENV PYTHONUNBUFFERED=1 \
|
7 |
+
GRADIO_FLAGGING_MODE=never \
|
8 |
+
GRADIO_NUM_PORTS=1 \
|
9 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
10 |
+
GRADIO_THEME=huggingface \
|
11 |
+
SYSTEM=spaces \
|
12 |
+
AM_I_IN_A_DOCKER_CONTAINER=Yes \
|
13 |
+
PYTHONPATH=/home/appuser/app \
|
14 |
+
HF_HOME=/home/appuser/.cache \
|
15 |
+
TORCH_HOME=/home/appuser/.cache \
|
16 |
+
TMP_DIR=/home/appuser/tmp \
|
17 |
+
TRANSFORMERS_CACHE=/home/appuser/.cache/transformers \
|
18 |
+
NVIDIA_VISIBLE_DEVICES=all \
|
19 |
+
NVIDIA_DRIVER_CAPABILITIES=compute,utility
|
20 |
|
21 |
+
# Install system dependencies and set Python 3.10 as default
|
22 |
+
RUN apt-get update && apt-get install --no-install-recommends -y \
|
23 |
+
build-essential \
|
24 |
+
python3.10 \
|
25 |
+
python3.10-distutils \
|
26 |
+
python3-pip \
|
27 |
+
ffmpeg \
|
28 |
+
libsm6 \
|
29 |
+
libxext6 \
|
30 |
+
libgl1 \
|
31 |
+
&& ln -sf /usr/bin/python3.10 /usr/bin/python \
|
32 |
+
&& ln -sf /usr/bin/pip3 /usr/bin/pip \
|
33 |
+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
34 |
|
35 |
+
# Install `uv`
|
36 |
+
RUN pip install --upgrade pip \
|
37 |
+
&& pip install uv
|
38 |
|
39 |
+
# Create a non-root user
|
40 |
+
RUN useradd -m -u 1000 appuser
|
41 |
+
|
42 |
+
# Set working directory
|
43 |
+
WORKDIR /home/appuser/app
|
44 |
+
|
45 |
+
# Copy dependency files and install dependencies
|
46 |
+
COPY --chown=appuser pyproject.toml uv.lock LICENSE README.md ./
|
47 |
+
RUN uv sync --frozen --no-cache \
|
48 |
+
&& chown -R appuser:appuser /home/appuser/app/.venv \
|
49 |
+
&& rm -rf /root/.cache /home/appuser/.cache
|
50 |
+
|
51 |
+
|
52 |
+
# Copy application code
|
53 |
+
COPY --chown=appuser app app
|
54 |
+
|
55 |
+
# Ensure non-root user has write access to cache and tmp directories
|
56 |
+
RUN mkdir -p /home/appuser/.cache/transformers /home/appuser/tmp /home/appuser/.cache \
|
57 |
+
&& chown -R appuser:appuser /home/appuser/.cache /home/appuser/tmp/ /home/appuser/app/
|
58 |
+
|
59 |
+
# Switch to non-root user
|
60 |
+
USER appuser
|
61 |
+
|
62 |
+
# Expose port for Gradio
|
63 |
+
EXPOSE 7862
|
64 |
+
|
65 |
+
# Command to run the application
|
66 |
+
CMD ["uv", "run", "python", "app/main.py"]
|
uv.lock
CHANGED
The diff for this file is too large to render.
See raw diff
|
|