STAC Catalog
Goal
Create a container and run the stac
step in the container image tagged localhost/stac:latest
.
Lab
This step has a dedicated lab available at /workspace/mastering-app-package/practice-labs/Containers/stac.ipynb
Container
Each step has its own recipe to build the container image.
The stac
step container image recipe is:
stac/Dockerfile |
---|
| FROM docker.io/library/python:3.10-slim@sha256:80619a5316afae7045a3c13371b0ee670f39bac46ea1ed35081d2bf91d6c3dbd
RUN pip install --no-cache-dir pystac rio_stac loguru click && \
python -c "import rio_stac"
ADD app.py /app/app.py
ENTRYPOINT []
|
Build the container image with:
terminal |
---|
| export WORKSPACE=/workspace/mastering-app-package
podman build --format docker -t localhost/crop:latest ${WORKSPACE}/water-bodies/command-line-tools/crop
podman build --format docker -t localhost/norm-diff:latest ${WORKSPACE}/water-bodies/command-line-tools/norm_diff
podman build --format docker -t localhost/otsu:latest ${WORKSPACE}/water-bodies/command-line-tools/otsu
|
Run the container
The command to run the stac
step in the container is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 | podman \
run \
-i \
--userns=keep-id \
--mount=type=bind,source=/workspace/mastering-app-package/runs,target=/runs \
--mount=type=bind,source=/workspace/mastering-app-package/runs/otsu.tif,target=/inputs/otsu.tif,readonly \
--workdir=/runs \
--read-only=true \
--user=1001:100 \
--rm \
--env=HOME=/runs \
--env=PYTHONPATH=/app \
localhost/stac:latest \
python \
-m \
app \
--input-item \
https://earth-search.aws.element84.com/v0/collections/sentinel-s2-l2a-cogs/items/S2B_10TFK_20210713_0_L2A \
--water-body \
/inputs/otsu.tif
|
Step
Run the command to run the stac
step with:
sh -x ${WORKSPACE}/scripts/podman-stac.sh
Expected outcome
The folder /workspace/mastering-app-package/runs
contains:
(base) jovyan@coder-mrossi:~/runs$ tree .
.
├── S2B_10TFK_20210713_0_L2A
│ ├── S2B_10TFK_20210713_0_L2A.json
│ └── otsu.tif
├── catalog.json
├── crop_green.tif
├── crop_nir.tif
├── norm_diff.tif
└── otsu.tif
1 directory, 7 files