Skip to content
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

Docker options for running Docker Lambda within a Docker container #1164

Merged
merged 26 commits into from Feb 9, 2021
Merged

Docker options for running Docker Lambda within a Docker container #1164

merged 26 commits into from Feb 9, 2021

Conversation

apancutt
Copy link
Contributor

Description

Extends PR #961 with additional changes:

  • Merge conflicts resolved
  • Restored pull of latest Docker Lambda image upon start
  • Added dockerNetwork option
  • Enabled DOCKER_LAMBDA_WATCH to restart Docker Lambda on filesystem changes
  • Documented new options in README.md
  • Removed trailing whitespace in README.md
  • Sorted command options in README.md
  • Sorted properties in defaultOptions.js
  • Fixed code style violation in DockerContainer.js as required by prettier

Motivation and Context

Cold starts with vanilla serverless-offline are extremely slow (we were getting average response times of ~700ms with a Koa API). The useDocker option addresses this by keeping a container warm but this has several issues...

  1. it doesn't work when running serverless-offline within a Docker container; typical of complex development stacks using Docker Compose (fixed by --dockerHost and --dockerHostServicePath options)
  2. it doesn't hot-reload when files change (fixed by adding DOCKER_LAMBDA_WATCH=1 to Docker container env)
  3. the container cannot communicate with other containers hosted on the parent Docker Compose stack (fixed by --dockerNetwork option).

How Has This Been Tested?

Tested within a development environment provisioned using Docker Compose running several service containers, one of which is serverless-offline. The API running in this container is now fully operational with the --useDocker option enabled and hot-reloads on file changes. Response times reduced from ~700ms to ~60ms.

@frozenbonito
Copy link
Collaborator

Thank you for your great work @apancutt.
Sorry, There are still some issues about artifact and layer support.
Let me fix them and add test.

@frozenbonito
Copy link
Collaborator

@apancutt
Copy link
Contributor Author

apancutt commented Feb 9, 2021

That's already enabled. Not working?

@frozenbonito
Copy link
Collaborator

For some reason, I couldn't push to your repository directly.
Could you merge the following branch to this PR?
https://github.com/frozenbonito/serverless-offline/tree/pull/1164

@frozenbonito
Copy link
Collaborator

Thank you!

@frozenbonito frozenbonito merged commit 91592d3 into dherault:master Feb 9, 2021
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.

None yet

2 participants