Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Then:

```shell
source .venv/bin/activate
cp .env.local .env
cd infrastructure/aws
cp .env.local .env
# Make sure you're using the eoAPI sub-account
aws sso login --profile eoapi && eval "$(aws configure export-credentials --profile eoapi --format env)" # or however you configure your AWS sessions
cdk diff # to show any differences
Expand Down
2 changes: 2 additions & 0 deletions infrastructure/aws/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ def __init__(
),
environment={
"STAC_FASTAPI_GEOPARQUET_HREF": f"s3://{bucket.bucket_name}/{config.geoparquet_key}",
# find pre-fetched extensions
"STAC_FASTAPI_DUCKDB_EXTENSION_DIRECTORY": "/asset",
"HOME": "/tmp", # for duckdb's home_directory
},
)
Expand Down
31 changes: 17 additions & 14 deletions infrastructure/aws/lambda/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
ARG PYTHON_VERSION=3.12
ARG BUILDPLATFORM=x86_64

FROM public.ecr.aws/lambda/python:${PYTHON_VERSION}
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
FROM --platform=${BUILDPLATFORM} ghcr.io/astral-sh/uv:0.6.6 AS uv
FROM --platform=${BUILDPLATFORM} public.ecr.aws/lambda/python:${PYTHON_VERSION} AS builder

ENV UV_COMPILE_BYTECODE=1
ENV UV_NO_INSTALLER_METADATA=1
ENV UV_LINK_MODE=copy

# Install required utilities
RUN dnf install -y findutils binutils git && \
dnf clean all && \
rm -rf /var/cache/dnf

WORKDIR /tmp
COPY uv.lock uv.lock
COPY pyproject.toml pyproject.toml
COPY README.md README.md
COPY src/ src/

RUN uv pip install --compile-bytecode .[lambda] --target /asset

# Reduce package size and remove useless files
RUN --mount=from=uv,source=/uv,target=/bin/uv \
--mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv export --frozen --no-emit-workspace --no-dev --no-editable --extra lambda -o requirements.txt && \
uv pip install -r requirements.txt --target /asset
WORKDIR /asset
RUN python -c "from stacrs import DuckdbClient; DuckdbClient(use_s3_credential_chain=True, use_azure_credential_chain=False, install_extensions=True, extension_directory='/asset')"
RUN find . -type f -name '*.pyc' | while read f; do n=$(echo $f | sed 's/__pycache__\///' | sed 's/.cpython-[0-9]*//'); cp $f $n; done;
RUN find . -type d -a -name '__pycache__' -print0 | xargs -0 rm -rf
RUN find . -type f -a -name '*.py' -print0 | xargs -0 rm -f
RUN find . -type d -a -name 'tests' -print0 | xargs -0 rm -rf

# Strip debug symbols from compiled C/C++ code
RUN find . -type f -name '*.so*' -exec strip --strip-unneeded {} \;

FROM --platform=${BUILDPLATFORM} public.ecr.aws/lambda/python:${PYTHON_VERSION}
WORKDIR /asset
COPY --from=builder /asset /asset
COPY infrastructure/aws/lambda/handler.py /asset/handler.py
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ description = "Test the performance of stac-fastapi-geoparquet"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"stac-fastapi-geoparquet @ git+https://github.com/stac-utils/stac-fastapi-geoparquet",
"stac-fastapi-geoparquet",
"stacrs>=0.6.0b0",
]

[project.optional-dependencies]
Expand Down Expand Up @@ -40,6 +41,9 @@ ignore_missing_imports = true
[tool.ruff.lint]
select = ["E", "F", "I"]

[tool.uv.sources]
stac-fastapi-geoparquet = { git = "https://github.com/stac-utils/stac-fastapi-geoparquet", branch = "main" }

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
Loading