3434#
3535# Later, we'll copy this venv to our project
3636FROM ubuntu:22.04 AS python-builder
37- RUN apt update && apt install -qqy curl python3 python3-pip python3-venv libpq-dev
38-
39- # Create a python-venv that will include all dependencies
40- ENV PATH=/tmp/venv/bin:$PATH
41- RUN python3 -m venv /tmp/venv
42-
43- # We use the official poetry installer
44- # This ensures poetry is always up-to-date.
45- # This approach also ensures `poetry` and our environment don't overlap
46- ENV POETRY_HOME=/tmp/poetry
47- RUN curl -sSL https://install.python-poetry.org | python3 - --version 1.8.2
48- ENV PATH=$POETRY_HOME/bin:$PATH
49-
50- # Uncomment below line after poetry v2.x.x upgrade
51- # RUN poetry self add poetry-plugin-export
52-
53- # The pyproject.toml files describe our project
54- # I purposefully ignore lock-files here
55- # We are developping a libraries and if a new version of a
56- # dependency breaks our code I want to be the first to know it
57- ADD pyproject.toml /repo/pyproject.toml
58- ADD libs/gl-client-py/pyproject.toml /repo/libs/gl-client-py/pyproject.toml
59- ADD libs/gl-testing/pyproject.toml /repo/libs/gl-testing/pyproject.toml
60- ADD libs/cln-version-manager/pyproject.toml /repo/libs/cln-version-manager/pyproject.toml
37+ RUN apt update && apt install -qqy curl python3 python3-pip libpq-dev
6138
62- WORKDIR /repo
39+ # `uv` manages both python versions and python packages.
40+ RUN curl -LsSf https://astral.sh/uv/0.5.22/install.sh | sh
6341
64- # We don't want to reinstall depenendencies every time
65- # a single line of library code changes.
66- #
67- # Poetry install requires us to ADD the library-code to
68- # the dockerfile. So this approach doesn't work
69- #
70- # Using poetry export we can generate a list of all dependencies.
71- # We filter out all path-depenendencies from this list cause we
72- # don't have the code in the Docker-repo yet.
73- RUN poetry lock
74- RUN poetry export -f requirements.txt -o requirements.txt --with=dev
75- RUN cat requirements.txt | sed '/file:\/\/\/ /d' > requirements2.txt
76- RUN python -m pip install --upgrade pip && pip install wheel && pip install -r requirements2.txt
77-
78- # Later we will run this image under another user
79- # It is great if they can access this as well
80- RUN chmod a+rwx -R /tmp/venv
42+ WORKDIR /repo
8143
8244# ---------------------------------------------
8345# STAGE: rust-builder
@@ -116,9 +78,10 @@ RUN mkdir -p /opt/cln/
11678ENV CLNVM_CACHE_DIR=/opt/cln
11779
11880ADD libs/cln-version-manager /repo/libs/cln-version-manager
119- RUN cd /repo/libs/cln-version-manager; python -m pip install -e .
12081
121- RUN GL_TESTING_IGNORE_HASH=${GL_TESTING_IGNORE_HASH} python -m clnvm get-all
82+ # Use the system python3 to install into the OS. `uv` won't have the
83+ # source in the derived containers.
84+ RUN python3 -m pip install /repo/libs/cln-version-manager
12285
12386# -------------------------------------
12487# STAGE: bitcoin-downloader
@@ -236,14 +199,6 @@ COPY --from=cfssl-downloader /usr/bin/cfssljson /usr/local/bin/cfssljson
236199# Install protoc
237200COPY --from=protoc-downloader /usr/local/bin/protoc /usr/local/bin/protoc
238201
239- # Copy the installs from the python-builder
240- COPY --from=python-builder /tmp/poetry /tmp/poetry
241- COPY --from=python-builder /tmp/venv /tmp/venv
242- COPY --from=python-builder /repo/poetry.lock /repo/poetry.lock
243-
244- ENV PATH=/tmp/poetry/bin:/tmp/venv/bin:$PATH
245- ENV VIRTUAL_ENV=/tmp/venv
246-
247202# Create a non-root user.
248203ARG GID=0
249204ARG UID=0
@@ -262,8 +217,7 @@ ADD . /repo
262217WORKDIR /repo
263218
264219# Add the remaining repositories to the python-path
265- RUN poetry install
266- RUN chmod -R a+rw /tmp/venv
220+ RUN python3 -m pip install libs/cln-version-manager/
267221
268222# Create a symlink to the latest cln-version and add it to the path
269223RUN ln -s $(clnvm latest --root-path) /opt/cln-latest
0 commit comments