Skip to content

Commit

Permalink
feat: clean up Dockerfiles and improve their documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jfaldanam committed Jun 18, 2024
1 parent 71bd78e commit 758d6bd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ENV EIDOS_ENV production

ENV EIDOS_FUNCTIONS_FOLDER /functions

RUN pip install "."
RUN pip install --no-cache-dir "."

EXPOSE 80

Expand Down
24 changes: 12 additions & 12 deletions Dockerfile.lambda
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
FROM amazon/aws-lambda-python:3.11
FROM amazon/aws-lambda-python:3.10

# When sending request from the UI it crashes as described in this issue, this is a patch for it
# https://github.com/aws/aws-lambda-runtime-interface-emulator/issues/97#issuecomment-1707171018
RUN curl -Lo /usr/local/bin/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/download/v1.10/aws-lambda-rie \
&& chmod +x /usr/local/bin/aws-lambda-rie

# Install main dependency
COPY pyproject.toml /tmp/eidos/pyproject.toml
COPY README.md /tmp/eidos/README.md
COPY src /tmp/eidos/src
RUN pip install --no-cache-dir "/tmp/eidos"

# Copy default functions and provide ENV to override it functions
COPY ./functions /var/task/functions
ENV EIDOS_FUNCTIONS_FOLDER=/var/task/functions
COPY README.md /code/README.md
COPY src /code/src
COPY pyproject.toml /code/pyproject.toml
COPY ./functions /functions

# Copy lambda's code
#COPY serverless/eidos/src/ /var/task
ENV EIDOS_ENV production

ENV EIDOS_FUNCTIONS_FOLDER=/functions

RUN pip install --no-cache-dir "/code"

EXPOSE 8080

# Setup lambda's handler
CMD [ "eidos.lambda.lambda_handler" ]
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Alternatively, you can use the provided [Dockerfile](Dockerfile) to build a Dock

```bash
docker build -t eidos-server:latest .
docker run -v $(pwd)/functions:/functions -p 8090:80 eidos-server:latest
docker run --rm -v $(pwd)/functions:/functions -p 8090:80 eidos-server:latest
```

Example:
Expand All @@ -49,26 +49,25 @@ curl -X POST -H "Content-Type: application/json" -d '{"who": "me"}' http://local

* Kubernetes

To deploy the container in Kubernetes, a reference deployment is available and documented at [deployments](deployments/).
To deploy the container in Kubernetes, a reference deployment is available and documented at [manifests](manifests/).

* Serverless in AWS

# Semantic search of database of documents

Another docker image to deploy serverless in AWS Lambda is provided in [Dockerfile.lambda](Dockerfile.lambda). The image is based on the official AWS Lambda Python 3.11 image. For extending this image the process is the same as the main image.

```console
$ docker build -t eidos-lambda -f Dockerfile.lambda .
```bash
docker build -t eidos-lambda -f Dockerfile.lambda .
```

Run the container locally with the following command or deploy in AWS Lambda as a docker container image:

```bash
docker run --rm -p 9001:8080 eidos-lambda
docker run --rm -p 8091:8080 eidos-lambda
```

Invoke the function for local testing with sample query

```bash
curl -XPOST "http://localhost:9001/2015-03-31/functions/function/invocations" -d '{"command": "EXECUTE", "parameters": {"function": "salute", "args": {"who": "me, I am executing serverless"}}}'
curl -XPOST "http://localhost:8091/2015-03-31/functions/function/invocations" -d '{"command": "EXECUTE", "parameters": {"function": "salute", "args": {"who": "me, I am executing serverless"}}}'
```

## Testing
Expand Down
1 change: 1 addition & 0 deletions src/eidos/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def execute(function_name: str, arguments: dict | None) -> dict[str, Any]:
try:
function_definition = json_load(file_path)
except FileNotFoundError:
log.error("Error: function module not found.", function=function_name, file_path=file_path)
raise FileNotFoundError("Error: function module not found.")

# Validate input arguments against the function's schema.
Expand Down

0 comments on commit 758d6bd

Please sign in to comment.