I'm using Docker as a container to a repo with the following structure:
engine
--models_api
----alpha_model_api
--------model_api.py
----api_utils
--------utils.py
--models_logic
----models_utils
--------utils.py
----model_ids.json
--Dockerfile
model_api.api is the lambda handler. It uses the models_api.api_utils.utils module to get some data.
The models_api.api_utils.utils uses models_logic.models_utils.utils to provide that data, which is been deserialized from models_logic.model_ids.json .
The problem is I don't know how an object living inside the api_utils scope can know how to get from the working directory (${LAMBDA_TASK_ROOT}/models_api/alpha_model_api/model_api) to the model_ids.json without assuming its running in a specific directory.
The ideal situation for me is to find a way to call the aws lambda handler (model_api.api) with the working directory being ${LAMBDA_TASK_ROOT}
Here's the dockerfile:
FROM public.ecr.aws/lambda/python:3.8
COPY . ${LAMBDA_TASK_ROOT}
ENV PYTHONPATH="$PYTHONPATH:${LAMBDA_TASK_ROOT}"
RUN pip install -r ./models_api/alpha_api/requirements.txt --target ./models_api/alpha_api
WORKDIR ${LAMBDA_TASK_ROOT}/models_api/alpha_api
CMD ["model_api.api"]
I want to be able to call the lambda handler without setting the WORKDIR variable.
Is it even possible?