Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ lib/**/*.d.ts
dist
docs
__pycache__
.venv
/.venv
.tox
tests/*.egg*
tests/*venv*
Expand Down
10 changes: 5 additions & 5 deletions integration_tests/cdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions lib/stac-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class PgStacApiLambdaRuntime extends Construct {
constructor(
scope: Construct,
id: string,
props: PgStacApiLambdaRuntimeProps
props: PgStacApiLambdaRuntimeProps,
) {
super(scope, id);

Expand All @@ -60,8 +60,8 @@ export class PgStacApiLambdaRuntime extends Construct {
if (!isValidExtension(ext)) {
throw new Error(
`Invalid extension: "${ext}". Must be one of: ${Object.values(
EXTENSIONS
).join(", ")}`
EXTENSIONS,
).join(", ")}`,
);
}
}
Expand All @@ -75,7 +75,7 @@ export class PgStacApiLambdaRuntime extends Construct {
this.lambdaFunction = new lambda.Function(this, "lambda", {
// defaults
runtime: lambda.Runtime.PYTHON_3_12,
handler: "handler.handler",
handler: "stac_api.handler.handler",
memorySize: 8192,
logRetention: aws_logs.RetentionDays.ONE_WEEK,
timeout: Duration.seconds(30),
Expand Down Expand Up @@ -106,7 +106,7 @@ export class PgStacApiLambdaRuntime extends Construct {
this.lambdaFunction.connections.allowTo(
props.db,
ec2.Port.tcp(5432),
"allow connections from stac-fastapi-pgstac"
"allow connections from stac-fastapi-pgstac",
);
}
}
Expand Down
31 changes: 25 additions & 6 deletions lib/stac-api/runtime/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
ARG PYTHON_VERSION
FROM --platform=linux/amd64 public.ecr.aws/lambda/python:${PYTHON_VERSION}
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

WORKDIR /tmp
RUN python -m pip install pip -U
COPY stac-api/runtime/uv.lock stac-api/runtime/pyproject.toml ./
COPY stac-api/runtime/src/ ./src/
COPY utils/utils.py /asset/

COPY stac-api/runtime/requirements.txt requirements.txt
RUN python -m pip install -r requirements.txt -t /asset --no-binary pydantic
RUN <<EOF
uv export --locked --no-editable --no-dev --format requirements.txt -o requirements.txt
uv pip install \
--compile-bytecode \
--no-binary pydantic \
--target /asset \
--no-cache-dir \
--disable-pip-version-check \
-r requirements.txt
EOF

RUN mkdir -p /asset/src
COPY stac-api/runtime/src/*.py /asset/
COPY utils/utils.py /asset/
# Reduce package size and remove useless files
WORKDIR /asset
RUN <<EOF
dnf install -y findutils && \
dnf clean all && \
rm -rf /var/cache/dnf
find . -type f -name '*.pyc' | while read f; do n=$(echo $f | sed 's/__pycache__\///' | sed 's/.cpython-[0-9]*//'); cp $f $n; done;
find . -type d -a -name '__pycache__' -print0 | xargs -0 rm -rf
find . -type f -a -name '*.py' -print0 | xargs -0 rm -f
find . -type d -a -name 'tests' -print0 | xargs -0 rm -rf
EOF

CMD ["echo", "hello world"]
14 changes: 14 additions & 0 deletions lib/stac-api/runtime/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[project]
name = "stac-api"
version = "0.0.0"
description = "stac-api runtime"
authors = [{ name = "hrodmn", email = "[email protected]" }]
requires-python = ">=3.12"
dependencies = [
"stac-fastapi-pgstac[awslambda]>=6.0,<6.1",
"starlette-cramjam>=0.4,<0.5",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
2 changes: 0 additions & 2 deletions lib/stac-api/runtime/requirements.txt

This file was deleted.

855 changes: 855 additions & 0 deletions lib/stac-api/runtime/uv.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/stac-auth-proxy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class StacAuthProxyLambdaRuntime extends Construct {
constructor(
scope: Construct,
id: string,
props: StacAuthProxyLambdaRuntimeProps
props: StacAuthProxyLambdaRuntimeProps,
) {
super(scope, id);

Expand All @@ -22,7 +22,7 @@ export class StacAuthProxyLambdaRuntime extends Construct {

this.lambdaFunction = new lambda.Function(this, "lambda", {
runtime: lambda.Runtime.PYTHON_3_13,
handler: "handler.handler",
handler: "stac_auth_proxy_api.handler.handler",
memorySize: 8192,
logRetention: cdk.aws_logs.RetentionDays.ONE_WEEK,
timeout: cdk.Duration.seconds(30),
Expand Down Expand Up @@ -114,7 +114,7 @@ export class StacAuthProxyLambda extends Construct {
const runtime = new StacAuthProxyLambdaRuntime(
this,
"runtime",
runtimeProps
runtimeProps,
);
this.lambdaFunction = runtime.lambdaFunction;

Expand Down
19 changes: 13 additions & 6 deletions lib/stac-auth-proxy/runtime/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
ARG PYTHON_VERSION
FROM --platform=linux/amd64 public.ecr.aws/lambda/python:${PYTHON_VERSION}
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

WORKDIR /tmp
RUN python -m pip install pip -U
COPY stac-auth-proxy/runtime/uv.lock stac-auth-proxy/runtime/pyproject.toml ./
COPY stac-auth-proxy/runtime/src/ ./src/

COPY stac-auth-proxy/runtime/requirements.txt requirements.txt
RUN python -m pip install -r requirements.txt "mangum>=0.14,<0.15" -t /asset

RUN mkdir -p /asset/src
COPY stac-auth-proxy/runtime/src/*.py /asset/
RUN <<EOF
uv export --locked --no-editable --no-dev --format requirements.txt -o requirements.txt
uv pip install \
--compile-bytecode \
--no-binary pydantic \
--target /asset \
--no-cache-dir \
--disable-pip-version-check \
-r requirements.txt
EOF
13 changes: 13 additions & 0 deletions lib/stac-auth-proxy/runtime/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[project]
name = "stac-auth-proxy-api"
version = "0.0.0"
description = "stac-auth-proxy-api runtime"
requires-python = ">=3.12"
dependencies = [
"mangum>=0.19.0",
"stac-auth-proxy>=0.6,<1",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
Loading
Loading