From 71c90ae4ea3eb3626a3558093e7931520a43cf20 Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Sun, 8 Sep 2024 21:01:07 -0700 Subject: [PATCH] [sickchill] uv, new dockerfile on ubuntu --- sickchill/Dockerfile | 62 +++++++++++++++++++++++--------------- sickchill/requirements.in | 3 +- sickchill/requirements.txt | 18 +++++------ 3 files changed, 48 insertions(+), 35 deletions(-) diff --git a/sickchill/Dockerfile b/sickchill/Dockerfile index 95ad4e4..7756083 100644 --- a/sickchill/Dockerfile +++ b/sickchill/Dockerfile @@ -1,40 +1,52 @@ -FROM debian:bookworm as compile-sickchill -RUN apt-get update -RUN apt-get install -y --no-install-recommends \ - # python virtualenv construction - python-is-python3 python3-venv +ARG UV_VERSION=0.4.2 +FROM ubuntu:noble as compile-sickchill -# prepare the sickchill venv -RUN python -mvenv /app/sickchill +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + # python virtualenv construction \ + python-is-python3 python3-venv \ + # for building in general \ + build-essential pkg-config \ + # for rust \ + curl ca-certificates \ + # python sources need these. Mainly sickchill \ + libffi-dev libxml2-dev libxslt-dev libssl-dev -# Sadly, on most platforms this needs to build Rust. -RUN apt-get install -y --no-install-recommends \ - # for rust - curl ca-certificates RUN curl https://sh.rustup.rs -sSf | bash -x -s -- -y -# needed to work around https://github.com/rust-lang/cargo/issues/8719 -ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse +# Security-conscious organizations should package/review uv themselves. +COPY --from=ghcr.io/astral-sh/uv:0.4.2 /uv /bin/uv + +# - Silence uv complaining about not being able to use hard links, +# - tell uv to byte-compile packages for faster application startups, +# - prevent uv from accidentally downloading isolated Python builds, +# - and finally pick a Python. +ENV UV_LINK_MODE=copy \ + UV_COMPILE_BYTECODE=1 \ + UV_PYTHON_DOWNLOADS=never \ + UV_PYTHON=python3.12 \ + # needed to work around https://github.com/rust-lang/cargo/issues/8719 \ + CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse RUN apt-get install -y --no-install-recommends \ # for building in general - gcc build-essential pkg-config \ - # python sources need these. Mainly sickchill - python3-dev libffi-dev libxml2-dev libxslt-dev libssl-dev + gcc build-essential pkg-config ADD requirements.txt /src/requirements.txt -RUN . /root/.cargo/env && \ - . /app/sickchill/bin/activate && \ - python -mpip install --upgrade pip pip-tools && \ - pip-sync /src/requirements.txt +WORKDIR /app + +RUN --mount=type=cache,target=/root/.cache \ + . /root/.cargo/env && \ + uv venv && \ + uv pip sync /src/requirements.txt -FROM debian:bookworm-slim AS runtime-image +FROM ubuntu:noble AS runtime-image VOLUME /var/lib/sickchill VOLUME /mnt/media EXPOSE 8080 -COPY --from=compile-sickchill /app/sickchill /app/sickchill +COPY --from=compile-sickchill /app/.venv /app/.venv # Dependencies last, because I don't need them to set the rest up RUN apt-get update && \ @@ -47,8 +59,10 @@ RUN apt-get update && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -CMD . /app/sickchill/bin/activate && \ - exec python -m SickChill \ +COPY --from=ghcr.io/astral-sh/uv:0.4.2 /uv /bin/uv + +WORKDIR /app +CMD uv run python -m SickChill \ --datadir=/var/lib/sickchill \ --config /var/lib/sickchill/config.ini \ --nolaunch --port 8080 diff --git a/sickchill/requirements.in b/sickchill/requirements.in index d560148..26713f1 100644 --- a/sickchill/requirements.in +++ b/sickchill/requirements.in @@ -1 +1,2 @@ -sickchill==2024.3.1 +sickchill==2024.3.1 +setuptools diff --git a/sickchill/requirements.txt b/sickchill/requirements.txt index 332be36..b52b105 100644 --- a/sickchill/requirements.txt +++ b/sickchill/requirements.txt @@ -1,9 +1,5 @@ -# -# This file is autogenerated by pip-compile with Python 3.11 -# by the following command: -# -# pip-compile --no-emit-index-url --no-emit-trusted-host /src/requirements.in -# +# This file was autogenerated by uv via the following command: +# uv pip compile requirements.in -o requirements.txt --no-emit-index-url --no-emit-trusted-host appdirs==1.4.4 # via subliminal babelfish==0.6.0 @@ -56,9 +52,7 @@ future==0.18.3 gntp==1.0.3 # via sickchill greenlet==3.0.3 - # via - # sickchill - # sqlalchemy + # via sickchill guessit==3.8.0 # via # sickchill @@ -145,6 +139,8 @@ requests-oauthlib==1.3.1 # via python-twitter send2trash==1.8.2 # via sickchill +setuptools==74.1.2 + # via -r requirements.in sickchill==2024.3.1 # via -r requirements.in six==1.16.0 @@ -181,7 +177,9 @@ tus-py==1.3.4 tvdbsimple==1.0.6 # via sickchill typing-extensions==4.9.0 - # via sqlalchemy + # via + # dogpile-cache + # sqlalchemy unidecode==1.3.8 # via sickchill urllib3==2.2.0