Dan
commited on
Commit
·
51e0e82
1
Parent(s):
d8c6f7a
add dockerfile
Browse files- .gitignore +11 -0
- .python-version +1 -0
- Dockerfile +102 -0
- ollama_pull.sh +13 -0
- on_startup.sh +1 -0
- packages.txt +0 -0
- pyproject.toml +20 -0
- start_server.sh +22 -0
- uv.lock +0 -0
.gitignore
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.vscode
|
| 2 |
+
.venv
|
| 3 |
+
.ipynb_checkpoints
|
| 4 |
+
__pycache__
|
| 5 |
+
*.pyc
|
| 6 |
+
*.pyo
|
| 7 |
+
*.pyd
|
| 8 |
+
.Python
|
| 9 |
+
env/
|
| 10 |
+
build/
|
| 11 |
+
dist/
|
.python-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
3.11
|
Dockerfile
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04
|
| 2 |
+
|
| 3 |
+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
| 4 |
+
|
| 5 |
+
ENV DEBIAN_FRONTEND=noninteractive \
|
| 6 |
+
TZ=Europe/Paris
|
| 7 |
+
|
| 8 |
+
# Remove any third-party apt sources to avoid issues with expiring keys.
|
| 9 |
+
# Install some basic utilities
|
| 10 |
+
RUN rm -f /etc/apt/sources.list.d/*.list && \
|
| 11 |
+
apt-get update && apt-get install -y --no-install-recommends \
|
| 12 |
+
curl \
|
| 13 |
+
ca-certificates \
|
| 14 |
+
sudo \
|
| 15 |
+
git \
|
| 16 |
+
wget \
|
| 17 |
+
procps \
|
| 18 |
+
git-lfs \
|
| 19 |
+
zip \
|
| 20 |
+
unzip \
|
| 21 |
+
htop \
|
| 22 |
+
vim \
|
| 23 |
+
nano \
|
| 24 |
+
bzip2 \
|
| 25 |
+
libx11-6 \
|
| 26 |
+
build-essential \
|
| 27 |
+
libsndfile-dev \
|
| 28 |
+
software-properties-common \
|
| 29 |
+
python3-distutils \
|
| 30 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 31 |
+
|
| 32 |
+
RUN add-apt-repository ppa:flexiondotorg/nvtop && \
|
| 33 |
+
apt-get upgrade -y && \
|
| 34 |
+
apt-get install -y --no-install-recommends nvtop
|
| 35 |
+
|
| 36 |
+
# Create a working directory
|
| 37 |
+
WORKDIR /app
|
| 38 |
+
|
| 39 |
+
# Create a non-root user and switch to it
|
| 40 |
+
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
|
| 41 |
+
&& chown -R user:user /app
|
| 42 |
+
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
|
| 43 |
+
USER user
|
| 44 |
+
|
| 45 |
+
# All users can use /home/user as their home directory
|
| 46 |
+
ENV HOME=/home/user
|
| 47 |
+
RUN mkdir $HOME/.cache $HOME/.config \
|
| 48 |
+
&& chmod -R 777 $HOME
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
WORKDIR $HOME/app
|
| 52 |
+
|
| 53 |
+
#######################################
|
| 54 |
+
# Start root user section
|
| 55 |
+
#######################################
|
| 56 |
+
|
| 57 |
+
USER root
|
| 58 |
+
|
| 59 |
+
# User Debian packages
|
| 60 |
+
## Security warning : Potential user code executed as root (build time)
|
| 61 |
+
RUN --mount=target=/root/packages.txt,source=packages.txt \
|
| 62 |
+
apt-get update && \
|
| 63 |
+
xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
|
| 64 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 65 |
+
|
| 66 |
+
RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
|
| 67 |
+
bash /root/on_startup.sh
|
| 68 |
+
|
| 69 |
+
RUN mkdir /data && chown user:user /data
|
| 70 |
+
|
| 71 |
+
RUN curl -fsSL https://ollama.com/install.sh | sh
|
| 72 |
+
COPY ollama_pull.sh ollama_pull.sh
|
| 73 |
+
RUN chmod +x ollama_pull.sh && ./ollama_pull.sh
|
| 74 |
+
|
| 75 |
+
#######################################
|
| 76 |
+
# End root user section
|
| 77 |
+
#######################################
|
| 78 |
+
|
| 79 |
+
USER user
|
| 80 |
+
|
| 81 |
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
| 82 |
+
--mount=type=bind,source=uv.lock,target=uv.lock \
|
| 83 |
+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
| 84 |
+
uv sync --locked --no-install-project
|
| 85 |
+
|
| 86 |
+
RUN uv run ipython kernel install --user --env VIRTUAL_ENV $(pwd)/.venv --name=uv_project
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 90 |
+
COPY --chown=user . $HOME/app
|
| 91 |
+
|
| 92 |
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
| 93 |
+
uv sync --locked
|
| 94 |
+
|
| 95 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 96 |
+
SYSTEM=spaces \
|
| 97 |
+
SHELL=/bin/bash
|
| 98 |
+
|
| 99 |
+
RUN chmod +x start_server.sh
|
| 100 |
+
EXPOSE 7860
|
| 101 |
+
|
| 102 |
+
CMD ["./start_server.sh"]
|
ollama_pull.sh
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
echo "Starting Ollama server..."
|
| 4 |
+
ollama serve &
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
echo "Waiting for Ollama server to be active..."
|
| 8 |
+
while [ "$(ollama list | grep 'NAME')" == "" ]; do
|
| 9 |
+
sleep 1
|
| 10 |
+
done
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
ollama pull gemma3:4b
|
on_startup.sh
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
echo "HELLO"
|
packages.txt
ADDED
|
File without changes
|
pyproject.toml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "workhorse"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
description = "Add your description here"
|
| 5 |
+
readme = "README.md"
|
| 6 |
+
requires-python = ">=3.11"
|
| 7 |
+
dependencies = [
|
| 8 |
+
"huggingface-hub[cli]>=0.34.4",
|
| 9 |
+
"keras>=3.11.3",
|
| 10 |
+
"pandas>=2.3.2",
|
| 11 |
+
"pip>=25.2",
|
| 12 |
+
"tensorflow>=2.20.0",
|
| 13 |
+
"torch>=2.8.0",
|
| 14 |
+
"torchvision>=0.23.0",
|
| 15 |
+
]
|
| 16 |
+
|
| 17 |
+
[dependency-groups]
|
| 18 |
+
dev = [
|
| 19 |
+
"ipykernel>=6.30.1",
|
| 20 |
+
]
|
start_server.sh
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
JUPYTER_TOKEN="${JUPYTER_TOKEN:=huggingface}"
|
| 3 |
+
|
| 4 |
+
NOTEBOOK_DIR="/data"
|
| 5 |
+
|
| 6 |
+
# jupyter labextension disable "@jupyterlab/apputils-extension:announcements"
|
| 7 |
+
|
| 8 |
+
echo """Starting Jupyter Lab server..."
|
| 9 |
+
echo "connect to "http://127.0.0.1:7860/lab?token=huggingface"
|
| 10 |
+
|
| 11 |
+
uv run --with jupyter jupyter lab \
|
| 12 |
+
--ip 0.0.0.0 \
|
| 13 |
+
--port 7860 \
|
| 14 |
+
--no-browser \
|
| 15 |
+
--allow-root \
|
| 16 |
+
--ServerApp.token="$JUPYTER_TOKEN" \
|
| 17 |
+
--ServerApp.tornado_settings="{'headers': {'Content-Security-Policy': 'frame-ancestors *'}}" \
|
| 18 |
+
--ServerApp.cookie_options="{'SameSite': 'None', 'Secure': True}" \
|
| 19 |
+
--ServerApp.disable_check_xsrf=True \
|
| 20 |
+
--LabApp.news_url=None \
|
| 21 |
+
--LabApp.check_for_updates_class="jupyterlab.NeverCheckForUpdate" \
|
| 22 |
+
--notebook-dir=$NOTEBOOK_DIR
|
uv.lock
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|