lambda-layer-cake 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c2e83a6e8260e73527a3adb0d302da0ff59bfe734f165b8c3a5ae2b02c874225
4
+ data.tar.gz: f3702b522dfae36a3cfab37f5642d9d8618de5c2c82b44cbe7e5c5106c8f6269
5
+ SHA512:
6
+ metadata.gz: 29f5718a159d316a2de9a5785d173dfa1c78332d318531b358970aa67baa4ffc2c42416518056a35a7df3b74585e49237c6386d74ebdce07f65a1b7583f5e9d5
7
+ data.tar.gz: a8590370365b683367f81829d1992a0ec32e049368b9c92a7002c7e819c001ae2e6c896e6ecbebfc80ab29d04ab6b11ee94f271e38c6a6b7bbe883e54a0a4b7d
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2019 Logan Bowers
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # LambdaLayerCake
2
+
3
+ LambdaLayerCake provides a set of rake tasks to produce two zip files for deploying Rails projects to AWS Lambda. One zip file (`layer.zip`) is of gems and any necessary system-level shared libraries, the second (`app.zip`) is of the Rails code itself. By splitting the project into two pieces, the inline lambda code editor can be used to edit most Rails projects.
4
+
5
+ I wrote this code to bridge the best aspects of Ruby on Jets and Lamby. Jets is great, but I didn't want to migrate off Rails onto a framework where the APIs potentially different (or are unimplemented). Lamby is also solid, but I wanted to package my dependencies indepentently and I didn't want to use AWS SAM to manage deployment of my app. I also wanted a clear, automated mechanism to include extra system packages in the Lambda environment.
6
+
7
+ This gem does just the packaging of the app and leaves deployment as an exercise for the user.
8
+
9
+ ## Usage
10
+
11
+ 1. Include Lamby and this gem in your Rails app's Gemfile.
12
+ 1. Create an `app.rb` in the root of your project per Lamby instructions to implement a Lambda handler.
13
+ 1. If you need extra system packages (such as `postgresql-libs` for the `pg` gem), create a file called `system-packages.txt` in the root of your Rails project and include package names, one per line.
14
+ 1. When you are ready to deploy your app, use `rake .layer_cake/layer.zip` and `rake .layer_cake/app.zip` to build files suitable for deployment to Lambda.
15
+ 1. Use the the demployment tools of your choice to deploy the app.
16
+
17
+
18
+ ## How It Works
19
+
20
+ LambdaLayerCake uses three input files to build `layer.zip`: `Gemfile`, `Gemfile.lock`, and `system-packages.txt`. The layer is built using the `lambci/lambda:build-ruby2.5` Docker image and any packages you specify in `system-packages.txt` are installed prior to building and installing gems. The packages themselves are not copied into the Lambda layer. LambdaLayerCake, however, walks all shared libraries built during gem installing, uses `ldd` to find dependent libraries that are not in the standard Lambda image, and copies them into the layer.
21
+
22
+ LambdaLayerCake simply bundles the Rails directory into app.zip, excluding files that begin with `.` and several directories that are not needed outside of development.
23
+
24
+ ## Contributing
25
+
26
+ This is my first attempt at publishing a complete gem and Rails plugin. I took it as an opportunity to learn and write idiomatic Rakefiles, automate usage of Docker, etc. Suggestions on how to improve the structure of any of the moving pieces is most welcome, pull requests are even better. Please open an issue.
27
+
28
+ ## TODO
29
+
30
+ Contributions on the following items is particularly appreciated:
31
+
32
+ * Modifying the Docker build environment to probe the host system's cache of gemfiles to more gracefully handle private and unreleased gems
33
+ * A `clean` Rake task
34
+
35
+ ## License
36
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'LambdaLayerCake'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ require 'bundler/gem_tasks'
@@ -0,0 +1,78 @@
1
+ require 'open3'
2
+ require 'set'
3
+ require 'fileutils'
4
+
5
+ def main
6
+ STDERR.puts("Loading list of installed packages…")
7
+ installed = File.read("installed-packages.txt").split
8
+
9
+ STDERR.puts("Installing tools")
10
+ unless(system("yum", "install", "-y", "yum-utils"))
11
+ STDERR.puts("Could not install yum-utils, exit code #{$?}")
12
+ exit 1
13
+ end
14
+
15
+ STDERR.puts("Moving to Build Directory")
16
+ Dir.chdir("/tmp/inputs")
17
+
18
+ if(File.exist?('system-packages.txt'))
19
+ STDERR.puts("Installing System Packages")
20
+ build_deps = File.read("system-packages.txt").split
21
+ unless(system("yum", "install", "-y", *(build_deps)))
22
+ STDERR.puts("Could not install build dependency pacakges")
23
+ exit 2
24
+ end
25
+ end
26
+
27
+ STDERR.puts("Building Gems")
28
+ FileUtils.mkdir_p("/tmp/build")
29
+ unless(system("bundle","install","--deployment","--path=/tmp/build"))
30
+ STDERR.puts("Couldn't build gems")
31
+ exit 3
32
+ end
33
+
34
+ STDERR.puts("Locating dynamic library depdendencies")
35
+ libs = Set.new
36
+ repoquery_cache = Hash.new() do |h,k| # Reduce calls to repoquery
37
+ pkgs_str, status = Open3.capture2("repoquery","-f", k)
38
+ h[k] = pkgs_str
39
+ end
40
+
41
+ Dir['/tmp/build/**/*.so*'].each do |lib|
42
+ STDERR.write("Checking deps on #{lib}…")
43
+ deps_str, status = Open3.capture2("ldd",lib)
44
+ unless(status.exitstatus == 0)
45
+ STDERR.puts("Couldn't run ldd! Status code: #{status}, ignoring…")
46
+ #exit 3
47
+ end
48
+ deps = deps_str.split("\n").collect { |d_str| d_str[/(?<==>\s)(\/\S+)/] }.compact
49
+ if(deps.length > 0)
50
+ deps.each do |dep|
51
+ STDERR.write('d')
52
+ pkgs = repoquery_cache[dep].split("\n")
53
+ if(pkgs.length > 0)
54
+ # See if it's already on the system
55
+ unless((installed & pkgs).first)
56
+ libs << dep
57
+ STDERR.write("!")
58
+ end
59
+ end
60
+ end
61
+ end
62
+ STDERR.write("\n")
63
+ end
64
+
65
+ STDERR.puts("The following libs need to be copied into /opt/lib: #{libs.to_a.join(',')}")
66
+ FileUtils.mkdir_p('/tmp/outputs/lib')
67
+ FileUtils.cp(libs.to_a, '/tmp/outputs/lib')
68
+
69
+ STDERR.puts("Moving gems into place")
70
+ FileUtils.mkdir_p('/tmp/outputs/ruby/gems/2.5.0')
71
+ #Skip the cache directory since it's not needed at runtime
72
+ FileUtils.cp_r(Dir["/tmp/build/ruby/2.5.0/*"] - ["/tmp/build/ruby/2.5.0/cache"], "/tmp/outputs/ruby/gems/2.5.0/")
73
+
74
+ STDERR.puts("All Done!")
75
+ end
76
+
77
+ main
78
+ true
@@ -0,0 +1,222 @@
1
+ ImageMagick-0:6.7.8.9-15.21.amzn1.x86_64
2
+ alsa-lib-0:1.0.22-3.9.amzn1.x86_64
3
+ audit-libs-0:2.6.5-3.28.amzn1.x86_64
4
+ avahi-libs-0:0.6.25-12.17.amzn1.x86_64
5
+ basesystem-0:10.0-4.9.amzn1.noarch
6
+ bash-0:4.2.46-28.37.amzn1.x86_64
7
+ binutils-0:2.25.1-31.base.66.amzn1.x86_64
8
+ bzip2-0:1.0.6-8.12.amzn1.x86_64
9
+ bzip2-libs-0:1.0.6-8.12.amzn1.x86_64
10
+ ca-certificates-0:2018.2.22-65.1.20.amzn1.noarch
11
+ cairo-0:1.12.14-6.8.amzn1.x86_64
12
+ chkconfig-0:1.3.49.3-2.14.amzn1.x86_64
13
+ compat-gmp4-0:4.3.2-1.14.amzn1.x86_64
14
+ copy-jdk-configs-0:3.3-10.3.amzn1.noarch
15
+ coreutils-0:8.22-15.52.amzn1.x86_64
16
+ cpio-0:2.10-12.12.amzn1.x86_64
17
+ cracklib-0:2.8.16-4.14.amzn1.x86_64
18
+ cracklib-dicts-0:2.8.16-4.14.amzn1.x86_64
19
+ cups-libs-1:1.4.2-67.21.amzn1.x86_64
20
+ curl-0:7.61.1-7.91.amzn1.x86_64
21
+ cyrus-sasl-lib-0:2.1.23-13.16.amzn1.x86_64
22
+ db4-0:4.7.25-18.11.amzn1.x86_64
23
+ db4-utils-0:4.7.25-18.11.amzn1.x86_64
24
+ dbus-libs-1:1.6.12-14.28.amzn1.x86_64
25
+ dejavu-fonts-common-0:2.33-6.6.amzn1.noarch
26
+ dejavu-sans-fonts-0:2.33-6.6.amzn1.noarch
27
+ dejavu-serif-fonts-0:2.33-6.6.amzn1.noarch
28
+ diffutils-0:3.3-4.15.amzn1.x86_64
29
+ elfutils-libelf-0:0.168-8.19.amzn1.x86_64
30
+ expat-0:2.1.0-10.21.amzn1.x86_64
31
+ file-0:5.34-3.37.amzn1.x86_64
32
+ file-libs-0:5.34-3.37.amzn1.x86_64
33
+ filesystem-0:2.4.30-3.8.amzn1.x86_64
34
+ findutils-1:4.4.2-6.9.amzn1.x86_64
35
+ fontconfig-0:2.8.0-5.8.amzn1.x86_64
36
+ fontpackages-filesystem-0:1.41-1.1.2.amzn1.noarch
37
+ freetype-0:2.3.11-15.14.amzn1.x86_64
38
+ gawk-0:3.1.7-10.10.amzn1.x86_64
39
+ gdbm-0:1.8.0-36.6.amzn1.x86_64
40
+ ghostscript-fonts-0:5.50-23.2.7.amzn1.noarch
41
+ giflib-0:4.1.6-3.1.6.amzn1.x86_64
42
+ glib2-0:2.36.3-5.18.amzn1.x86_64
43
+ glibc-0:2.17-260.175.amzn1.x86_64
44
+ glibc-common-0:2.17-260.175.amzn1.x86_64
45
+ gmp-0:6.0.0-11.16.amzn1.x86_64
46
+ gnupg2-0:2.0.28-2.33.amzn1.x86_64
47
+ gnutls-0:2.12.23-21.18.amzn1.x86_64
48
+ gpgme-0:1.4.3-5.15.amzn1.x86_64
49
+ grep-0:2.20-3.18.amzn1.x86_64
50
+ groff-base-0:1.22.2-8.11.amzn1.x86_64
51
+ gzip-0:1.5-9.19.amzn1.x86_64
52
+ hwdata-0:0.233-14.1.19.amzn1.noarch
53
+ info-0:5.1-4.10.amzn1.x86_64
54
+ jasper-libs-0:1.900.1-21.9.amzn1.x86_64
55
+ java-1.8.0-openjdk-1:1.8.0.201.b09-0.43.amzn1.x86_64
56
+ java-1.8.0-openjdk-headless-1:1.8.0.201.b09-0.43.amzn1.x86_64
57
+ javapackages-tools-0:0.9.1-1.5.amzn1.noarch
58
+ jbigkit-libs-0:2.0-11.4.amzn1.x86_64
59
+ jpackage-utils-0:1.7.5-27.17.amzn1.noarch
60
+ keyutils-libs-0:1.5.8-3.12.amzn1.x86_64
61
+ kmod-0:14-10.10.amzn1.x86_64
62
+ kmod-libs-0:14-10.10.amzn1.x86_64
63
+ krb5-libs-0:1.15.1-34.44.amzn1.x86_64
64
+ lcms2-0:2.6-2.5.amzn1.x86_64
65
+ libICE-0:1.0.6-1.4.amzn1.x86_64
66
+ libSM-0:1.2.1-2.6.amzn1.x86_64
67
+ libX11-0:1.6.0-2.2.12.amzn1.x86_64
68
+ libX11-common-0:1.6.0-2.2.12.amzn1.x86_64
69
+ libXau-0:1.0.6-4.9.amzn1.x86_64
70
+ libXcomposite-0:0.4.3-4.6.amzn1.x86_64
71
+ libXdamage-0:1.1.3-4.7.amzn1.x86_64
72
+ libXext-0:1.3.2-2.1.10.amzn1.x86_64
73
+ libXfixes-0:5.0.1-2.1.8.amzn1.x86_64
74
+ libXfont-0:1.4.5-5.12.amzn1.x86_64
75
+ libXi-0:1.7.2-2.2.9.amzn1.x86_64
76
+ libXrender-0:0.9.8-2.1.9.amzn1.x86_64
77
+ libXt-0:1.1.4-6.1.9.amzn1.x86_64
78
+ libXtst-0:1.2.2-2.1.9.amzn1.x86_64
79
+ libXxf86vm-0:1.1.3-2.1.9.amzn1.x86_64
80
+ libacl-0:2.2.49-6.11.amzn1.x86_64
81
+ libassuan-0:2.0.3-3.3.amzn1.x86_64
82
+ libattr-0:2.4.46-12.10.amzn1.x86_64
83
+ libblkid-0:2.23.2-33.28.amzn1.x86_64
84
+ libcap-0:2.16-5.5.8.amzn1.x86_64
85
+ libcap-ng-0:0.7.5-4.15.amzn1.x86_64
86
+ libcom_err-0:1.43.5-2.43.amzn1.x86_64
87
+ libcurl-0:7.61.1-7.91.amzn1.x86_64
88
+ libdrm-0:2.4.82-1.14.amzn1.x86_64
89
+ libffi-0:3.0.13-16.5.amzn1.x86_64
90
+ libfontenc-0:1.0.5-2.6.amzn1.x86_64
91
+ libgcc72-0:7.2.1-2.59.amzn1.x86_64
92
+ libgcrypt-0:1.5.3-12.19.amzn1.x86_64
93
+ libglvnd-1:0.2.999-14.20170308git8e6e102.3.amzn1.x86_64
94
+ libglvnd-glx-1:0.2.999-14.20170308git8e6e102.3.amzn1.x86_64
95
+ libgomp-0:6.4.1-1.45.amzn1.x86_64
96
+ libgpg-error-0:1.11-1.12.amzn1.x86_64
97
+ libicu-0:50.1.2-11.12.amzn1.x86_64
98
+ libidn2-0:0.16-1.2.amzn1.x86_64
99
+ libjpeg-turbo-0:1.2.90-5.14.amzn1.x86_64
100
+ libmount-0:2.23.2-33.28.amzn1.x86_64
101
+ libnghttp2-0:1.21.1-1.4.amzn1.x86_64
102
+ libpciaccess-0:0.13.1-4.1.11.amzn1.x86_64
103
+ libpng-2:1.2.49-2.14.amzn1.x86_64
104
+ libpsl-0:0.6.2-1.2.amzn1.x86_64
105
+ libpwquality-0:1.2.3-4.8.amzn1.x86_64
106
+ libselinux-0:2.1.10-3.22.amzn1.x86_64
107
+ libsepol-0:2.1.7-3.12.amzn1.x86_64
108
+ libssh2-0:1.4.2-2.13.amzn1.x86_64
109
+ libstdc++72-0:7.2.1-2.59.amzn1.x86_64
110
+ libtasn1-0:2.3-6.6.amzn1.x86_64
111
+ libtiff-0:4.0.3-27.29.amzn1.x86_64
112
+ libtool-ltdl-0:2.4.2-20.4.8.5.32.amzn1.x86_64
113
+ libudev-0:173-4.13.amzn1.x86_64
114
+ libunistring-0:0.9.3-6.1.amzn1.x86_64
115
+ libuser-0:0.60-7.23.amzn1.x86_64
116
+ libutempter-0:1.1.5-4.1.6.amzn1.x86_64
117
+ libuuid-0:2.23.2-33.28.amzn1.x86_64
118
+ libverto-0:0.2.5-4.9.amzn1.x86_64
119
+ libwmf-lite-0:0.2.8.4-41.13.amzn1.x86_64
120
+ libxcb-0:1.11-2.21.amzn1.x86_64
121
+ libxml2-0:2.9.1-6.3.52.amzn1.x86_64
122
+ libxshmfence-0:1.2-1.4.amzn1.x86_64
123
+ libxslt-0:1.1.28-5.12.amzn1.x86_64
124
+ lksctp-tools-0:1.0.10-7.7.amzn1.x86_64
125
+ lua-0:5.1.4-4.1.9.amzn1.x86_64
126
+ make-1:3.82-21.10.amzn1.x86_64
127
+ mesa-dri-drivers-0:17.1.5-2.41.amzn1.x86_64
128
+ mesa-filesystem-0:17.1.5-2.41.amzn1.x86_64
129
+ mesa-libGL-0:17.1.5-2.41.amzn1.x86_64
130
+ mesa-libglapi-0:17.1.5-2.41.amzn1.x86_64
131
+ ncurses-0:5.7-4.20090207.14.amzn1.x86_64
132
+ ncurses-base-0:5.7-4.20090207.14.amzn1.x86_64
133
+ ncurses-libs-0:5.7-4.20090207.14.amzn1.x86_64
134
+ nspr-0:4.19.0-1.43.amzn1.x86_64
135
+ nss-0:3.36.0-5.82.amzn1.x86_64
136
+ nss-pem-0:1.0.3-4.3.amzn1.x86_64
137
+ nss-softokn-0:3.36.0-5.42.amzn1.x86_64
138
+ nss-softokn-freebl-0:3.36.0-5.42.amzn1.x86_64
139
+ nss-sysinit-0:3.36.0-5.82.amzn1.x86_64
140
+ nss-tools-0:3.36.0-5.82.amzn1.x86_64
141
+ nss-util-0:3.36.0-1.54.amzn1.x86_64
142
+ openldap-0:2.4.40-16.31.amzn1.x86_64
143
+ openssl-1:1.0.2k-16.150.amzn1.x86_64
144
+ p11-kit-0:0.18.5-2.3.amzn1.x86_64
145
+ p11-kit-trust-0:0.18.5-2.3.amzn1.x86_64
146
+ pam-0:1.1.8-12.33.amzn1.x86_64
147
+ patch-0:2.7.1-10.10.amzn1.x86_64
148
+ pcre-0:8.21-7.8.amzn1.x86_64
149
+ perl-4:5.16.3-294.43.amzn1.x86_64
150
+ perl-Carp-0:1.26-244.5.amzn1.noarch
151
+ perl-Encode-0:2.51-7.5.amzn1.x86_64
152
+ perl-Exporter-0:5.68-3.5.amzn1.noarch
153
+ perl-File-Path-0:2.09-2.5.amzn1.noarch
154
+ perl-File-Temp-0:0.23.01-3.5.amzn1.noarch
155
+ perl-Filter-0:1.49-3.5.amzn1.x86_64
156
+ perl-Getopt-Long-0:2.40-3.6.amzn1.noarch
157
+ perl-HTTP-Tiny-0:0.033-3.6.amzn1.noarch
158
+ perl-PathTools-0:3.40-5.5.amzn1.x86_64
159
+ perl-Pod-Escapes-1:1.04-294.43.amzn1.noarch
160
+ perl-Pod-Perldoc-0:3.20-4.7.amzn1.noarch
161
+ perl-Pod-Simple-1:3.28-4.6.amzn1.noarch
162
+ perl-Pod-Usage-0:1.63-3.5.amzn1.noarch
163
+ perl-Scalar-List-Utils-0:1.27-248.5.amzn1.x86_64
164
+ perl-Socket-0:2.010-3.5.amzn1.x86_64
165
+ perl-Storable-0:2.45-3.5.amzn1.x86_64
166
+ perl-Text-ParseWords-0:3.29-4.5.amzn1.noarch
167
+ perl-Time-HiRes-4:1.9725-272.5.amzn1.x86_64
168
+ perl-Time-Local-0:1.2300-2.5.amzn1.noarch
169
+ perl-constant-0:1.27-2.5.amzn1.noarch
170
+ perl-libs-4:5.16.3-294.43.amzn1.x86_64
171
+ perl-macros-4:5.16.3-294.43.amzn1.x86_64
172
+ perl-parent-1:0.225-244.5.amzn1.noarch
173
+ perl-podlators-0:2.5.1-3.8.amzn1.noarch
174
+ perl-threads-0:1.87-4.5.amzn1.x86_64
175
+ perl-threads-shared-0:1.43-6.5.amzn1.x86_64
176
+ pinentry-0:0.7.6-6.11.amzn1.x86_64
177
+ pixman-0:0.32.4-4.11.amzn1.x86_64
178
+ pkgconfig-1:0.27.1-2.7.amzn1.x86_64
179
+ popt-0:1.13-7.7.amzn1.x86_64
180
+ procps-0:3.2.8-45.16.amzn1.x86_64
181
+ psmisc-0:22.20-8.12.amzn1.x86_64
182
+ pth-0:2.0.7-9.3.7.amzn1.x86_64
183
+ python27-0:2.7.16-1.127.amzn1.x86_64
184
+ python27-iniparse-0:0.3.1-2.1.9.amzn1.noarch
185
+ python27-libs-0:2.7.16-1.127.amzn1.x86_64
186
+ python27-pycurl-0:7.19.0-17.12.amzn1.x86_64
187
+ python27-pygpgme-0:0.3-9.12.amzn1.x86_64
188
+ python27-pyliblzma-0:0.5.3-11.6.amzn1.x86_64
189
+ python27-pyxattr-0:0.5.0-1.6.amzn1.x86_64
190
+ python27-urlgrabber-0:3.10-8.16.amzn1.noarch
191
+ python36-0:3.6.8-1.13.amzn1.x86_64
192
+ python36-libs-0:3.6.8-1.13.amzn1.x86_64
193
+ python36-pip-0:9.0.3-1.26.amzn1.noarch
194
+ python36-setuptools-0:36.2.7-1.33.amzn1.noarch
195
+ readline-0:6.2-9.14.amzn1.x86_64
196
+ rpm-0:4.11.3-21.75.amzn1.x86_64
197
+ rpm-build-libs-0:4.11.3-21.75.amzn1.x86_64
198
+ rpm-libs-0:4.11.3-21.75.amzn1.x86_64
199
+ rpm-python27-0:4.11.3-21.75.amzn1.x86_64
200
+ sed-0:4.2.1-10.10.amzn1.x86_64
201
+ setup-0:2.8.14-20.12.amzn1.noarch
202
+ shadow-utils-2:4.1.4.2-13.10.amzn1.x86_64
203
+ shared-mime-info-0:1.1-9.8.amzn1.x86_64
204
+ sqlite-0:3.7.17-8.14.amzn1.x86_64
205
+ sysctl-defaults-0:1.0-1.1.amzn1.noarch
206
+ system-release-0:2018.03-0.0.noarch
207
+ tar-2:1.26-31.22.amzn1.x86_64
208
+ ttmkfdir-0:3.0.9-32.1.5.amzn1.x86_64
209
+ tzdata-0:2018c-1.70.amzn1.noarch
210
+ tzdata-java-0:2018c-1.70.amzn1.noarch
211
+ unzip-0:6.0-4.10.amzn1.x86_64
212
+ urw-fonts-0:2.4-10.7.amzn1.noarch
213
+ util-linux-0:2.23.2-33.28.amzn1.x86_64
214
+ which-0:2.19-6.10.amzn1.x86_64
215
+ xorg-x11-font-utils-1:7.2-11.5.amzn1.x86_64
216
+ xorg-x11-fonts-Type1-0:7.2-9.1.5.amzn1.noarch
217
+ xz-0:5.1.2-12alpha.12.amzn1.x86_64
218
+ xz-libs-0:5.1.2-12alpha.12.amzn1.x86_64
219
+ yum-0:3.4.3-150.70.amzn1.noarch
220
+ yum-metadata-parser-0:1.1.4-10.20.amzn1.x86_64
221
+ yum-plugin-priorities-0:1.1.31-46.30.amzn1.noarch
222
+ zlib-0:1.2.8-7.18.amzn1.x86_64
@@ -0,0 +1,70 @@
1
+ module LambdaLayerCake
2
+ require 'lambda_layer_cake/railtie' if defined?(Rails)
3
+
4
+ class Builder
5
+ attr :version
6
+
7
+ def initialize(version)
8
+ @version = version
9
+ end
10
+
11
+ def clean!
12
+ FileUtils.rm_r(outputs_dir!)
13
+ end
14
+
15
+ def build_layer!
16
+ FileUtils.cp(%w{Gemfile Gemfile.lock system-packages.txt}.select {|f| File.exist?(f) }, inputs_dir!)
17
+
18
+ cmd = %W{docker run --rm
19
+ -v #{inputs_dir!}:/tmp/inputs
20
+ -v #{outputs_dir!}:/tmp/outputs
21
+ -v #{tools_dir}:/var/task
22
+ lambci/lambda:build-ruby2.5 ruby build_ruby.rb}
23
+ STDERR.puts("Excuting cmd: #{cmd.join(' ')}")
24
+ system(*cmd) or raise
25
+ end
26
+
27
+ def zip_layer!
28
+ pwd = Dir.pwd
29
+ begin
30
+ Dir.chdir(outputs_dir!)
31
+ cmd = *%W{zip -r #{File.join(build_dir!, "layer-#{version}.zip")} lib ruby}
32
+ system(*cmd) or raise
33
+ ensure
34
+ Dir.chdir(pwd)
35
+ end
36
+ end
37
+
38
+ def build_rails!
39
+
40
+ end
41
+
42
+ private
43
+
44
+ def inputs_dir!
45
+ working_dir!("layer_inputs")
46
+ end
47
+
48
+ def outputs_dir!
49
+ working_dir!("layer-#{version}")
50
+ end
51
+
52
+ def working_dir!(path_suffix = "")
53
+ File.expand_path(
54
+ File.join(
55
+ Rails.root,
56
+ '.layer_cake/',
57
+ path_suffix
58
+ )
59
+ ).tap { |d| FileUtils.mkdir_p(d) }
60
+ end
61
+
62
+ def tools_dir
63
+ File.expand_path(__dir__ + "/../build_env") # Never needs to be created
64
+ end
65
+
66
+ def build_dir!
67
+ working_dir!
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,10 @@
1
+ module LambdaLayerCake
2
+ class Railtie < ::Rails::Railtie
3
+ railtie_name :layer_cake
4
+
5
+ rake_tasks do
6
+ path = File.expand_path(__dir__)
7
+ Dir.glob("#{path}/../tasks/**/*.rake").each { |f| load f }
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module LambdaLayerCake
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,92 @@
1
+ require 'digest'
2
+ require 'fileutils'
3
+
4
+ require 'rake/packagetask'
5
+
6
+ namespace :layer_cake do
7
+ desc 'Clean the build directories'
8
+ task :clean do
9
+ LambdaLayerCake.clean!
10
+ end
11
+
12
+ #Files used to generate the gem layer
13
+ INPUT_FILES = Rake::FileList.new(
14
+ ['Gemfile', 'Gemfile.lock', 'system-packages.txt'].collect { |f| File.join(Rails.root, f) }
15
+ )
16
+ #Files used to generate the
17
+ APP_FILES = Rake::FileList.new(Dir['*'] - ['spec','test','log', 'tmp'])
18
+ OUTPUT_DIR = '.layer_cake'
19
+
20
+ # Some helper methods
21
+ def self.input_hash
22
+ @input_hash ||= begin
23
+ hash = Digest::SHA1.hexdigest(INPUT_FILES.existing.collect do |f|
24
+ File.read(f)
25
+ end.join("\x1C"))
26
+ hash[0..7]
27
+ end
28
+ end
29
+
30
+ def inputs_dir
31
+ working_dir("layer_inputs")
32
+ end
33
+
34
+ def outputs_dir
35
+ working_dir("layer-#{input_hash}")
36
+ end
37
+
38
+ def working_dir(path_suffix = "")
39
+ File.expand_path(
40
+ File.join(
41
+ Rails.root,
42
+ '.layer_cake/',
43
+ path_suffix
44
+ )
45
+ )
46
+ end
47
+
48
+ desc "Output the version hash for the current input files (Gemfile, Gemfile.lock, system-packages.txt)"
49
+ task :version do
50
+ $stdout.write input_hash
51
+ end
52
+
53
+ desc "Builds a layer.zip with gems and libraries"
54
+ task build_layer: '.layer_cake/layer.zip'
55
+
56
+ desc "Build a layer for version #{input_hash}"
57
+ directory ".layer_cake/layer-#{input_hash}"
58
+ file ".layer_cake/layer-#{input_hash}": INPUT_FILES.existing do
59
+ FileUtils.mkdir_p(inputs_dir)
60
+ FileUtils.cp(INPUT_FILES.existing, inputs_dir)
61
+
62
+ cmd = %W{docker run --rm
63
+ -v #{inputs_dir}:/tmp/inputs
64
+ -v #{outputs_dir}:/tmp/outputs
65
+ -v #{File.expand_path(__dir__ + "/../../build_env")}:/var/task
66
+ lambci/lambda:build-ruby2.5 ruby build_ruby.rb}
67
+ STDERR.puts("Excuting cmd: #{cmd.join(' ')}")
68
+ system(*cmd) or raise
69
+ end
70
+
71
+ file ".layer_cake/layer-#{input_hash}.zip": ".layer_cake/layer-#{input_hash}" do
72
+ pwd = Dir.pwd
73
+ begin
74
+ Dir.chdir(outputs_dir)
75
+ cmd = %W{zip -r #{File.join(working_dir, "layer-#{input_hash}.zip")} lib ruby}
76
+ system(*cmd) or raise
77
+ ensure
78
+ Dir.chdir(pwd)
79
+ end
80
+ end
81
+
82
+ desc "Build the current layer version and symlink it to the versioned zip"
83
+ file ".layer_cake/layer.zip": ".layer_cake/layer-#{input_hash}.zip" do
84
+ FileUtils.ln_s("layer-#{input_hash}.zip",".layer_cake/layer.zip", force: true)
85
+ end
86
+
87
+ desc "Zip up Rails directory into an app"
88
+ file ".layer_cake/app.zip": APP_FILES do
89
+ cmd = %W{zip -r .layer_cake/app.zip} + APP_FILES
90
+ system(*cmd) or raise
91
+ end
92
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lambda-layer-cake
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Logan Bowers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-09-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A set of Rake tasks to bundle Rails apps for use on AWS Lambda
42
+ email:
43
+ - logan@datacurrent.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - build_env/build_ruby.rb
52
+ - build_env/installed-packages.txt
53
+ - lib/lambda-layer-cake.rb
54
+ - lib/lambda_layer_cake/railtie.rb
55
+ - lib/lambda_layer_cake/version.rb
56
+ - lib/tasks/layer_cake.rake
57
+ homepage: http://github.com/loganb/lambda-layer-cake
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.7.10
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: A set of Rake tasks to bundle Rails apps for use on AWS Lambda
81
+ test_files: []