From ecd6f37cb665e04f753606c433deba61deb8baaa Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Tue, 2 Dec 2025 05:02:02 +0000 Subject: [PATCH 1/2] Install dependencies in separate layer in Dockerfile --- docker/lnt.dockerfile | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/docker/lnt.dockerfile b/docker/lnt.dockerfile index d2d17cbf..0e354143 100644 --- a/docker/lnt.dockerfile +++ b/docker/lnt.dockerfile @@ -28,17 +28,21 @@ FROM python:3.10-alpine -# Install dependencies -RUN apk update \ - && apk add --no-cache --virtual .build-deps git g++ postgresql-dev yaml-dev \ - && apk add --no-cache libpq +COPY pyproject.toml . +COPY lnt/testing/profile lnt/testing/profile -# Install LNT itself, without leaving behind any sources inside the image. -RUN --mount=type=bind,source=.,target=./lnt-source \ - cp -R lnt-source /tmp/lnt-src && \ - cd /tmp/lnt-src && \ - pip3 install -r requirements.server.txt && apk --purge del .build-deps && \ - rm -rf /tmp/lnt-src +# Install dependencies and build cperf ext-modules. +# Need to temporarily mount .git for sourcetools-scm. +RUN --mount=source=.git,target=.git,type=bind \ + apk update \ + && apk add --no-cache --virtual .build-deps g++ postgresql-dev yaml-dev \ + && apk add --no-cache git libpq \ + && pip install ".[server]" \ + && apk --purge del .build-deps + +# Copy over sources and install LNT. +COPY . . +RUN pip install . # Prepare volumes that will be used by the server VOLUME /var/lib/lnt /var/log/lnt From 30fc001d344c28f8a11e3c450123e20c6d860afe Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Tue, 2 Dec 2025 05:26:35 +0000 Subject: [PATCH 2/2] Use fake scm version --- docker/lnt.dockerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docker/lnt.dockerfile b/docker/lnt.dockerfile index 0e354143..5d945acb 100644 --- a/docker/lnt.dockerfile +++ b/docker/lnt.dockerfile @@ -31,15 +31,18 @@ FROM python:3.10-alpine COPY pyproject.toml . COPY lnt/testing/profile lnt/testing/profile +# Fake a version for setuptools so we don't need to COPY .git +ENV SETUPTOOLS_SCM_PRETEND_VERSION=0.1 + # Install dependencies and build cperf ext-modules. -# Need to temporarily mount .git for sourcetools-scm. -RUN --mount=source=.git,target=.git,type=bind \ - apk update \ +RUN apk update \ && apk add --no-cache --virtual .build-deps g++ postgresql-dev yaml-dev \ && apk add --no-cache git libpq \ && pip install ".[server]" \ && apk --purge del .build-deps +# Let setuptools_scm use git to pick the version +ENV SETUPTOOLS_SCM_PRETEND_VERSION= # Copy over sources and install LNT. COPY . . RUN pip install .