diff --git a/docker-compose.yml b/docker-compose.yml index a126d76c..5c513a03 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -128,6 +128,7 @@ services: - PGPASSWORD=password - PGDATABASE=postgis - DYNAMODB_ENDPOINT=http://localhost:8085 + - VEDA_DB_PGSTAC_VERSION=0.7.10 ports: - "8083:8083" command: bash -c "bash /tmp/scripts/wait-for-it.sh -t 120 -h database -p 5432 && python /asset/local.py" diff --git a/ingest_api/infrastructure/config.py b/ingest_api/infrastructure/config.py index 13651b6b..771d346d 100644 --- a/ingest_api/infrastructure/config.py +++ b/ingest_api/infrastructure/config.py @@ -67,6 +67,10 @@ class IngestorConfig(BaseSettings): ingest_root_path: str = Field("", description="Root path for ingest API") custom_host: Optional[str] = Field(description="Custom host name") + db_pgstac_version: str = Field( + ..., + description="Version of PgStac database, i.e. 0.5", + ) class Config: case_sensitive = False diff --git a/ingest_api/infrastructure/construct.py b/ingest_api/infrastructure/construct.py index 2959aef0..c4322647 100644 --- a/ingest_api/infrastructure/construct.py +++ b/ingest_api/infrastructure/construct.py @@ -66,6 +66,7 @@ def __init__( "db_secret": db_secret, "db_vpc": db_vpc, "db_security_group": db_security_group, + "pgstac_version": config.db_pgstac_version, } if config.raster_data_access_role_arn: @@ -124,6 +125,7 @@ def build_api_lambda( db_vpc: ec2.IVpc, db_security_group: ec2.ISecurityGroup, data_access_role: Union[iam.IRole, None] = None, + pgstac_version: str, code_dir: str = "./", ) -> apigateway.LambdaRestApi: stack_name = Stack.of(self).stack_name @@ -150,6 +152,7 @@ def build_api_lambda( path=os.path.abspath(code_dir), file="ingest_api/runtime/Dockerfile", platform="linux/amd64", + build_args={"PGSTAC_VERSION": pgstac_version}, ), runtime=aws_lambda.Runtime.PYTHON_3_9, timeout=Duration.seconds(30), @@ -291,6 +294,7 @@ def __init__( db_vpc=db_vpc, db_security_group=db_security_group, db_vpc_subnets=db_vpc_subnets, + pgstac_version=config.db_pgstac_version, ) def build_ingestor( @@ -302,6 +306,7 @@ def build_ingestor( db_vpc: ec2.IVpc, db_security_group: ec2.ISecurityGroup, db_vpc_subnets: ec2.SubnetSelection, + pgstac_version: str, code_dir: str = "./", ) -> aws_lambda.Function: handler = aws_lambda.Function( @@ -311,6 +316,7 @@ def build_ingestor( path=os.path.abspath(code_dir), file="ingest_api/runtime/Dockerfile", platform="linux/amd64", + build_args={"PGSTAC_VERSION": pgstac_version}, ), handler="ingestor.handler", runtime=aws_lambda.Runtime.PYTHON_3_9, diff --git a/ingest_api/runtime/Dockerfile b/ingest_api/runtime/Dockerfile index 201c48ce..01bc2f6a 100644 --- a/ingest_api/runtime/Dockerfile +++ b/ingest_api/runtime/Dockerfile @@ -1,5 +1,8 @@ FROM public.ecr.aws/sam/build-python3.9:latest +ARG PGSTAC_VERSION +RUN echo "Using PGSTAC Version ${PGSTAC_VERSION}" + WORKDIR /tmp COPY common/auth /tmp/common/auth @@ -7,7 +10,7 @@ RUN pip install /tmp/common/auth -t /asset RUN rm -rf /tmp/common COPY ingest_api/runtime/requirements.txt /tmp/ingestor/requirements.txt -RUN pip install -r /tmp/ingestor/requirements.txt -t /asset --no-binary pydantic uvicorn +RUN pip install -r /tmp/ingestor/requirements.txt pypgstac==${PGSTAC_VERSION} -t /asset --no-binary pydantic uvicorn RUN rm -rf /tmp/ingestor # TODO this is temporary until we use a real packaging system like setup.py or poetry COPY ingest_api/runtime/src /asset/src diff --git a/ingest_api/runtime/requirements.txt b/ingest_api/runtime/requirements.txt index fcb66519..c773522e 100644 --- a/ingest_api/runtime/requirements.txt +++ b/ingest_api/runtime/requirements.txt @@ -8,7 +8,6 @@ orjson>=3.6.8 psycopg[binary,pool]>=3.0.15 pydantic_ssm_settings>=0.2.0 pydantic>=1.10.12 -pypgstac==0.7.4 python-multipart==0.0.7 requests>=2.27.1 s3fs==2023.3.0