From d18f4ddf7686ebbeaa7cbfa507cf7c67f00e27e6 Mon Sep 17 00:00:00 2001 From: Benjamin Pelletier Date: Wed, 26 Aug 2026 18:04:28 +0000 Subject: [PATCH 1/3] Add Gemini changes --- monitoring/Dockerfile | 79 +++++++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 22 deletions(-) diff --git a/monitoring/Dockerfile b/monitoring/Dockerfile index 905477466c..e99fffa992 100644 --- a/monitoring/Dockerfile +++ b/monitoring/Dockerfile @@ -9,7 +9,7 @@ # # This image is intended to be built from the repository root context/folder. -FROM ghcr.io/astral-sh/uv:0.12.5-python3.13-trixie-slim AS base +FROM ghcr.io/astral-sh/uv:0.12.5-python3.13-trixie-slim AS base-system # Not -alpine because: https://stackoverflow.com/a/58028091/651139 # Install system tools @@ -28,18 +28,10 @@ RUN if [ "$(uname -m)" = "aarch64" ]; then \ RUN mkdir -p /app/ -# This image should be built by passing in `version` and `commit_hash` based on information from git (see `make image`) -# This version information becomes available in the environment variables specified below -ARG version -ARG commit_hash -ENV MONITORING_VERSION=$version -ENV GIT_COMMIT_HASH=$commit_hash - # Install dependencies ENV UV_LINK_MODE=copy ENV UV_PROJECT_ENVIRONMENT=/venv/ ENV VIRTUAL_ENV=/venv/ -ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MONITORING=$version RUN --mount=type=cache,target=/root/.cache/uv \ --mount=type=bind,source=./uv.lock,target=/app/uv.lock \ --mount=type=bind,source=./pyproject.toml,target=/app/pyproject.toml \ @@ -59,6 +51,44 @@ RUN find /root/ -type d -exec chmod a+rx {} + # Start in this folder WORKDIR /app/monitoring +# Discover `monitoring` module in Python +ENV PYTHONPATH=/app + +# Add venv to path +ENV PATH="/venv/bin/:$PATH" + +# No entry point maximizes flexibility in the use of this image +ENTRYPOINT [] + +FROM base-system AS dev-dependencies + +# Install dev dependencies +RUN --mount=type=cache,target=/root/.cache/uv \ + --mount=type=bind,source=./uv.lock,target=/app/uv.lock \ + --mount=type=bind,source=./pyproject.toml,target=/app/pyproject.toml \ + cd /app/ && \ + unset UV_FROZEN && \ + uv sync --locked --no-install-project --compile-bytecode --group dev + +# Ensure UV don't check dependencies or lock file, since we installed everything before +ENV UV_FROZEN=1 +ENV UV_NO_SYNC=1 + +# Ensure the cache folder is present and writable by anyone +RUN mkdir -p /.cache/uv/ && chmod 777 /.cache/uv/ +# Also fix the root folder where python is downloaded +RUN find /root/ -type d -exec chmod a+rx {} + + +FROM base-system AS base + +# This image should be built by passing in `version` and `commit_hash` based on information from git (see `make image`) +# This version information becomes available in the environment variables specified below +ARG version +ARG commit_hash +ENV MONITORING_VERSION=$version +ENV GIT_COMMIT_HASH=$commit_hash +ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MONITORING=$version + # Add core content from repo ADD ./interfaces /app/interfaces ADD ./monitoring /app/monitoring @@ -73,21 +103,26 @@ RUN mkdir -p /app/uss-host-files # This script indicates the status of the container HEALTHCHECK --interval=3s CMD sh /app/health_check.sh -# Discover `monitoring` module in Python -ENV PYTHONPATH=/app +FROM dev-dependencies AS with-dev-dependencies -# Add venv to path -ENV PATH="/venv/bin/:$PATH" +# This image should be built by passing in `version` and `commit_hash` based on information from git (see `make image-dev`) +# This version information becomes available in the environment variables specified below +ARG version +ARG commit_hash +ENV MONITORING_VERSION=$version +ENV GIT_COMMIT_HASH=$commit_hash +ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MONITORING=$version +# Add core content from repo +ADD ./interfaces /app/interfaces +ADD ./monitoring /app/monitoring -# No entry point maximizes flexibility in the use of this image -ENTRYPOINT [] +# Add health check to the /app root and make it executable +COPY ./monitoring/health_check.sh /app/health_check.sh +RUN chmod 766 /app/health_check.sh -FROM base AS with-dev-dependencies +# Additional preparations for uss_qualifier/webapp +RUN mkdir -p /app/uss-host-files -RUN --mount=type=cache,target=/root/.cache/uv \ - --mount=type=bind,source=./uv.lock,target=/app/uv.lock \ - --mount=type=bind,source=./pyproject.toml,target=/app/pyproject.toml \ - cd /app/ && \ - unset UV_FROZEN && \ - uv sync --locked --no-install-project --compile-bytecode --group dev +# This script indicates the status of the container +HEALTHCHECK --interval=3s CMD sh /app/health_check.sh From d962cc79c5e78890129d7b013cc236e23d4b8d65 Mon Sep 17 00:00:00 2001 From: Benjamin Pelletier Date: Wed, 26 Aug 2026 18:29:40 +0000 Subject: [PATCH 2/3] Adjust and document --- monitoring/Dockerfile | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/monitoring/Dockerfile b/monitoring/Dockerfile index e99fffa992..78ff0d16c0 100644 --- a/monitoring/Dockerfile +++ b/monitoring/Dockerfile @@ -1,5 +1,8 @@ # Dockerfile for interuss/monitoring # +# This file should generally be used via `make image` and/or `make image-dev` +# from the repo root. +# # The image generated by this Dockerfile (via ./build.sh) includes the entire # `monitoring` folder contents in /app/monitoring and has installed dependencies # necessary to run any of the monitoring tools. See documentation for any of @@ -9,6 +12,28 @@ # # This image is intended to be built from the repository root context/folder. +# Stage hierarchy: +# ghcr.io/astral-sh/uv +# │ +# ▼ +# [base-system] +# • Install system packages (apt) +# • RUN uv sync (base dependencies) +# • CACHED as long as uv.lock does not change +# │ +# ┌──────────┴──────────┐ +# │ │ +# ▼ ▼ +# [base] [dev-dependencies] +# • ADD ./monitoring • RUN uv sync --group dev +# • Ready for prod • CACHED as long as uv.lock does not change +# • (interuss/monitoring) │ +# ▼ +# [with-dev-dependencies] +# • ADD ./monitoring +# • Ready for local dev & formatting +# • (interuss/monitoring-dev) + FROM ghcr.io/astral-sh/uv:0.12.5-python3.13-trixie-slim AS base-system # Not -alpine because: https://stackoverflow.com/a/58028091/651139 @@ -38,12 +63,12 @@ RUN --mount=type=cache,target=/root/.cache/uv \ cd /app/ && \ uv sync --locked --no-install-project --compile-bytecode -# Ensure UV don't check dependencies or lock file, since we installed everything before +# Ensure UV doesn't check dependencies or lock file (we've already installed everything for the base system above) ENV UV_FROZEN=1 ENV UV_NO_SYNC=1 # Ensure the cache folder is present and writable by anyone -# (Some command run with limited privileges) +# (Some commands run with limited privileges) RUN mkdir -p /.cache/uv/ && chmod 777 /.cache/uv/ # Also fix the root folder where python is downloaded RUN find /root/ -type d -exec chmod a+rx {} + @@ -62,7 +87,7 @@ ENTRYPOINT [] FROM base-system AS dev-dependencies -# Install dev dependencies +# Install dev dependencies (unsetting flag not to check dependencies) RUN --mount=type=cache,target=/root/.cache/uv \ --mount=type=bind,source=./uv.lock,target=/app/uv.lock \ --mount=type=bind,source=./pyproject.toml,target=/app/pyproject.toml \ @@ -70,15 +95,6 @@ RUN --mount=type=cache,target=/root/.cache/uv \ unset UV_FROZEN && \ uv sync --locked --no-install-project --compile-bytecode --group dev -# Ensure UV don't check dependencies or lock file, since we installed everything before -ENV UV_FROZEN=1 -ENV UV_NO_SYNC=1 - -# Ensure the cache folder is present and writable by anyone -RUN mkdir -p /.cache/uv/ && chmod 777 /.cache/uv/ -# Also fix the root folder where python is downloaded -RUN find /root/ -type d -exec chmod a+rx {} + - FROM base-system AS base # This image should be built by passing in `version` and `commit_hash` based on information from git (see `make image`) @@ -105,6 +121,9 @@ HEALTHCHECK --interval=3s CMD sh /app/health_check.sh FROM dev-dependencies AS with-dev-dependencies +# The operations in this stage should be identical to those in the `base` stage; the only difference is which base image we're starting from. +# TODO: Consider making more DRY with BASE_STAGE ARG + FROM ${BASE_STAGE} AS final, using BASE_STAGE instead of --target when building (to avoid duplication of these steps) + # This image should be built by passing in `version` and `commit_hash` based on information from git (see `make image-dev`) # This version information becomes available in the environment variables specified below ARG version From ac9e3692d7b893dd800f0eb17d15712db17145fb Mon Sep 17 00:00:00 2001 From: Benjamin Pelletier Date: Wed, 26 Aug 2026 18:53:24 +0000 Subject: [PATCH 3/3] Replace --target with BASE_STAGE arg --- monitoring/Dockerfile | 51 +++++++++++------------------------------ monitoring/build.sh | 1 - monitoring/build_dev.sh | 2 +- 3 files changed, 14 insertions(+), 40 deletions(-) diff --git a/monitoring/Dockerfile b/monitoring/Dockerfile index 78ff0d16c0..08c93e5f24 100644 --- a/monitoring/Dockerfile +++ b/monitoring/Dockerfile @@ -22,17 +22,19 @@ # • CACHED as long as uv.lock does not change # │ # ┌──────────┴──────────┐ -# │ │ +# │ (default) │ # ▼ ▼ -# [base] [dev-dependencies] -# • ADD ./monitoring • RUN uv sync --group dev -# • Ready for prod • CACHED as long as uv.lock does not change -# • (interuss/monitoring) │ -# ▼ -# [with-dev-dependencies] -# • ADD ./monitoring -# • Ready for local dev & formatting -# • (interuss/monitoring-dev) +# [base-system] [dev-dependencies] +# │ • RUN uv sync --group dev +# │ • CACHED as long as uv.lock does not change +# │ │ +# └──────────┬──────────┘ +# ▼ +# [final] (FROM ${BASE_STAGE}) +# • ADD ./monitoring +# • Ready for prod/dev + +ARG BASE_STAGE=base-system FROM ghcr.io/astral-sh/uv:0.12.5-python3.13-trixie-slim AS base-system # Not -alpine because: https://stackoverflow.com/a/58028091/651139 @@ -95,7 +97,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \ unset UV_FROZEN && \ uv sync --locked --no-install-project --compile-bytecode --group dev -FROM base-system AS base +FROM ${BASE_STAGE} AS final # This image should be built by passing in `version` and `commit_hash` based on information from git (see `make image`) # This version information becomes available in the environment variables specified below @@ -118,30 +120,3 @@ RUN mkdir -p /app/uss-host-files # This script indicates the status of the container HEALTHCHECK --interval=3s CMD sh /app/health_check.sh - -FROM dev-dependencies AS with-dev-dependencies - -# The operations in this stage should be identical to those in the `base` stage; the only difference is which base image we're starting from. -# TODO: Consider making more DRY with BASE_STAGE ARG + FROM ${BASE_STAGE} AS final, using BASE_STAGE instead of --target when building (to avoid duplication of these steps) - -# This image should be built by passing in `version` and `commit_hash` based on information from git (see `make image-dev`) -# This version information becomes available in the environment variables specified below -ARG version -ARG commit_hash -ENV MONITORING_VERSION=$version -ENV GIT_COMMIT_HASH=$commit_hash -ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MONITORING=$version - -# Add core content from repo -ADD ./interfaces /app/interfaces -ADD ./monitoring /app/monitoring - -# Add health check to the /app root and make it executable -COPY ./monitoring/health_check.sh /app/health_check.sh -RUN chmod 766 /app/health_check.sh - -# Additional preparations for uss_qualifier/webapp -RUN mkdir -p /app/uss-host-files - -# This script indicates the status of the container -HEALTHCHECK --interval=3s CMD sh /app/health_check.sh diff --git a/monitoring/build.sh b/monitoring/build.sh index 136ca42938..b20baa25ff 100755 --- a/monitoring/build.sh +++ b/monitoring/build.sh @@ -19,7 +19,6 @@ docker image build \ -t "${TAG}" \ --build-arg version="$(scripts/git/version.sh monitoring --long)" \ --build-arg commit_hash="$(git rev-parse HEAD)" \ - --target base \ . \ || exit 1 diff --git a/monitoring/build_dev.sh b/monitoring/build_dev.sh index 772c9ee9e2..ccca5a6da6 100755 --- a/monitoring/build_dev.sh +++ b/monitoring/build_dev.sh @@ -17,9 +17,9 @@ TAG="${1:-interuss/monitoring}" docker image build \ -f monitoring/Dockerfile \ -t "${TAG}-dev" \ + --build-arg BASE_STAGE=dev-dependencies \ --build-arg version="$(scripts/git/version.sh monitoring --long)" \ --build-arg commit_hash="$(git rev-parse HEAD)" \ - --target with-dev-dependencies \ . \ || exit 1