Skip to content

Commit eabbd89

Browse files
authored
Pass env vars to docker (#271)
* Add environment variables to docker run cmd * Pass env vars to docker Based on #231 & closes #267 * format * fix docs * Update README.md
1 parent e592188 commit eabbd89

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ It is important that the host of your private repositories has already been adde
7272
`$HOME/.ssh/known_hosts` file, as the install process will fail otherwise due to host authenticity
7373
failure.
7474

75+
You can also pass environment variables to docker by specifying them in `dockerEnv`
76+
option:
77+
```yaml
78+
custom:
79+
pythonRequirements:
80+
dockerEnv:
81+
- https_proxy
82+
```
83+
7584
[:checkered_flag: Windows notes](#checkered_flag-windows-dockerizepip-notes)
7685

7786
## Pipenv support :sparkles::cake::sparkles:

index.js

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class ServerlessPythonRequirements {
4242
dockerSsh: false,
4343
dockerImage: null,
4444
dockerFile: null,
45+
dockerEnv: false,
4546
useStaticCache: false,
4647
useDownloadCache: false,
4748
cacheLocation: false,

lib/pip.js

+7
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@ function installRequirements(targetFolder, serverless, options) {
196196
pipCmd.push('--cache-dir', quote_single(dockerDownloadCacheDir));
197197
}
198198

199+
if (options.dockerEnv) {
200+
// Add environment variables to docker run cmd
201+
options.dockerEnv.forEach(function(item) {
202+
cmdOptions.push('-e', item);
203+
});
204+
}
205+
199206
if (process.platform === 'linux') {
200207
// Use same user so requirements folder is not root and so --cache-dir works
201208
var commands = [];

0 commit comments

Comments
 (0)