mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
dockerfile, requirements, and local handler
This commit is contained in:
parent
09ee2699b6
commit
9471854dfb
6 changed files with 81 additions and 1 deletions
26
backend/ecmk_fetcher/handler/Dockerfile
Normal file
26
backend/ecmk_fetcher/handler/Dockerfile
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
FROM mcr.microsoft.com/playwright/python:v1.58.0-jammy
|
||||
|
||||
# Install AWS Lambda RIE
|
||||
ADD https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie /usr/local/bin/aws-lambda-rie
|
||||
RUN chmod +x /usr/local/bin/aws-lambda-rie
|
||||
|
||||
# Set working directory (Lambda task root)
|
||||
WORKDIR /var/task
|
||||
|
||||
COPY backend/ecmk_fetcher/handler/requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY utils/ utils/
|
||||
COPY backend/ backend/
|
||||
COPY datatypes/ datatypes/
|
||||
|
||||
# Local lambda entrypoint
|
||||
ENTRYPOINT ["/usr/local/bin/aws-lambda-rie", "python", "-m", "awslambdaric"]
|
||||
|
||||
#AWS lambda entrypoint
|
||||
# ENTRYPOINT ["python", "-m", "awslambdaric"]
|
||||
|
||||
# -----------------------------
|
||||
# Lambda handler
|
||||
# -----------------------------
|
||||
CMD ["backend.ecmk_fetcher.handler.handler.handler"]
|
||||
|
|
@ -1,9 +1,13 @@
|
|||
from typing import Any, Mapping
|
||||
|
||||
from backend.ecmk_fetcher.processor import run_job
|
||||
from utils.logger import setup_logger
|
||||
|
||||
logger = setup_logger()
|
||||
|
||||
|
||||
def handler(event: Mapping[str, Any], context: Any) -> None:
|
||||
logger.info("Entered handler")
|
||||
run_job()
|
||||
|
||||
|
||||
|
|
|
|||
12
backend/ecmk_fetcher/handler/requirements.txt
Normal file
12
backend/ecmk_fetcher/handler/requirements.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
awslambdaric
|
||||
playwright==1.58.0
|
||||
msal
|
||||
openpyxl
|
||||
sqlalchemy==2.0.36
|
||||
sqlmodel
|
||||
pytz==2024.2
|
||||
psycopg2-binary==2.9.10
|
||||
pydantic-settings==2.6.0
|
||||
boto3==1.35.44
|
||||
pandas==2.2.2
|
||||
numpy<2.0
|
||||
11
backend/ecmk_fetcher/local_handler/docker-compose.yml
Normal file
11
backend/ecmk_fetcher/local_handler/docker-compose.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
version: "3.9"
|
||||
|
||||
services:
|
||||
ecmk-fetcher-lambda:
|
||||
build:
|
||||
context: ../../../
|
||||
dockerfile: backend/ecmk_fetcher/handler/Dockerfile
|
||||
ports:
|
||||
- "9000:8080"
|
||||
env_file:
|
||||
- ../../../.env
|
||||
26
backend/ecmk_fetcher/local_handler/invoke_local_lambda.py
Normal file
26
backend/ecmk_fetcher/local_handler/invoke_local_lambda.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env python3
|
||||
import json
|
||||
import requests
|
||||
|
||||
HOST = "localhost"
|
||||
PORT = "9000"
|
||||
|
||||
LAMBDA_URL = f"http://{HOST}:{PORT}/2015-03-31/functions/function/invocations"
|
||||
|
||||
payload = {
|
||||
"Records": [
|
||||
{
|
||||
"body": json.dumps(
|
||||
{
|
||||
"test": 123456,
|
||||
}
|
||||
)
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
response = requests.post(LAMBDA_URL, json=payload)
|
||||
|
||||
print("Status code:", response.status_code)
|
||||
print("Response:")
|
||||
print(response.text)
|
||||
|
|
@ -41,7 +41,8 @@ logger = setup_logger()
|
|||
|
||||
|
||||
def run_job() -> None:
|
||||
username: str = ""
|
||||
|
||||
username: str = "" # TODO: get from github secrets
|
||||
password: str = ""
|
||||
|
||||
property_list_file: str = (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue