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

Support recursively adding files to serverless package #544

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,17 @@ zipinfo .serverless/xxx.zip

If you can't see the library, you might need to adjust your package include/exclude configuration in `serverless.yml`.

If you would like to recursively include a directory and all of its contents,
prepend `-r ` to the file list member:

```yaml
custom:
pythonRequirements:
dockerExtraFiles:
- -r /path/to/additional/dependencies/
```


## Optimising packaging time

If you wish to exclude most of the files in your project, and only include the source files of your lambdas and their dependencies you may well use an approach like this:
Expand Down
8 changes: 7 additions & 1 deletion lib/pip.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,13 @@ function installRequirements(targetFolder, serverless, options) {
}

for (let path of options.dockerExtraFiles) {
pipCmds.push(['cp', path, '/var/task/']);
let cmd = ['cp', path, '/var/task/'];
// Copy recursively if -r option was specified
if (path.startsWith('-r ')) {
path = path.split(' ')[1];
cmd = ['cp', '-r', path, '/var/task/']
}
pipCmds.push(cmd);
}

if (process.platform === 'linux') {
Expand Down