Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

AWS Lambda operator does not honor Docker template #48

Open
giacomov opened this issue Nov 15, 2022 · 3 comments
Open

AWS Lambda operator does not honor Docker template #48

giacomov opened this issue Nov 15, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@giacomov
Copy link

Describe the bug
Building bentos with the AWS Lambda operator with custom Dockerfile templates does not work. It seems that the AWS lambda operator uses its own Dockerfile template without regards on whether the model to build has its own Dockerfile template.

To Reproduce
Steps to reproduce the issue:

  1. Create a bentoml with a custom Dockerfile template, for example:
{% extends bento_base_template %}
{% block SETUP_BENTO_BASE_IMAGE %}
{{ super() }}
ARG GITHUB_TOKEN

{% endblock %}
{% block SETUP_BENTO_COMPONENTS %}
{{ super() }}
{% endblock %}
  1. Try to build the model with
bentoctl build -b [model name] -f deployment_config.yaml --build-arg GITHUB_TOKEN=testing --verbose
  1. Look for the Dockerfile produced by the command (under /tmp/* as printed by the command). It won't contain the added instructions (in this case, the GITHUB_TOKEN arg)

This happens because of this line for the AWS lambda operator:

~bentoctl/operators/aws-lambda/bentoctl_lambda/create_deployable.py(61)create_deployable()
-> options["dockerfile_template"] = TEMPLATE_PATH

where TEMPLATE_PATH points to a template within the operator itself (in my case, PosixPath('~/bentoctl/operators/aws-lambda/bentoctl_lambda/aws_lambda/template.j2')

Expected behavior

The model is built honoring the custom Dockerfile template included in the bento (or the dockerfile included in the bento under env/docker/Dockerfile).

Environment:

  • OS: Ubuntu 20.04
  • Python Version 3.8.12
  • BentoML Version 1.0.10
  • Bentoctl Version 0.3.4 (same problem also installing the HEAD of the repo)
@giacomov giacomov added the bug Something isn't working label Nov 15, 2022
@jjmachan
Copy link
Contributor

Yes, this is a limitation with the lambda operator since we are using the custom template for modifying the bento to make it ready for deployment to AWS Lambda. I would love to figure out a workaround for you, what would be the best way to setup some time for that?

@giacomov
Copy link
Author

I found a workaround already :-) I modified the template within the operator itself. Not very sustainable, but works for now.

I think a rather simple fix for this would be to merge the two templates (the one from the operator and the one from the bento) before generating the Dockerfile.

@jjmachan
Copy link
Contributor

Glad to hear that you fixed it!
Yes, what you suggested should work in most cases—moving this issue to the lambda repo so we can take it up

@jjmachan jjmachan transferred this issue from bentoml/bentoctl Nov 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants