Skip to content

Commit 35594d5

Browse files
committed
chore(ci): Simplify the Dockerfile after switching to uv
1 parent 976e0c9 commit 35594d5

File tree

3 files changed

+31
-81
lines changed

3 files changed

+31
-81
lines changed

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ gen: ${GENALL}
102102

103103
build-self: ensure-docker
104104
cargo build --all
105-
cd libs/gl-client-py; maturin develop --uv
106-
#mypy examples/python
105+
cd libs/gl-client-py; uv tool run maturin develop --uv
107106

108107
check-all: check-rs check-self check-py check-testing-py
109108

@@ -113,7 +112,7 @@ check-self: ensure-docker build-self
113112
ls -lha .venv/bin
114113
PYTHONPATH=/repo/libs/gl-testing \
115114
GL_TESTING_IGNORE_HASH=1 \
116-
uv run python3 -m pytest -vvv -s\
115+
uv run python3 -m pytest -vvv -n 4 \
117116
/repo/libs/gl-testing \
118117
${PYTEST_OPTS}
119118

@@ -154,19 +153,19 @@ docker-shell: docker-volumes
154153

155154
docker-check-self: docker-volumes
156155
docker run \
157-
-t \
156+
-ti \
158157
${DOCKER_OPTIONS} \
159158
gltesting make build-self check-self
160159

161160
docker-check-all:docker-volumes
162161
docker run \
163-
-t \
162+
-ti \
164163
${DOCKER_OPTIONS} \
165164
gltesting make build-self check-all
166165

167166
docker-check: docker-volumes
168167
docker run \
169-
-t \
168+
-ti \
170169
-v ${REPO_ROOT}:/repo \
171170
gltesting make check
172171

docker/gl-testing/Dockerfile

Lines changed: 25 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -45,39 +45,13 @@ RUN python3 -m venv /tmp/venv
4545
# This approach also ensures `poetry` and our environment don't overlap
4646
ENV POETRY_HOME=/tmp/poetry
4747
RUN curl -sSL https://install.python-poetry.org | python3 - --version 1.8.2
48-
ENV PATH=$POETRY_HOME/bin:$PATH
48+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
49+
ENV PATH=$POETRY_HOME/bin:$HOME/.local/bin:$PATH
4950

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
6151

52+
ADD . /repo
6253
WORKDIR /repo
6354

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
8155

8256
# ---------------------------------------------
8357
# STAGE: rust-builder
@@ -103,23 +77,6 @@ RUN rustup default stable
10377
# Ensure we can use cargo under a different user
10478
RUN chmod a+rwx -R $CARGO_HOME
10579

106-
# ------------------------------------------
107-
# STAGE: cln-downloader
108-
# -----------------------------------------
109-
# gl-testing requires multiple versions of Core Lightning
110-
# Download all versions so they can be copied to our dev-container
111-
FROM python-builder AS cln-downloader
112-
113-
ARG GL_TESTING_IGNORE_HASH=0
114-
115-
RUN mkdir -p /opt/cln/
116-
ENV CLNVM_CACHE_DIR=/opt/cln
117-
118-
ADD libs/cln-version-manager /repo/libs/cln-version-manager
119-
RUN cd /repo/libs/cln-version-manager; python -m pip install -e .
120-
121-
RUN GL_TESTING_IGNORE_HASH=${GL_TESTING_IGNORE_HASH} python -m clnvm get-all
122-
12380
# -------------------------------------
12481
# STAGE: bitcoin-downloader
12582
# ------------------------------------
@@ -192,6 +149,23 @@ ENV DEBIAN_FRONTEND=noninteractive
192149
ENV GL_DOCKER=1
193150
# Tells cln to use shorter polling intervals
194151
ENV DEVELOPER=1
152+
ENV PYTHONUNBUFFERED=1
153+
ENV PATH=$HOME/.local/bin:/opt/cln-latest/usr/local/bin:/opt/bitcoin/bin:/opt/cln-latest/usr/local/bin:$PATH
154+
ENV UV_INSTALL_DIR=/usr/local/bin/
155+
# grpcio == 1.46 produces spammy log messages, silence them
156+
ENV GRPC_ENABLE_FORK_SUPPORT=0
157+
158+
# Install cln-versions
159+
ENV CLNVM_CACHE_DIR=/opt/cln
160+
ENV GL_TESTING_IGNORE_HASH=1
161+
162+
# Enumerate all versions that gl-testing should find
163+
ENV CLN_PATH=/opt/cln/v0.10.1/usr/local/bin/:/opt/cln/v0.10.2/usr/local/bin/:/opt/cln/v0.11.0.1/usr/local/bin/:/opt/cln/v0.11.2gl2/usr/local/bin/:/opt/cln/v22.11gl1/usr/local/bin/:/opt/cln/v23.05gl1/usr/local/bin/:/opt/cln/v23.08gl1/usr/local/bin/:/opt/cln/v24.02gl1/usr/local/bin/
164+
165+
# Create a non-root user.
166+
ARG GID=0
167+
ARG UID=0
168+
ARG DOCKER_USER=dev
195169

