From 5bdd73d5f7a7642036a99dbaa5c53e0dd95d6f80 Mon Sep 17 00:00:00 2001 From: Charlie Marshak Date: Thu, 27 Feb 2025 18:34:33 -0800 Subject: [PATCH 1/4] update docker entrypoint --- CHANGELOG.md | 1 + Dockerfile.nvidia | 7 +++++-- src/dist_s1/etc/entrypoint.sh | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 src/dist_s1/etc/entrypoint.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index d70dbd6..cfc1a95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Github issue templates (thanks to Scott Staniewicz) - Tests for the CLI and main python interace tests. - Minimum for distmetrics to ensure proper target crs is utilized when merging. +- Updated entrypoint for the docker container to allow for CLI arguments to be passed directly to the container. ### Fixed - Ensures CLI correctly populates `apply_water_mask` and `water_mask_path` arguments. diff --git a/Dockerfile.nvidia b/Dockerfile.nvidia index 073b643..9e1c7ff 100644 --- a/Dockerfile.nvidia +++ b/Dockerfile.nvidia @@ -49,5 +49,8 @@ RUN echo ". /opt/miniforge/etc/profile.d/conda.sh" >> ~/.bashrc && \ # Install repository with pip RUN python -m pip install --no-cache-dir /home/ops/dist-s1 -ENTRYPOINT ["/bin/bash", "-l", "-c"] -CMD ["echo Greetings from OPERA DIST-S1 team"] \ No newline at end of file +## Allows us to provide CLI arguments to the container +## If interactively jump into the container is desired, +## overwrite the entrypoint with --entrypoint /bin/bash ... +ENTRYPOINT ["/home/ops/dist-s1/src/dist_s1/etc/entrypoint.sh"] +CMD ["-h"] \ No newline at end of file diff --git a/src/dist_s1/etc/entrypoint.sh b/src/dist_s1/etc/entrypoint.sh new file mode 100644 index 0000000..fe6f2d6 --- /dev/null +++ b/src/dist_s1/etc/entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/bash --login +set -e +exec python -um dist-s1 run "$@" \ No newline at end of file From ab7452945b49c497842c7dea50079fa9e5c1acb2 Mon Sep 17 00:00:00 2001 From: Charlie Marshak Date: Thu, 27 Feb 2025 18:34:42 -0800 Subject: [PATCH 2/4] update entrypoint --- Dockerfile | 4 ++-- Dockerfile.nvidia | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 950f322..c3847d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,5 +43,5 @@ RUN echo "conda activate dist-s1-env" >> ~/.bashrc # Install repository with pip RUN python -m pip install --no-cache-dir /home/ops/dist-s1 -ENTRYPOINT ["/bin/bash", "-l", "-c"] -CMD ["echo Greetings from OPERA DIST-S1 team"] \ No newline at end of file +ENTRYPOINT ["/home/ops/dist-s1/src/dist_s1/etc/entrypoint.sh"] +CMD ["--help"] \ No newline at end of file diff --git a/Dockerfile.nvidia b/Dockerfile.nvidia index 9e1c7ff..cb86056 100644 --- a/Dockerfile.nvidia +++ b/Dockerfile.nvidia @@ -53,4 +53,4 @@ RUN python -m pip install --no-cache-dir /home/ops/dist-s1 ## If interactively jump into the container is desired, ## overwrite the entrypoint with --entrypoint /bin/bash ... ENTRYPOINT ["/home/ops/dist-s1/src/dist_s1/etc/entrypoint.sh"] -CMD ["-h"] \ No newline at end of file +CMD ["--help"] \ No newline at end of file From 6e45eb4f5067a986caf2b327af5b5dfb06b945cd Mon Sep 17 00:00:00 2001 From: Charlie Marshak Date: Thu, 27 Feb 2025 19:06:28 -0800 Subject: [PATCH 3/4] fix underscore --- src/dist_s1/etc/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dist_s1/etc/entrypoint.sh b/src/dist_s1/etc/entrypoint.sh index fe6f2d6..ae272e9 100644 --- a/src/dist_s1/etc/entrypoint.sh +++ b/src/dist_s1/etc/entrypoint.sh @@ -1,3 +1,3 @@ #!/bin/bash --login set -e -exec python -um dist-s1 run "$@" \ No newline at end of file +exec python -um dist_s1 run "$@" \ No newline at end of file From c67c9f3be8a2576166dd7377dff1e73b1964d24d Mon Sep 17 00:00:00 2001 From: Charlie Marshak Date: Thu, 27 Feb 2025 19:21:03 -0800 Subject: [PATCH 4/4] update readme --- README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0a5e35e..307243b 100644 --- a/README.md +++ b/README.md @@ -164,8 +164,18 @@ docker build -f Dockerfile -t dist-s1-img . ``` On Mac ARM, you can specify the target platform via: ``` -docker buildx build --platform linux/amd64 -f Dockerfile -t dist-s1 . +docker buildx build --platform linux/amd64 -f Dockerfile -t dist-s1-img . ``` +The docker image will be tagged with `dist-s1-img` in the above examples. + +### Generating a Sample Product via a Docker Container + +To generate a sample product via a docker container (e.g. the one built above), run: +``` +docker run -ti --rm dist-s1-img --mgrs_tile_id '11SLT' --post_date '2025-01-21' --track_number 71 +``` +See the `src/dist_s1/etc/entrypoint.sh` file for the entrypoint of the container. It runs `dist-s1 run...`. + ### GPU Docker Image @@ -177,7 +187,7 @@ See issue [#22](https://github.com/opera-adt/dist-s1/issues/22) for more details To run the container interactively: ``` -docker run -ti --rm dist-s1 bash +docker run -ti --rm --entrypoint "/bin/bash" dist-s1-img # assuming the image is tagged as dist-s1-img ``` Within the container, you can run the CLI commands and the test suite. The `--rm` ensures that the container is removed after we exit the shell. @@ -200,8 +210,9 @@ docker pull ghcr.io/opera-adt/dist-s1:0.0.4 The command will pull the latest released version of the Docker image. To run the test suite, run: ``` -docker run --rm ghcr.io/opera-adt/dist-s1 'cd dist-s1 && pytest tests' +docker run --rm --entrypoint '/bin/bash' ghcr.io/opera-adt/dist-s1 -c -l 'cd dist-s1 && pytest tests' ``` +Note we have to use the `--entrypoint` flag to overwrite the entrypoint of the container which is `python -um dist_s1 run` by default. # Contribution Instructions