Skip to content

Commit e2efa66

Browse files
committed
#14 Implemented option to preinstall yums before bundling gem
1 parent e396fa1 commit e2efa66

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/bundle.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,22 @@ function bundleInstall(){
4444
if (ps.error && ps.error.code === 'ENOENT') {
4545
throw new Error('docker command not found');
4646
}
47+
let buildDocker = false;
4748
if (this.options.docker_file) {
4849
fs.copySync(path.join(this.servicePath, this.options.docker_file),
4950
path.join(this.ruby_layer,'Dockerfile'))
51+
buildDocker = true
52+
}else if (this.options.docker_yums) {
53+
docker_steps =['FROM lambci/lambda:build-'+this.serverless.service.provider.runtime]
54+
this.options.docker_yums.forEach(function(package_name) {
55+
docker_steps.push('RUN yum install -y '+package_name)
56+
})
57+
docker_steps.push('RUN gem update bundler')
58+
docker_steps.push('CMD "/bin/bash"')
59+
fs.writeFileSync(path.join(this.ruby_layer,'Dockerfile'),docker_steps.join('\n'))
60+
buildDocker = true
61+
}
62+
if (buildDocker) {
5063
docker_name ='ruby-layer:docker'
5164
docker(['build', '-t', docker_name, '-f', 'Dockerfile', '.'], options,this.cli)
5265
}

0 commit comments

Comments
 (0)