From 37dcb67141c31f446621ab6694d834d1d94d3e29 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Thu, 23 Nov 2023 21:48:41 +0000 Subject: [PATCH 1/5] reorder Dockerfile for faster rebuild. --- Dockerfile | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 84c57c45..63f71ef5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,10 @@ # nosemgrep:github.workflows.config.dockerfile-source-not-pinned FROM ubuntu:22.04 as installer +ARG PIPCONF +ENV PIPCONF=$PIPCONF COPY --from=iqtlabs/gamutrf-base:latest /usr/local /usr/local ENV DEBIAN_FRONTEND noninteractive ENV PATH="${PATH}:/root/.local/bin" -WORKDIR /gamutrf -COPY gamutrf gamutrf/ -COPY bin bin/ -COPY templates templates/ -COPY poetry.lock pyproject.toml README.md /gamutrf/ SHELL ["/bin/bash", "-o", "pipefail", "-c"] # TODO: https://github.com/python-poetry/poetry/issues/3591 # Install pandas via pip to get wheel. Disabling the new installer/configuring a wheel source does not work. @@ -25,16 +22,18 @@ RUN apt-get update && apt-get install --no-install-recommends -y -q \ python3-pip && \ curl -sSL https://install.python-poetry.org | python3 - --version 1.4.2 && \ poetry config virtualenvs.create false && \ - python3 -m pip install --no-cache-dir --upgrade pip && \ - poetry run pip install --no-cache-dir pandas==$(grep pandas pyproject.toml | grep -Eo "[0-9\.]+") && \ + python3 -m pip install --no-cache-dir --upgrade pip +WORKDIR /gamutrf +COPY gamutrf gamutrf/ +COPY bin bin/ +COPY templates templates/ +COPY poetry.lock pyproject.toml README.md /gamutrf/ +RUN if [ "$PIPCONF" != "" ] ; then echo -e "$PIPCONF" > /etc/pip.conf ; fi +RUN poetry run pip install --no-cache-dir pandas==$(grep pandas pyproject.toml | grep -Eo "[0-9\.]+") && \ poetry install --no-interaction --no-dev --no-ansi # nosemgrep:github.workflows.config.dockerfile-source-not-pinned FROM ubuntu:22.04 -COPY --from=iqtlabs/gnuradio:3.10.8 /usr/share/uhd/images /usr/share/uhd/images -COPY --from=installer /usr/local /usr/local -COPY --from=installer /gamutrf /gamutrf -COPY --from=installer /root/.local /root/.local LABEL maintainer="Charlie Lewis " ENV DEBIAN_FRONTEND noninteractive ENV UHD_IMAGES_DIR /usr/share/uhd/images @@ -81,6 +80,10 @@ RUN if [ "$(arch)" = "x86_64" ] ; then \ wget \ zstd && \ apt-get -y -q clean && rm -rf /var/lib/apt/lists/* +COPY --from=iqtlabs/gnuradio:3.10.8 /usr/share/uhd/images /usr/share/uhd/images +COPY --from=installer /usr/local /usr/local +COPY --from=installer /gamutrf /gamutrf +COPY --from=installer /root/.local /root/.local WORKDIR /gamutrf RUN echo "$(find /gamutrf/gamutrf -type f -name \*py -print)"|xargs grep -Eh "^(import|from)\s"|grep -Ev "gamutrf"|sort|uniq|python3 RUN ldd /usr/local/bin/uhd_sample_recorder From d658d88da13b3642932a6ca152b220f3236a86d1 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Thu, 23 Nov 2023 22:59:37 +0000 Subject: [PATCH 2/5] ldconfig. --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 63f71ef5..141a763e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -84,6 +84,7 @@ COPY --from=iqtlabs/gnuradio:3.10.8 /usr/share/uhd/images /usr/share/uhd/images COPY --from=installer /usr/local /usr/local COPY --from=installer /gamutrf /gamutrf COPY --from=installer /root/.local /root/.local +RUN ldconfig -v WORKDIR /gamutrf RUN echo "$(find /gamutrf/gamutrf -type f -name \*py -print)"|xargs grep -Eh "^(import|from)\s"|grep -Ev "gamutrf"|sort|uniq|python3 RUN ldd /usr/local/bin/uhd_sample_recorder From 618bbfae83f242c5f7e3cc83d8bcf525f4eb8e33 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Thu, 23 Nov 2023 23:10:52 +0000 Subject: [PATCH 3/5] cache COPY --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 141a763e..856a89aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,6 @@ FROM ubuntu:22.04 as installer ARG PIPCONF ENV PIPCONF=$PIPCONF -COPY --from=iqtlabs/gamutrf-base:latest /usr/local /usr/local ENV DEBIAN_FRONTEND noninteractive ENV PATH="${PATH}:/root/.local/bin" SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -23,6 +22,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y -q \ curl -sSL https://install.python-poetry.org | python3 - --version 1.4.2 && \ poetry config virtualenvs.create false && \ python3 -m pip install --no-cache-dir --upgrade pip +COPY --from=iqtlabs/gamutrf-base:latest /usr/local /usr/local WORKDIR /gamutrf COPY gamutrf gamutrf/ COPY bin bin/ From 4817d602188de5f8f2c2bf2c6738b7c18f5e5044 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Fri, 24 Nov 2023 00:20:47 +0000 Subject: [PATCH 4/5] quote. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 856a89aa..63ad8982 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ COPY bin bin/ COPY templates templates/ COPY poetry.lock pyproject.toml README.md /gamutrf/ RUN if [ "$PIPCONF" != "" ] ; then echo -e "$PIPCONF" > /etc/pip.conf ; fi -RUN poetry run pip install --no-cache-dir pandas==$(grep pandas pyproject.toml | grep -Eo "[0-9\.]+") && \ +RUN poetry run pip install --no-cache-dir pandas=="$(grep pandas pyproject.toml | grep -Eo '[0-9\.]+')" && \ poetry install --no-interaction --no-dev --no-ansi # nosemgrep:github.workflows.config.dockerfile-source-not-pinned From 30c98b6058f63fa936682cc55e1bcd4beffe8059 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Fri, 24 Nov 2023 01:07:44 +0000 Subject: [PATCH 5/5] dependency install cacheable. --- Dockerfile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 63ad8982..95077a98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,5 @@ # nosemgrep:github.workflows.config.dockerfile-source-not-pinned FROM ubuntu:22.04 as installer -ARG PIPCONF -ENV PIPCONF=$PIPCONF ENV DEBIAN_FRONTEND noninteractive ENV PATH="${PATH}:/root/.local/bin" SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -24,13 +22,14 @@ RUN apt-get update && apt-get install --no-install-recommends -y -q \ python3 -m pip install --no-cache-dir --upgrade pip COPY --from=iqtlabs/gamutrf-base:latest /usr/local /usr/local WORKDIR /gamutrf +COPY poetry.lock pyproject.toml README.md /gamutrf/ +RUN poetry run pip install --no-cache-dir pandas=="$(grep pandas pyproject.toml | grep -Eo '[0-9\.]+')" +# dependency install is cached for faster rebuild, if only gamutrf source changed. +RUN poetry install --no-interaction --no-ansi --no-dev --no-root COPY gamutrf gamutrf/ COPY bin bin/ COPY templates templates/ -COPY poetry.lock pyproject.toml README.md /gamutrf/ -RUN if [ "$PIPCONF" != "" ] ; then echo -e "$PIPCONF" > /etc/pip.conf ; fi -RUN poetry run pip install --no-cache-dir pandas=="$(grep pandas pyproject.toml | grep -Eo '[0-9\.]+')" && \ - poetry install --no-interaction --no-dev --no-ansi +RUN poetry install --no-interaction --no-ansi --no-dev # nosemgrep:github.workflows.config.dockerfile-source-not-pinned FROM ubuntu:22.04