Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: immich uv #91

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions templates/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ENV \
IMMICH_MACHINE_LEARNING_URL="http://127.0.0.1:3003" \
MACHINE_LEARNING_CACHE_FOLDER="/config/machine-learning" \
TRANSFORMERS_CACHE="/config/machine-learning" \
UV_PYTHON_INSTALL_DIR="/usr/local/bin" \
{% else -%}
IMMICH_MACHINE_LEARNING_ENABLED="false" \
{% endif -%}
Expand Down Expand Up @@ -97,8 +98,6 @@ RUN \
curl -s "https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key" | gpg --dearmor | tee /usr/share/keyrings/nodesource-repo.gpg >/dev/null && \
echo "deb [signed-by=/usr/share/keyrings/postgres.gpg] https://apt.postgresql.org/pub/repos/apt noble-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
curl -s "https://www.postgresql.org/media/keys/ACCC4CF8.asc" | gpg --dearmor | tee /usr/share/keyrings/postgres.gpg >/dev/null && \
echo "deb [signed-by=/usr/share/keyrings/deadsnakes.gpg] https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu noble main" >>/etc/apt/sources.list.d/deadsnakes.list && \
curl -s "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xF23C5A6CF475977595C89F51BA6932366A755776" | gpg --dearmor | tee /usr/share/keyrings/deadsnakes.gpg >/dev/null && \
{% if machine_learning_provider == "cuda" -%}
echo "deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/ /" >>/etc/apt/sources.list.d/cuda.list && \
curl -s "https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/3bf863cc.pub" | gpg --dearmor | tee /usr/share/keyrings/cuda-archive-keyring.gpg >/dev/null && \
Expand Down Expand Up @@ -128,13 +127,6 @@ RUN \
mesa-opencl-icd \
ocl-icd-libopencl1 \
{% endif -%}
{% if machine_learning_provider -%}
python3.11 \
python3.11-dev \
python3.11-venv \
python3-pip \
python3-poetry \
{% endif -%}
nodejs=$NODEJS_VERSION \
perl \
postgresql-client-14 \
Expand Down Expand Up @@ -202,15 +194,28 @@ RUN \
/app/immich/cli && \
{% if machine_learning_provider -%}
echo "**** build machine-learning ****" && \
if [ $(arch) = "x86_64" ]; then \
UV_PLATFORM="uv-x86_64-unknown-linux-gnu"; \
else \
UV_PLATFORM="uv-aarch64-unknown-linux-gnu"; \
fi && \
if [ -z ${UV_VERSION} ]; then \
UV_VERSION=$(curl -sL https://api.github.com/repos/astral-sh/uv/releases/latest | \
jq -r '.tag_name'); \
fi && \
curl -o \
/tmp/uv.tar.gz -L \
"https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/${UV_PLATFORM}.tar.gz" && \
tar xf \
/tmp/uv.tar.gz -C \
/tmp --strip-components=1 && \
cd /tmp/immich/machine-learning && \
python3.11 -m venv /lsiopy && \
poetry config installer.max-workers 10 && \
poetry config virtualenvs.create false && \
/tmp/uv python install 3.11 && \
cp -a \
pyproject.toml \
poetry.lock \
app \
log_conf.json \
uv.lock \
/app/immich/machine-learning && \
cp -a \
ann/ann.py \
Expand All @@ -234,7 +239,7 @@ RUN \
echo "hard core 0" >> /etc/security/limits.conf && \
echo "fs.suid_dumpable 0" >> /etc/sysctl.conf && \
echo "ulimit -S -c 0 > /dev/null 2>&1" >> /etc/profile && \
poetry install --no-interaction --no-ansi --no-root --with {{ machine_learning_provider }} --without dev && \
/tmp/uv sync --active --frozen --extra {{ machine_learning_provider }} --no-dev --no-editable --no-install-project --compile-bytecode --no-progress && \
{% endif -%}
echo "**** cleanup ****" && \
apt-get remove -y --purge \
Expand All @@ -245,20 +250,12 @@ RUN \
binutils-gold \
{% endif -%}
build-essential \
{% if machine_learning_provider -%}
python3.11-dev \
python3.11-venv \
python3-pip \
python3-poetry \
{% endif -%}
unzip && \
apt-get autoremove -y --purge && \
apt-get clean && \
rm -rf \
/etc/apt/sources.list.d/node.list \
/etc/apt/sources.list.d/pgdg.list \
/etc/apt/sources.list.d/deadsnakes.list \
/usr/share/keyrings/deadsnakes.gpg \
{% if machine_learning_provider == "cuda" -%}
/etc/apt/preferences.d/cuda \
/etc/apt/sources.list.d/cuda.list \
Expand Down
Loading