Skip to content

Commit

Permalink
chore: Make pypgstac an ENV in dockerfile (#404)
Browse files Browse the repository at this point in the history
### Issue

#372

### What?

Make pypgstac and ENV var in dockerfile

### Why?

- Description of why the changes were made

### Testing?

Deployed without any errors to http://monitor.openveda.cloud/
  • Loading branch information
sandrahoang686 authored Aug 14, 2024
2 parents 69e8227 + e6f10d6 commit 96a336f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions ingest_api/infrastructure/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions ingest_api/infrastructure/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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),
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion ingest_api/runtime/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
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
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
Expand Down
1 change: 0 additions & 1 deletion ingest_api/runtime/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 96a336f

Please sign in to comment.