Skip to content

Commit a1e830a

Browse files
committed
Upgrade pip in docker
1 parent a6b9009 commit a1e830a

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

index.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,25 @@ class ServerlessPythonRequirements {
2727
this.serverless.cli.log('Installing required Python packages...');
2828

2929
return new BbPromise((resolve, reject) => {
30-
let cmd = 'pip';
31-
let options = [
32-
'--isolated', 'install',
33-
'-t', '.requirements',
34-
'-r', 'requirements.txt',
30+
let cmd, options;
31+
const pipCmd = [
32+
'pip', '--isolated', 'install',
33+
'-t', '.requirements', '-r', 'requirements.txt',
34+
];
35+
const dockerCmd = [
36+
'docker', 'run', '--rm',
37+
'-v', `${this.serverless.config.servicePath}:/var/task:z`,
38+
'lambci/lambda:build-python2.7',
39+
'bash', '-c',
3540
];
3641
if (this.custom.dockerizePip) {
37-
cmd = 'docker';
38-
options = [
39-
'run', '--rm',
40-
'-v', `${this.serverless.config.servicePath}:/var/task:z`,
41-
'lambci/lambda:build-python2.7', 'pip',
42-
].concat(options);
42+
cmd = dockerCmd[0];
43+
options = dockerCmd.slice(1);
44+
pipCmd.unshift('pip install --upgrade pip &&')
45+
options.push(pipCmd.join(' '))
46+
} else {
47+
cmd = pipCmd[0];
48+
options = pipCmd.slice(1);
4349
}
4450
const res = child_process.spawnSync(cmd, options);
4551
if (res.error) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-python-requirements",
3-
"version": "2.0.0-beta",
3+
"version": "2.0.0-beta.2",
44
"engines": {
55
"node": ">=4.0"
66
},

0 commit comments

Comments
 (0)