Skip to content

Build AWS Lambda layers for canvas 2.8.0 - #15

Merged
jwerre merged 2 commits into
jwerre:developmentfrom
maxpeterson:canvas-2.8.0
Oct 30, 2021
Merged

jwerre merged 2 commits into
jwerre:developmentfrom
maxpeterson:canvas-2.8.0

Conversation

@maxpeterson

Copy link
Copy Markdown
Contributor

For #14

Update the Dockerfile to build the latest canvas version (2.8.0).

To get the canvas layers to work on lambda I updated the Dockerfile to use the lambci/lambda:build-nodejsXYZ.x image and run npm install with the --build-from-source flag.

Other changes included:

  • Using lddtree.sh to find the so library dependencies (inspired by node-canvas/prebuild/Linux/bundle.sh#L1)
  • Using docker cp to copy the layer zip files out of the docker image.
  • Using docker-compose.yml and a Makefile to help setup, test and debug running canvas locally using the lambda image, as well as to simplify the build process.

@jwerre some of changes here were the result of my testing / development process (such as using make and docker-compose). Let me know if you would like me to strip them out or make any other changes.

@jwerre

jwerre commented Oct 29, 2021

Copy link
Copy Markdown
Owner

Thanks @maxpeterson I'll check this out today.

@jwerre

jwerre commented Oct 29, 2021

Copy link
Copy Markdown
Owner

Thanks again for contributing @maxpeterson. It really looks like you've done some work here. To summarize what you've done I see that you've added/modified the following files.

  • Makefile
  • Dockerfile.yaml
  • docker-compose.yml
  • build.sh
  • test/build.Dockerfile
  • test/Dockerfile

I think we can clean this up a bit but I have a few questions first.

What is the purpose of docker-compose lambda-build and docker-compose lambda-test? I don't feel like they're adding much value and I wonder if it would be best to just remove them. Since that's the case, you could just remove the test directory as well as the docker-compose.yml since you can just use docker build/run in the Makefile. I think we can clean the Makefile up a bit too. Finally remove build.sh since this is already functionality handled by the Makefile

Thanks again for doing all this. Looking forward to your reply.

@maxpeterson

Copy link
Copy Markdown
Contributor Author

No problem @jwerre

I used lambda-test to test that the layers work using docker (rather than uploading them to AWS). It is used by make lambda-tests which runs the lambda function handler.handler from the test folder using the lambda layers to verify they work.

lambda-build provides a version of the lambda image / environment that you can run bash in to debug any issues (e.g. using ldd to see which so files are missing).

I added the lambda-test/build stuff during the process of figuring out how to build the layers, so it may or may not be useful in the future. If your preference is to keep the repo as simple as possible then happy to remove it.

As you said the docker-compose.yml and build.sh are superfluous so could be removed if you prefer (I did already consider this).

In summary, I can remove the docker-compose.yml and build.sh if you like. Similarly I can remove the lambda-test/build stuff if you prefer.

@jwerre

jwerre commented Oct 29, 2021

Copy link
Copy Markdown
Owner

@maxpeterson Sounds good. On last thing is I don't want to merge this directly into master since I think it needs to be a new version. I created a new branch development, can you create a new pull request for that branch? Once that's done I'll merge it into master.

@maxpeterson

Copy link
Copy Markdown
Contributor Author

Just to confirm, do you wan't me to remove the docker-compose.yml, build.sh and the test stuff?

@jwerre

jwerre commented Oct 29, 2021 •

Copy link
Copy Markdown
Owner

Just to confirm, do you wan't me to remove the docker-compose.yml, build.sh and the test stuff?

Yes, please

@jwerre

jwerre commented Oct 29, 2021

Copy link
Copy Markdown
Owner

On second thought why don't you just leave it there and document it in the readme so everyone is clear about what it does.

@maxpeterson
maxpeterson changed the base branch from master to development October 30, 2021 11:16
@maxpeterson

Copy link
Copy Markdown
Contributor Author

@jwerre I have updated this PR. Let me know what you think.

One further thing that occurred to me is that the two zip files now seem to be much smaller than before, so they could be combined into into a single zip file that would be around 8.5M

@jwerre

jwerre commented Sep 1, 2022

Copy link
Copy Markdown
Owner

@maxpeterson, I finally got around to merging this. Sorry for letting your work slip through the cracks. It should be up and running now so let me know if you comments or improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants