Skip to content

Pass env vars to docker #271

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

Merged
merged 6 commits into from
Nov 8, 2018
Merged
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ It is important that the host of your private repositories has already been adde
`$HOME/.ssh/known_hosts` file, as the install process will fail otherwise due to host authenticity
failure.

You can also pass environment variables to docker by specifying them in `dockerEnv`
option:
```yaml
custom:
pythonRequirements:
dockerEnv:
- https_proxy
```

[:checkered_flag: Windows notes](#checkered_flag-windows-dockerizepip-notes)

## Pipenv support :sparkles::cake::sparkles:
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ServerlessPythonRequirements {
dockerSsh: false,
dockerImage: null,
dockerFile: null,
dockerEnv: false,
useStaticCache: false,
useDownloadCache: false,
cacheLocation: false,
Expand Down
7 changes: 7 additions & 0 deletions lib/pip.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ function installRequirements(targetFolder, serverless, options) {
pipCmd.push('--cache-dir', quote_single(dockerDownloadCacheDir));
}

if (options.dockerEnv) {
// Add environment variables to docker run cmd
options.dockerEnv.forEach(function(item) {
cmdOptions.push('-e', item);
});
}

if (process.platform === 'linux') {
// Use same user so requirements folder is not root and so --cache-dir works
var commands = [];
Expand Down