-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Docker Container Image Support #2188
Comments
Initial Exploration
I was able to get a little POC doing this ☝️ : This is the import time
from flask import Flask, jsonify
app = Flask(__name__)
@app.route("/")
def serve():
return jsonify(success=True)
@app.route("/time")
def get_current_time():
return {"time": round(time.time())} Steps
FROM amazon/aws-lambda-python:3.8
COPY ./ /var/task/
# Install dependencies with poetry
RUN pip install poetry
RUN POETRY_VIRTUALENVS_CREATE=false poetry install --no-root
CMD [ "handler.lambda_handler" ] The only hack here is you need to have the handler.py (from zappa library) and zappa_settings.py files baked into your docker image. The To get around this, I'm thinking the following may be a simple solution:
|
This project looks a little dead. As the workflow is pretty different with docker, maybe worth forking the relevant bits perhaps? |
Scratch that.. for the use-case I'm describing https://github.com/adamchainz/apig-wsgi seems to suffice. (I'm thinking more conventional docker build + terraform kinda setup) |
* Make the zappa update and zappa deploy commands accept a new docker_image_uri parameter * Refactor handler.py so it first looks for zappa_settings.py file (current behaviour), and if that is not there, it looks for all the settings as environment variables (new behaviour) Related Miserlou#2188
* Make the zappa update and zappa deploy commands accept a new docker_image_uri parameter * Refactor handler.py so it first looks for zappa_settings.py file (current behaviour), and if that is not there, it looks for all the settings as environment variables (new behaviour) Related Miserlou#2188
* Make the zappa update and zappa deploy commands accept a new docker_image_uri parameter * Refactor handler.py so it first looks for zappa_settings.py file (current behaviour), and if that is not there, it looks for all the settings as environment variables (new behaviour) Related Miserlou#2188
Bump boto3/botocore versions Bump boto3/botocore versions Related Miserlou#2188
Bump boto3/botocore versions Bump boto3/botocore versions Related Miserlou#2188
* Make the zappa deploy command accept a new docker_image_uri parameter * Add a new CLI command to generate & save the zappa_settings.py file used by handler.py Related Miserlou#2188
* Raise a NotImplementedError for zappa rollback. Related Miserlou#2188
works like a charm: https://github.com/adamchainz/apig-wsgi |
Keep in mind that Lambdas which are created from ECR have very long cold starts: for my project it's 4.5 seconds compared with 1.2 seconds before |
@ian-whitestone using the |
Let's move the conversation over to zappa/Zappa#922 (the new repo). I will reply there @alexanderdamiani @ArtikUA ! |
Earlier this month, AWS announced container image support for AWS Lambda. This means you can now package and deploy lambda functions as container images, instead of using zip files. The container image based approach will solve a lot of headaches caused by the zip file approach, particularly with file sizes (container images can be up to 10GB) and the dependency issues we all know & love.
In an ideal end state, you should be able to call
zappa deploy
/zappa update
/zappa package
(etc.) and specify whether you want to use the traditional zip-based approach or new Docker container based approach. If choosing the latter, Zappa would automatically:For a MVP, we should take a BYOI (bring your own image) approach and just get
zappa deploy
andzappa update
to deploy a lambda function using an existing Docker Image that complies with these guidelines.The text was updated successfully, but these errors were encountered: