@@ -14,7 +14,6 @@ BbPromise.promisifyAll(Fse);
1414class PkgPyFuncs {
1515
1616 fetchConfig ( ) {
17-
1817 if ( ! this . serverless . service . custom ) {
1918 this . error ( "No serverless custom configurations are defined" )
2019 }
@@ -36,6 +35,14 @@ class PkgPyFuncs {
3635 this . dockerServicePath = '/var/task'
3736 }
3837
38+ autoconfigArtifacts ( ) {
39+ _ . map ( this . serverless . service . functions , ( func_config , func_name ) => {
40+ let autoArtifact = `${ this . buildDir } /${ func_name } .zip`
41+ func_config . package . artifact = func_config . package . artifact || autoArtifact
42+ this . serverless . service . functions [ func_name ] = func_config
43+ } )
44+ }
45+
3946 clean ( ) {
4047 if ( ! this . cleanup ) {
4148 this . log ( 'Cleanup is set to "false". Build directory and Docker container (if used) will be retained' )
@@ -58,15 +65,17 @@ class PkgPyFuncs {
5865 } ) ;
5966
6067 const info = _ . map ( functions , ( target ) => {
68+
69+
6170 return {
6271 name : target . name ,
63- includes : target . package . include
72+ includes : target . package . include ,
73+ artifact : target . package . artifact
6474 }
6575 } )
6676 return info
6777 }
6878
69-
7079 installRequirements ( buildPath , requirementsPath ) {
7180
7281 if ( ! Fse . pathExistsSync ( requirementsPath ) ) {
@@ -118,11 +127,11 @@ class PkgPyFuncs {
118127 this . log ( 'Container already exists. Reusing.' )
119128 } else {
120129 let args = [ 'run' , '--rm' , '-dt' , '-v' , `${ process . cwd ( ) } :${ this . dockerServicePath } ` ]
121-
130+
122131 if ( this . mountSSH ) {
123132 args = args . concat ( [ '-v' , `${ process . env . HOME } /.ssh:/root/.ssh` ] )
124133 }
125-
134+
126135 args = args . concat ( [ '--name' , this . containerName , this . dockerImage , 'bash' ] )
127136 this . runProcess ( 'docker' , args )
128137 this . log ( 'Container created' )
@@ -171,14 +180,20 @@ class PkgPyFuncs {
171180 zipper . sync . zip ( buildPath ) . compress ( ) . save ( `${ buildPath } .zip` )
172181 }
173182
183+
184+
174185 constructor ( serverless , options ) {
175186 this . serverless = serverless ;
176187 this . options = options ;
177188 this . log = ( msg ) => { this . serverless . cli . log ( `[serverless-package-python-functions] ${ msg } ` ) }
178189 this . error = ( msg ) => { throw new Error ( `[serverless-package-python-functions] ${ msg } ` ) }
190+
191+
192+
179193 this . hooks = {
180194 'before:package:createDeploymentArtifacts' : ( ) => BbPromise . bind ( this )
181195 . then ( this . fetchConfig )
196+ . then ( this . autoconfigArtifacts )
182197 . then ( ( ) => { Fse . ensureDirAsync ( this . buildDir ) } )
183198 . then ( this . setupDocker )
184199 . then ( this . selectAll )
0 commit comments