196170
# Required dependencies and some dependencies which are nice to have
197171
# floating around
@@ -214,20 +188,8 @@ RUN apt-get update && apt install -qqy \
214188
# Set up a default logging filter. This includes all trace-level messages from greenlight components and validating lightning signer
215189
ENV RUST_LOG=gl_client=trace,tracing=warn,gl_signerproxy=trace,gl_plugin=trace,lightning_signer=trace,vls_protocol_signer=trace,vls_core=trace,vls_persist=trace,vls_protocol=trace,info
216190

217-
# grpcio == 1.46 produces spammy log messages, silence them
218-
ENV GRPC_ENABLE_FORK_SUPPORT=0
219-
220-
# Install cln-versions
221-
COPY --from=cln-downloader /opt/cln /opt/cln
222-
ENV CLNVM_CACHE_DIR=/opt/cln
223-
ENV PATH=/opt/cln-latest/usr/local/bin:$PATH
224-
225-
# Enumerate all versions that gl-testing should find
226-
ENV CLN_PATH=/opt/cln/v0.10.1/usr/local/bin/:/opt/cln/v0.10.2/usr/local/bin/:/opt/cln/v0.11.0.1/usr/local/bin/:/opt/cln/v0.11.2gl2/usr/local/bin/:/opt/cln/v22.11gl1/usr/local/bin/:/opt/cln/v23.05gl1/usr/local/bin/:/opt/cln/v23.08gl1/usr/local/bin/:/opt/cln/v24.02gl1/usr/local/bin/
227-
228191
# Install bitcoin-core
229192
COPY --from=bitcoin-downloader /opt/bitcoin/bin /opt/bitcoin/bin
230-
ENV PATH=/opt/bitcoin/bin:$PATH
231193

232194
# Install cfssl
233195
COPY --from=cfssl-downloader /usr/bin/cfssl /usr/local/bin/cfssl
@@ -236,18 +198,6 @@ COPY --from=cfssl-downloader /usr/bin/cfssljson /usr/local/bin/cfssljson
236198
# Install protoc
237199
COPY --from=protoc-downloader /usr/local/bin/protoc /usr/local/bin/protoc
238200

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-
247-
# Create a non-root user.
248-
ARG GID=0
249-
ARG UID=0
250-
ARG DOCKER_USER=dev
251201

252202
# Check if the group already exists before running groupadd
253203
RUN getent group $GID || groupadd -g $GID -o $DOCKER_USER && \
@@ -260,11 +210,11 @@ RUN mkdir -p /tmp/gltesting/cargo && mkdir -p /tmp/gltesting/tmp
260210

261211
ADD . /repo
262212
WORKDIR /repo
213+
ENV UV_LINK_MODE=copy
263214

264-
# Add the remaining repositories to the python-path
265-
RUN poetry install
266-
RUN chmod -R a+rw /tmp/venv
215+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
216+
RUN uv sync && uv pip install libs/cln-version-manager
217+
RUN uv run clnvm --verbose get-all
267218

268219
# Create a symlink to the latest cln-version and add it to the path
269-
RUN ln -s $(clnvm latest --root-path) /opt/cln-latest
270-
ENV PATH=/opt/cln-latest/usr/local/bin:$PATH
220+
RUN ln -s $(uv run --package cln-version-manager latest --root-path) /opt/cln-latest

libs/gl-client-py/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# `gl-client`: Greenlight Client Bindings for Python

0 commit comments

Comments
 (0)