diff --git a/index.js b/index.js index 987102b..5340341 100644 --- a/index.js +++ b/index.js @@ -39,17 +39,15 @@ class RustPlugin { this.serverless.service.package.excludeDevDependencies = false; } - runDocker(funcArgs, cargoPackage) { + runDocker(funcArgs, cargoPackage, binary) { const defaultArgs = [ - "run", - "--rm", - "-t", - `-v`, - `${this.servicePath}:/code`, - `-v`, - `${process.env["HOME"]}/.cargo/registry:/root/.cargo/registry`, - `-v`, - `${process.env["HOME"]}/.cargo/git:/root/.cargo/git` + 'run', + '--rm', + '-t', + '-e', `BIN=${binary}`, + `-v`, `${this.servicePath}:/code`, + `-v`, `${process.env['HOME']}/.cargo/registry:/root/.cargo/registry`, + `-v`, `${process.env['HOME']}/.cargo/git:/root/.cargo/git`, ]; const customArgs = []; let cargoFlags = (funcArgs || {}).cargoFlags || this.custom.cargoFlags; @@ -99,7 +97,7 @@ class RustPlugin { binary = cargoPackage; } this.serverless.cli.log(`Building native Rust ${func.handler} func...`); - const res = this.runDocker(func.rust, cargoPackage); + const res = this.runDocker(func.rust, cargoPackage, binary); if (res.error || res.status > 0) { this.serverless.cli.log( `Dockerized Rust build encountered an error: ${res.error} ${