From 1e7622be054e26f9fca4ef521fa9372cbd13d51e Mon Sep 17 00:00:00 2001 From: Ethan Li Date: Mon, 26 Feb 2024 11:50:07 -0800 Subject: [PATCH 1/6] Stop dropping root in segmenter container --- processing/segmenter/Dockerfile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/processing/segmenter/Dockerfile b/processing/segmenter/Dockerfile index 87997e5b..26f36280 100644 --- a/processing/segmenter/Dockerfile +++ b/processing/segmenter/Dockerfile @@ -11,10 +11,9 @@ RUN \ rm -rf /var/lib/apt/lists/* && \ rm /tmp/apt-packages -# Drop root user - RUN useradd --create-home pi -USER pi:pi +# For now, we don't drop root because dirs are made as root by the hardware controller: +# USER pi:pi RUN mkdir -p /home/pi/device-backend/processing/segmenter WORKDIR /home/pi/device-backend/processing/segmenter @@ -38,9 +37,13 @@ RUN \ # Set up application -# Note: we must explicitly set chown here, or else filfes will be copied with root permissions -COPY --chown=pi:pi main.py . -COPY --chown=pi:pi planktoscope/ ./planktoscope +# For now, we don't drop root because dirs are made as root by the hardware controller: +# Note: we must explicitly set chown if we drop root, or else files will be copied with root +# permissions. +# COPY --chown=pi:pi main.py . +COPY main.py . +# COPY --chown=pi:pi planktoscope/ ./planktoscope +COPY planktoscope/ ./planktoscope ENTRYPOINT ["/home/pi/.local/bin/poetry", "run", "python", "main.py"] EXPOSE 8001 RUN mkdir -p /home/pi/device-backend-logs/processing/segmenter From f7553e64ca068c91e0c139e22ca403b7a995f5c5 Mon Sep 17 00:00:00 2001 From: Ethan Li Date: Mon, 26 Feb 2024 12:24:33 -0800 Subject: [PATCH 2/6] Update `CHANGELOG.md` --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad8fbf87..1f029928 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ All dates in this file are given in the [UTC time zone](https://en.wikipedia.org ### Fixed - (Hardware controller) The pixel calibration values have been switched between the default v2.5 hardware config file and the default v2.6 hardware config file, so that each file has the correct pixel calibration. The default pscopehat hardware config file has also been updated to include the changes made to the default v2.6 hardware config file. +- (Breaking change; segmenter) The segmenter now runs as `root` (instead of `pi`) in the Docker container for it, so that it doesn't break on various actual & potential edge cases of files/directories being created with `root` ownership (rather than `pi` ownership) before being bind mounted into the container. ## v2024.0.0-alpha.0 - 2024-02-06 From cddd2f620803febd9356f032392378df23b40a45 Mon Sep 17 00:00:00 2001 From: Ethan Li Date: Mon, 26 Feb 2024 12:26:40 -0800 Subject: [PATCH 3/6] Update version strings in `pyproject.toml` (forgot to do that for v2024.0.0-alpha.0) --- control/pyproject.toml | 2 +- processing/segmenter/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/control/pyproject.toml b/control/pyproject.toml index 6b359670..17c9c2d8 100644 --- a/control/pyproject.toml +++ b/control/pyproject.toml @@ -2,7 +2,7 @@ name = "planktoscope-controller" # Note: PEP 440 requires pre-releases to be formatted like "2023.7.0b0" rather than # "2023.7.0-beta.0", which is different from the Semantic Versioning schema -version = "2023.9.0" +version = "2024.0.0a0" description = "Controller of PlanktoScope hardware" # For simplicity, we follow the definition of "Maintainer" from # https://opensource.guide/how-to-contribute/#anatomy-of-an-open-source-project , which says: diff --git a/processing/segmenter/pyproject.toml b/processing/segmenter/pyproject.toml index 922bcf89..1cae91a6 100644 --- a/processing/segmenter/pyproject.toml +++ b/processing/segmenter/pyproject.toml @@ -2,7 +2,7 @@ name = "planktoscope-processing-segmenter" # Note: PEP 440 requires pre-releases to be formatted like "2023.7.0b0" rather than # "2023.7.0-beta.0", which is different from the Semantic Versioning schema -version = "2023.9.0" +version = "2024.0.0a0" description = "Data processor to segment objects from raw PlanktoScope data" # For simplicity, we follow the definition of "Maintainer" from # https://opensource.guide/how-to-contribute/#anatomy-of-an-open-source-project , which says: From d5f56921b3b7c91f31287b9638d66b269609dd40 Mon Sep 17 00:00:00 2001 From: Ethan Li Date: Mon, 26 Feb 2024 12:31:47 -0800 Subject: [PATCH 4/6] Try to resolve GitHub Actions merge job failure on merge queue --- .github/workflows/processing-segmenter-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/processing-segmenter-build.yml b/.github/workflows/processing-segmenter-build.yml index db72cced..ea53eaaf 100644 --- a/.github/workflows/processing-segmenter-build.yml +++ b/.github/workflows/processing-segmenter-build.yml @@ -134,5 +134,6 @@ jobs: $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - name: Inspect image + if: github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'push tag' run: | docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} From 9bf9433b3e144c6fd0158d89a63da60828d98b4d Mon Sep 17 00:00:00 2001 From: Ethan Li Date: Mon, 26 Feb 2024 15:03:58 -0800 Subject: [PATCH 5/6] Try to fix location of poetry & pip cache for root user --- processing/segmenter/Dockerfile | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/processing/segmenter/Dockerfile b/processing/segmenter/Dockerfile index 26f36280..5f9c0068 100644 --- a/processing/segmenter/Dockerfile +++ b/processing/segmenter/Dockerfile @@ -24,26 +24,23 @@ WORKDIR /home/pi/device-backend/processing/segmenter # the container image. COPY --chown=pi:pi pyproject.toml poetry.lock . RUN \ - export PATH="/home/pi/.local/bin:$PATH" && \ + export PATH="/root/.local/bin:$PATH" && \ pip install --no-cache-dir poetry==1.7.1 --extra-index-url https://www.piwheels.org/simple && \ poetry install --no-root --only main --compile && \ poetry --no-interaction cache list && \ poetry --no-interaction cache clear pypi --all && \ poetry --no-interaction cache clear piwheels --all && \ - rm -rf /home/pi/.cache/pypoetry/artifacts && \ - rm -rf /home/pi/.cache/pypoetry/cache && \ + rm -rf /root/.cache/pypoetry/artifacts && \ + rm -rf /root/.cache/pypoetry/cache && \ pip cache purge && \ - rm -rf /home/pi/.cache/pip + rm -rf /root/.cache/pip # Set up application -# For now, we don't drop root because dirs are made as root by the hardware controller: # Note: we must explicitly set chown if we drop root, or else files will be copied with root # permissions. -# COPY --chown=pi:pi main.py . -COPY main.py . -# COPY --chown=pi:pi planktoscope/ ./planktoscope -COPY planktoscope/ ./planktoscope -ENTRYPOINT ["/home/pi/.local/bin/poetry", "run", "python", "main.py"] +COPY --chown=pi:pi main.py . +COPY --chown=pi:pi planktoscope/ ./planktoscope +ENTRYPOINT ["/root/.local/bin/poetry", "run", "python", "main.py"] EXPOSE 8001 RUN mkdir -p /home/pi/device-backend-logs/processing/segmenter From a54acbf3ed869773ae4d8a43e0590cdb601c0849 Mon Sep 17 00:00:00 2001 From: Ethan Li Date: Mon, 26 Feb 2024 15:53:14 -0800 Subject: [PATCH 6/6] Fix more errors in Dockerfile --- processing/segmenter/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/processing/segmenter/Dockerfile b/processing/segmenter/Dockerfile index 5f9c0068..0855f83c 100644 --- a/processing/segmenter/Dockerfile +++ b/processing/segmenter/Dockerfile @@ -24,7 +24,7 @@ WORKDIR /home/pi/device-backend/processing/segmenter # the container image. COPY --chown=pi:pi pyproject.toml poetry.lock . RUN \ - export PATH="/root/.local/bin:$PATH" && \ + export PATH="/home/pi/.local/bin:$PATH" && \ pip install --no-cache-dir poetry==1.7.1 --extra-index-url https://www.piwheels.org/simple && \ poetry install --no-root --only main --compile && \ poetry --no-interaction cache list && \ @@ -41,6 +41,7 @@ RUN \ # permissions. COPY --chown=pi:pi main.py . COPY --chown=pi:pi planktoscope/ ./planktoscope -ENTRYPOINT ["/root/.local/bin/poetry", "run", "python", "main.py"] +# ENTRYPOINT ["/home/pi/.local/bin/poetry", "run", "python", "main.py"] +ENTRYPOINT ["/usr/local/bin/poetry", "run", "python", "main.py"] EXPOSE 8001 RUN mkdir -p /home/pi/device-backend-logs/processing/segmenter