lamby 2.6.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -5
- data/bin/_test +2 -1
- data/lib/lamby.rb +6 -0
- data/lib/lamby/config.rb +51 -0
- data/lib/lamby/handler.rb +40 -10
- data/lib/lamby/rack.rb +16 -0
- data/lib/lamby/rack_alb.rb +9 -0
- data/lib/lamby/rack_http.rb +10 -0
- data/lib/lamby/rack_rest.rb +8 -0
- data/lib/lamby/railtie.rb +0 -2
- data/lib/lamby/runner.rb +58 -0
- data/lib/lamby/templates/alb.rb +2 -2
- data/lib/lamby/templates/alb/Dockerfile +12 -0
- data/lib/lamby/templates/alb/Dockerfile-build +11 -8
- data/lib/lamby/templates/alb/_build +9 -24
- data/lib/lamby/templates/alb/_deploy +10 -41
- data/lib/lamby/templates/alb/app.rb +1 -1
- data/lib/lamby/templates/alb/deploy +3 -8
- data/lib/lamby/templates/alb/docker-compose.yml +9 -7
- data/lib/lamby/templates/alb/template.yaml +1 -1
- data/lib/lamby/templates/http.rb +2 -2
- data/lib/lamby/templates/http/Dockerfile +12 -0
- data/lib/lamby/templates/http/Dockerfile-build +11 -8
- data/lib/lamby/templates/http/_build +9 -24
- data/lib/lamby/templates/http/_deploy +9 -23
- data/lib/lamby/templates/http/app.rb +1 -1
- data/lib/lamby/templates/http/deploy +3 -8
- data/lib/lamby/templates/http/docker-compose.yml +9 -7
- data/lib/lamby/templates/http/template.yaml +1 -1
- data/lib/lamby/templates/rest.rb +2 -2
- data/lib/lamby/templates/rest/Dockerfile +12 -0
- data/lib/lamby/templates/rest/Dockerfile-build +11 -8
- data/lib/lamby/templates/rest/_build +9 -24
- data/lib/lamby/templates/rest/_deploy +9 -23
- data/lib/lamby/templates/rest/app.rb +1 -1
- data/lib/lamby/templates/rest/deploy +3 -8
- data/lib/lamby/templates/rest/docker-compose.yml +9 -7
- data/lib/lamby/templates/rest/template.yaml +1 -1
- data/lib/lamby/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0617227ed78f3d72343201c0c77d89e174c674f22e6a8c42ed6a07b6b1cec866
|
4
|
+
data.tar.gz: 8569247f0afb429718263444638a67cef3e765c576217c106e1af9b72025f724
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a2ac758ac583d5547d2112afbb4a78b6fba6261b7f6eb3e9056378a66f71b827528a6986623818e36aa69c680b67478687d1557a8f851111dddc90155d3428b
|
7
|
+
data.tar.gz: 287359de5ea4b423f81156e46a5455a739d22b293bb20190c02744a76b0dbd5860b63dfd80177b3aec178be2c8924a81add185a449f43e82c804f79ed17c5702
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,41 @@
|
|
4
4
|
|
5
5
|
See this http://keepachangelog.com link for information on how we want this documented formatted.
|
6
6
|
|
7
|
+
## v3.0.0
|
8
|
+
|
9
|
+
#### Added
|
10
|
+
|
11
|
+
- Automatically handle `Lambdakiq.jobs?(event)`.
|
12
|
+
- New event for tasks like DB migrations. #80 #93
|
13
|
+
|
14
|
+
#### Changed
|
15
|
+
|
16
|
+
- Updated template files to latest lambda container standards.
|
17
|
+
|
18
|
+
## v2.8.0
|
19
|
+
|
20
|
+
#### Fixed
|
21
|
+
|
22
|
+
- Perform rack body closing hooks on request #85
|
23
|
+
|
24
|
+
## v2.7.1
|
25
|
+
|
26
|
+
#### Removed
|
27
|
+
|
28
|
+
- Bootsnap setup convenience require.
|
29
|
+
|
30
|
+
## v2.7.0
|
31
|
+
|
32
|
+
#### Added
|
33
|
+
|
34
|
+
- Support EventBridge events in handler with default proc to log.
|
35
|
+
|
36
|
+
## v2.6.3
|
37
|
+
|
38
|
+
#### Added
|
39
|
+
|
40
|
+
- Bootsnap setup convenience require.
|
41
|
+
|
7
42
|
## v2.6.2
|
8
43
|
|
9
44
|
- Fixed Rack::Deflate usage with an ALB.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
# Lamby [](https://github.com/customink/lamby/actions)
|
3
2
|
|
4
3
|
<h2>Simple Rails & AWS Lambda Integration</h2>
|
@@ -11,7 +10,7 @@ The goal of this project is to provide minimal code to allow your Rails applicat
|
|
11
10
|
|
12
11
|
```ruby
|
13
12
|
def handler(event:, context:)
|
14
|
-
Lamby.handler $app, event, context
|
13
|
+
Lamby.handler $app, event, context
|
15
14
|
end
|
16
15
|
```
|
17
16
|
|
@@ -19,12 +18,10 @@ end
|
|
19
18
|
|
20
19
|
https://lamby.custominktech.com/docs/quick_start
|
21
20
|
|
22
|
-
|
23
21
|
## Full Documentation
|
24
22
|
|
25
23
|
https://lamby.custominktech.com/docs/installing_aws_sam
|
26
24
|
|
27
|
-
|
28
25
|
## Contributing
|
29
26
|
|
30
27
|
After checking out the repo, run:
|
@@ -37,7 +34,6 @@ $ ./bin/test
|
|
37
34
|
|
38
35
|
Bug reports and pull requests are welcome on GitHub at https://github.com/customink/lamby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
39
36
|
|
40
|
-
|
41
37
|
## Code of Conduct
|
42
38
|
|
43
39
|
Everyone interacting in the Lamby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/customink/lamby/blob/master/CODE_OF_CONDUCT.md).
|
data/bin/_test
CHANGED
data/lib/lamby.rb
CHANGED
@@ -2,12 +2,14 @@ require 'lamby/logger'
|
|
2
2
|
require 'rack'
|
3
3
|
require 'base64'
|
4
4
|
require 'lamby/version'
|
5
|
+
require 'lamby/config'
|
5
6
|
require 'lamby/sam_helpers'
|
6
7
|
require 'lamby/rack'
|
7
8
|
require 'lamby/rack_alb'
|
8
9
|
require 'lamby/rack_rest'
|
9
10
|
require 'lamby/rack_http'
|
10
11
|
require 'lamby/debug'
|
12
|
+
require 'lamby/runner'
|
11
13
|
require 'lamby/handler'
|
12
14
|
|
13
15
|
if defined?(Rails)
|
@@ -23,6 +25,10 @@ module Lamby
|
|
23
25
|
Handler.call(app, event, context, options)
|
24
26
|
end
|
25
27
|
|
28
|
+
def config
|
29
|
+
Lamby::Config.config
|
30
|
+
end
|
31
|
+
|
26
32
|
autoload :SsmParameterStore, 'lamby/ssm_parameter_store'
|
27
33
|
|
28
34
|
end
|
data/lib/lamby/config.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
module Lamby
|
2
|
+
module Config
|
3
|
+
|
4
|
+
def configure
|
5
|
+
yield(config)
|
6
|
+
config
|
7
|
+
end
|
8
|
+
|
9
|
+
def reconfigure
|
10
|
+
config.reconfigure { |c| yield(c) if block_given? }
|
11
|
+
end
|
12
|
+
|
13
|
+
def config
|
14
|
+
@config ||= Configuration.new
|
15
|
+
end
|
16
|
+
|
17
|
+
extend self
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
class Configuration
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
initialize_defaults
|
25
|
+
end
|
26
|
+
|
27
|
+
def reconfigure
|
28
|
+
instance_variables.each { |var| instance_variable_set var, nil }
|
29
|
+
initialize_defaults
|
30
|
+
yield(self) if block_given?
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def initialize_defaults
|
35
|
+
@event_bridge_handler = lambda { |event, context| puts(event) }
|
36
|
+
end
|
37
|
+
|
38
|
+
def event_bridge_handler
|
39
|
+
@event_bridge_handler
|
40
|
+
end
|
41
|
+
|
42
|
+
def event_bridge_handler=(func)
|
43
|
+
@event_bridge_handler = func
|
44
|
+
end
|
45
|
+
|
46
|
+
def runner_patterns
|
47
|
+
Runner::PATTERNS
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
data/lib/lamby/handler.rb
CHANGED
@@ -41,13 +41,14 @@ module Lamby
|
|
41
41
|
def body
|
42
42
|
@rbody ||= ''.tap do |rbody|
|
43
43
|
@body.each { |part| rbody << part if part }
|
44
|
+
@body.close if @body.respond_to? :close
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
47
48
|
def call
|
48
49
|
return self if @called
|
49
50
|
@status, @headers, @body = call_app
|
50
|
-
set_cookies
|
51
|
+
set_cookies if rack?
|
51
52
|
@called = true
|
52
53
|
self
|
53
54
|
end
|
@@ -67,25 +68,37 @@ module Lamby
|
|
67
68
|
private
|
68
69
|
|
69
70
|
def rack
|
70
|
-
@rack
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
else
|
76
|
-
Lamby::RackHttp.new @event, @context
|
71
|
+
return @rack if defined?(@rack)
|
72
|
+
@rack = begin
|
73
|
+
type = rack_option
|
74
|
+
klass = Lamby::Rack.lookup type, @event
|
75
|
+
(klass && klass.handle?(@event)) ? klass.new(@event, @context) : false
|
77
76
|
end
|
78
77
|
end
|
79
78
|
|
79
|
+
def rack_option
|
80
|
+
return if ENV['LAMBY_TEST_DYNAMIC_HANDLER']
|
81
|
+
@options[:rack]
|
82
|
+
end
|
83
|
+
|
80
84
|
def rack_response
|
81
|
-
rack.response(self)
|
85
|
+
rack? ? rack.response(self) : {}
|
82
86
|
end
|
83
87
|
|
84
88
|
def call_app
|
85
89
|
if Debug.on?(@event)
|
86
90
|
Debug.call @event, @context, rack.env
|
87
|
-
|
91
|
+
elsif rack?
|
88
92
|
@app.call rack.env
|
93
|
+
elsif runner?
|
94
|
+
Runner.call(@event)
|
95
|
+
elsif lambdakiq?
|
96
|
+
Lambdakiq.handler(@event)
|
97
|
+
elsif event_bridge?
|
98
|
+
Lamby.config.event_bridge_handler.call @event, @context
|
99
|
+
[200, {}, StringIO.new('')]
|
100
|
+
else
|
101
|
+
[404, {}, StringIO.new('')]
|
89
102
|
end
|
90
103
|
end
|
91
104
|
|
@@ -93,5 +106,22 @@ module Lamby
|
|
93
106
|
content_encoding_header = hdrs['Content-Encoding'] || ''
|
94
107
|
content_encoding_header.split(', ').any? { |h| ['br', 'gzip'].include?(h) }
|
95
108
|
end
|
109
|
+
|
110
|
+
def rack?
|
111
|
+
rack
|
112
|
+
end
|
113
|
+
|
114
|
+
def event_bridge?
|
115
|
+
Lamby.config.event_bridge_handler &&
|
116
|
+
@event.key?('source') && @event.key?('detail') && @event.key?('detail-type')
|
117
|
+
end
|
118
|
+
|
119
|
+
def lambdakiq?
|
120
|
+
defined?(::Lambdakiq) && ::Lambdakiq.job?(@event)
|
121
|
+
end
|
122
|
+
|
123
|
+
def runner?
|
124
|
+
Runner.handle?(@event)
|
125
|
+
end
|
96
126
|
end
|
97
127
|
end
|
data/lib/lamby/rack.rb
CHANGED
@@ -7,6 +7,22 @@ module Lamby
|
|
7
7
|
LAMBDA_CONTEXT = 'lambda.context'.freeze
|
8
8
|
HTTP_X_REQUESTID = 'HTTP_X_REQUEST_ID'.freeze
|
9
9
|
HTTP_COOKIE = 'HTTP_COOKIE'.freeze
|
10
|
+
|
11
|
+
class << self
|
12
|
+
|
13
|
+
def lookup(type, event)
|
14
|
+
types[type] || types.values.detect { |t| t.handle?(event) }
|
15
|
+
end
|
16
|
+
|
17
|
+
# Order is important. REST is hardest to isolated with handle? method.
|
18
|
+
def types
|
19
|
+
{ alb: RackAlb,
|
20
|
+
http: RackHttp,
|
21
|
+
rest: RackRest,
|
22
|
+
api: RackRest }
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
10
26
|
|
11
27
|
attr_reader :event, :context
|
12
28
|
|
data/lib/lamby/rack_alb.rb
CHANGED
data/lib/lamby/rack_http.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
module Lamby
|
2
2
|
class RackHttp < Lamby::Rack
|
3
3
|
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def handle?(event)
|
7
|
+
event.key?('version') &&
|
8
|
+
( event.dig('requestContext', 'http') ||
|
9
|
+
event.dig('requestContext', 'httpMethod') )
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
4
14
|
def response(handler)
|
5
15
|
if handler.base64_encodeable?
|
6
16
|
{ isBase64Encoded: true, body: handler.body64 }
|
data/lib/lamby/rack_rest.rb
CHANGED
data/lib/lamby/railtie.rb
CHANGED
data/lib/lamby/runner.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Lamby
|
4
|
+
class Runner
|
5
|
+
class Error < StandardError ; end
|
6
|
+
class UnknownCommandPattern < Error ; end
|
7
|
+
|
8
|
+
PATTERNS = [
|
9
|
+
%r{\A\./bin/(rails|rake) db:migrate.*}
|
10
|
+
]
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
def handle?(event)
|
15
|
+
event.dig 'lamby', 'runner'
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(event)
|
19
|
+
new(event).call
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(event)
|
25
|
+
@event = event
|
26
|
+
end
|
27
|
+
|
28
|
+
def call
|
29
|
+
validate!
|
30
|
+
status = Open3.popen3(command, chdir: chdir) do |_stdin, stdout, stderr, thread|
|
31
|
+
puts stdout.read
|
32
|
+
puts stderr.read
|
33
|
+
thread.value.exitstatus
|
34
|
+
end
|
35
|
+
[status, {}, StringIO.new('')]
|
36
|
+
end
|
37
|
+
|
38
|
+
def command
|
39
|
+
@event.dig 'lamby', 'runner'
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def chdir
|
45
|
+
defined?(::Rails) ? ::Rails.root : Dir.pwd
|
46
|
+
end
|
47
|
+
|
48
|
+
def validate!
|
49
|
+
return if pattern?
|
50
|
+
raise UnknownCommandPattern.new(command)
|
51
|
+
end
|
52
|
+
|
53
|
+
def pattern?
|
54
|
+
PATTERNS.any? { |p| p === command }
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
data/lib/lamby/templates/alb.rb
CHANGED
@@ -10,13 +10,13 @@ gsub_file app_file('template.yaml'), /APPNAMEHERE/, appname
|
|
10
10
|
copy_file tpl_file('Dockerfile'), app_file('Dockerfile')
|
11
11
|
copy_file tpl_file('Dockerfile-build'), app_file('Dockerfile-build')
|
12
12
|
copy_file tpl_file('docker-compose.yml'), app_file('docker-compose.yml')
|
13
|
+
gsub_file app_file('docker-compose.yml'), /APPNAMEHERE/, appname.downcase
|
13
14
|
|
14
15
|
say 'Adding to .gitignore...'
|
15
16
|
FileUtils.touch app_file('.gitignore')
|
16
17
|
append_to_file app_file('.gitignore'), <<~GITIGNORE
|
17
18
|
# Lamby
|
18
19
|
/.aws-sam
|
19
|
-
/.lamby
|
20
20
|
GITIGNORE
|
21
21
|
|
22
22
|
say 'Creating ./bin files for build and deploy...'
|
@@ -24,10 +24,10 @@ copy_file tpl_file('_build'), app_file('bin/_build')
|
|
24
24
|
gsub_file app_file('bin/_build'), /APPNAMEHERE/, appname.downcase
|
25
25
|
chmod app_file('bin/_build'), 0755
|
26
26
|
copy_file tpl_file('deploy'), app_file('bin/deploy')
|
27
|
+
gsub_file app_file('bin/deploy'), /APPNAMEHERE/, appname.downcase
|
27
28
|
chmod app_file('bin/deploy'), 0755
|
28
29
|
copy_file tpl_file('_deploy'), app_file('bin/_deploy')
|
29
30
|
gsub_file app_file('bin/_deploy'), /APPNAMEHERE/, appname.downcase
|
30
31
|
chmod app_file('bin/_deploy'), 0755
|
31
|
-
gsub_file app_file('bin/deploy'), /APPNAMEHERE/, appname.downcase
|
32
32
|
|
33
33
|
say 'Welcome to AWS Lambda and Rails 🎉', :green
|
@@ -1,3 +1,15 @@
|
|
1
1
|
FROM public.ecr.aws/lambda/ruby:2.7
|
2
|
+
ARG RAILS_ENV
|
3
|
+
ENV RAILS_ENV=$RAILS_ENV
|
4
|
+
|
2
5
|
COPY . .
|
6
|
+
|
7
|
+
# == Cleanup Unused Files & Directories ==
|
8
|
+
RUN rm -rf \
|
9
|
+
log \
|
10
|
+
node_modules \
|
11
|
+
test \
|
12
|
+
tmp \
|
13
|
+
vendor/bundle/ruby/2.7.0/cache
|
14
|
+
|
3
15
|
CMD ["app.handler"]
|
@@ -1,15 +1,18 @@
|
|
1
1
|
FROM amazon/aws-sam-cli-build-image-ruby2.7
|
2
2
|
|
3
3
|
# Ensure minimum required SAM version.
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
ENV SAM_CLI_VERSION=1.23.0
|
5
|
+
RUN curl -L "https://github.com/aws/aws-sam-cli/releases/download/v${SAM_CLI_VERSION}/aws-sam-cli-linux-x86_64.zip" \
|
6
|
+
-o "aws-sam-cli-linux-x86_64.zip" && \
|
7
|
+
unzip -q aws-sam-cli-linux-x86_64.zip -d sam-installation && \
|
8
|
+
./sam-installation/install && \
|
9
|
+
rm -rf ./sam-installation ./aws-sam-cli-linux-x86_64.zip
|
7
10
|
|
8
11
|
# Node for JavaScript.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash - && \
|
13
|
+
yum install -y nodejs && \
|
14
|
+
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \
|
15
|
+
rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg && \
|
16
|
+
yum install -y yarn
|
14
17
|
|
15
18
|
WORKDIR /var/task
|
@@ -1,20 +1,15 @@
|
|
1
|
-
#!/
|
1
|
+
#!/bin/sh
|
2
2
|
set -e
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
cp -r "$SAM_TEMP" "./.lamby/$RESOURCE"
|
11
|
-
pushd "./.lamby/$RESOURCE"
|
12
|
-
|
13
|
-
echo '== Cleaning Dev Dependencies =='
|
14
|
-
rm -rf ./.bundle \
|
15
|
-
./vendor/bundle
|
4
|
+
if [ "$CI" != "true" ]; then
|
5
|
+
echo "== Cleaning dev dependencies for local deploy. Run ./bin/setup again afterward! =="
|
6
|
+
rm -rf ./.bundle \
|
7
|
+
./vendor/bundle \
|
8
|
+
./node_modules
|
9
|
+
fi
|
16
10
|
|
17
11
|
echo '== Bundle For Deployment =='
|
12
|
+
bundle lock --add-platform x86_64-linux
|
18
13
|
bundle config --local deployment true
|
19
14
|
bundle config --local without 'development test'
|
20
15
|
bundle config --local path './vendor/bundle'
|
@@ -27,14 +22,4 @@ echo "== Environments & Configuration =="
|
|
27
22
|
# LAMBY_SSM_PARAMS_PATH="/APPNAMEHERE/${RAILS_ENV}/env"
|
28
23
|
|
29
24
|
echo "== Asset Hosts & Precompiling =="
|
30
|
-
|
31
|
-
# RAILS_GROUPS=assets \
|
32
|
-
# ./bin/rails assets:precompile
|
33
|
-
|
34
|
-
echo "== Cleanup Unused Files & Directories =="
|
35
|
-
rm -rf \
|
36
|
-
log \
|
37
|
-
node_modules \
|
38
|
-
test \
|
39
|
-
tmp \
|
40
|
-
vendor/bundle/ruby/2.7.0/cache
|
25
|
+
NODE_ENV='production' ./bin/rails assets:precompile
|
@@ -1,62 +1,31 @@
|
|
1
|
-
#!/
|
1
|
+
#!/bin/sh
|
2
2
|
set -e
|
3
3
|
|
4
|
-
export DEPLOYMENT_NAME="myorg/APPNAMEHERE"
|
5
|
-
export RAILS_ENV=${RAILS_ENV:="production"}
|
6
|
-
export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
|
7
|
-
export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.${DEPLOYMENT_NAME/\//-}"}
|
8
|
-
|
9
4
|
# https://github.com/aws/aws-sam-cli/issues/2447
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
echo '== Creating ECR repository =='
|
14
|
-
echo 'You can safely ignore any RepositoryAlreadyExistsException errors...'
|
15
|
-
aws ecr create-repository \
|
16
|
-
--repository-name "$DEPLOYMENT_NAME" \
|
17
|
-
--image-tag-mutability MUTABLE \
|
18
|
-
--image-scanning-configuration scanOnPush=true \
|
19
|
-
--region "$AWS_DEFAULT_REGION" || true
|
5
|
+
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
6
|
+
IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/APPNAMEHERE"
|
20
7
|
|
21
|
-
|
8
|
+
echo "== Lamby build =="
|
22
9
|
./bin/_build
|
23
10
|
|
24
|
-
|
25
|
-
aws ec2 describe-vpcs \
|
26
|
-
--output text \
|
27
|
-
--filters 'Name=state,Values=available' \
|
28
|
-
--query 'Vpcs[0].VpcId'
|
29
|
-
)}
|
30
|
-
|
31
|
-
export SUBNETS=${SUBNETS:=$(
|
32
|
-
aws ec2 describe-subnets \
|
33
|
-
--output text \
|
34
|
-
--filters 'Name=state,Values=available' "Name=vpc-id,Values=$VPCID" \
|
35
|
-
--query 'Subnets[*].SubnetId' | \
|
36
|
-
tr -s '[:blank:]' ','
|
37
|
-
)}
|
38
|
-
|
11
|
+
echo "== SAM build =="
|
39
12
|
sam build \
|
40
13
|
--parameter-overrides \
|
41
|
-
|
14
|
+
RailsEnv="${RAILS_ENV}"
|
42
15
|
|
43
|
-
echo "== SAM package
|
16
|
+
echo "== SAM package =="
|
44
17
|
sam package \
|
45
18
|
--region "$AWS_DEFAULT_REGION" \
|
46
19
|
--template-file ./.aws-sam/build/template.yaml \
|
47
20
|
--output-template-file ./.aws-sam/build/packaged.yaml \
|
48
21
|
--image-repository "$IMAGE_REPOSITORY" \
|
49
|
-
--s3-bucket "${CLOUDFORMATION_BUCKET}" \
|
50
|
-
--s3-prefix "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}"
|
51
22
|
|
52
|
-
echo "== SAM deploy
|
23
|
+
echo "== SAM deploy =="
|
53
24
|
sam deploy \
|
54
25
|
--region "$AWS_DEFAULT_REGION" \
|
55
26
|
--template-file ./.aws-sam/build/packaged.yaml \
|
56
|
-
--stack-name "
|
27
|
+
--stack-name "APPNAMEHERE-${RAILS_ENV}" \
|
57
28
|
--image-repository "$IMAGE_REPOSITORY" \
|
58
29
|
--capabilities "CAPABILITY_IAM" \
|
59
30
|
--parameter-overrides \
|
60
|
-
RailsEnv="${RAILS_ENV}"
|
61
|
-
VpcId=${VPCID} \
|
62
|
-
Subnets=${SUBNETS}
|
31
|
+
RailsEnv="${RAILS_ENV}"
|
@@ -1,13 +1,8 @@
|
|
1
|
-
#!/
|
1
|
+
#!/bin/sh
|
2
2
|
set -e
|
3
3
|
|
4
4
|
export RAILS_ENV=${RAILS_ENV:=production}
|
5
5
|
|
6
|
-
if [[ "$OSTYPE" == *"darwin"* ]]; then
|
7
|
-
export SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
|
8
|
-
fi
|
9
|
-
|
10
6
|
docker-compose run \
|
11
|
-
|
12
|
-
|
13
|
-
./bin/_deploy
|
7
|
+
APPNAMEHERE \
|
8
|
+
./bin/_deploy
|
@@ -1,17 +1,19 @@
|
|
1
1
|
version: '3.7'
|
2
2
|
services:
|
3
|
-
|
3
|
+
APPNAMEHERE:
|
4
4
|
build:
|
5
|
-
context: .
|
5
|
+
context: '.'
|
6
6
|
dockerfile: Dockerfile-build
|
7
|
+
entrypoint: ./bin/entrypoint
|
7
8
|
environment:
|
8
9
|
- RAILS_ENV=${RAILS_ENV-development}
|
10
|
+
- SAM_CLI_TELEMETRY=0
|
9
11
|
- AWS_PROFILE=${AWS_PROFILE-default}
|
12
|
+
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
|
13
|
+
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
|
10
14
|
- AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION-us-east-1}
|
11
|
-
-
|
15
|
+
- CI=${CI}
|
12
16
|
volumes:
|
13
|
-
- ${
|
14
|
-
-
|
15
|
-
- ~/.ssh/known_hosts:/root/.ssh/known_hosts
|
16
|
-
- .:/var/task:delegated
|
17
|
+
- ${PWD}:/var/task
|
18
|
+
- ${HOME}/.aws:/root/.aws
|
17
19
|
- /var/run/docker.sock:/var/run/docker.sock
|
data/lib/lamby/templates/http.rb
CHANGED
@@ -10,13 +10,13 @@ gsub_file app_file('template.yaml'), /APPNAMEHERE/, appname
|
|
10
10
|
copy_file tpl_file('Dockerfile'), app_file('Dockerfile')
|
11
11
|
copy_file tpl_file('Dockerfile-build'), app_file('Dockerfile-build')
|
12
12
|
copy_file tpl_file('docker-compose.yml'), app_file('docker-compose.yml')
|
13
|
+
gsub_file app_file('docker-compose.yml'), /APPNAMEHERE/, appname.downcase
|
13
14
|
|
14
15
|
say 'Adding to .gitignore...'
|
15
16
|
FileUtils.touch app_file('.gitignore')
|
16
17
|
append_to_file app_file('.gitignore'), <<~GITIGNORE
|
17
18
|
# Lamby
|
18
19
|
/.aws-sam
|
19
|
-
/.lamby
|
20
20
|
GITIGNORE
|
21
21
|
|
22
22
|
say 'Creating ./bin files for build and deploy...'
|
@@ -24,10 +24,10 @@ copy_file tpl_file('_build'), app_file('bin/_build')
|
|
24
24
|
gsub_file app_file('bin/_build'), /APPNAMEHERE/, appname.downcase
|
25
25
|
chmod app_file('bin/_build'), 0755
|
26
26
|
copy_file tpl_file('deploy'), app_file('bin/deploy')
|
27
|
+
gsub_file app_file('bin/deploy'), /APPNAMEHERE/, appname.downcase
|
27
28
|
chmod app_file('bin/deploy'), 0755
|
28
29
|
copy_file tpl_file('_deploy'), app_file('bin/_deploy')
|
29
30
|
gsub_file app_file('bin/_deploy'), /APPNAMEHERE/, appname.downcase
|
30
31
|
chmod app_file('bin/_deploy'), 0755
|
31
|
-
gsub_file app_file('bin/deploy'), /APPNAMEHERE/, appname.downcase
|
32
32
|
|
33
33
|
say 'Welcome to AWS Lambda and Rails 🎉', :green
|
@@ -1,3 +1,15 @@
|
|
1
1
|
FROM public.ecr.aws/lambda/ruby:2.7
|
2
|
+
ARG RAILS_ENV
|
3
|
+
ENV RAILS_ENV=$RAILS_ENV
|
4
|
+
|
2
5
|
COPY . .
|
6
|
+
|
7
|
+
# == Cleanup Unused Files & Directories ==
|
8
|
+
RUN rm -rf \
|
9
|
+
log \
|
10
|
+
node_modules \
|
11
|
+
test \
|
12
|
+
tmp \
|
13
|
+
vendor/bundle/ruby/2.7.0/cache
|
14
|
+
|
3
15
|
CMD ["app.handler"]
|
@@ -1,15 +1,18 @@
|
|
1
1
|
FROM amazon/aws-sam-cli-build-image-ruby2.7
|
2
2
|
|
3
3
|
# Ensure minimum required SAM version.
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
ENV SAM_CLI_VERSION=1.23.0
|
5
|
+
RUN curl -L "https://github.com/aws/aws-sam-cli/releases/download/v${SAM_CLI_VERSION}/aws-sam-cli-linux-x86_64.zip" \
|
6
|
+
-o "aws-sam-cli-linux-x86_64.zip" && \
|
7
|
+
unzip -q aws-sam-cli-linux-x86_64.zip -d sam-installation && \
|
8
|
+
./sam-installation/install && \
|
9
|
+
rm -rf ./sam-installation ./aws-sam-cli-linux-x86_64.zip
|
7
10
|
|
8
11
|
# Node for JavaScript.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash - && \
|
13
|
+
yum install -y nodejs && \
|
14
|
+
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \
|
15
|
+
rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg && \
|
16
|
+
yum install -y yarn
|
14
17
|
|
15
18
|
WORKDIR /var/task
|
@@ -1,20 +1,15 @@
|
|
1
|
-
#!/
|
1
|
+
#!/bin/sh
|
2
2
|
set -e
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
cp -r "$SAM_TEMP" "./.lamby/$RESOURCE"
|
11
|
-
pushd "./.lamby/$RESOURCE"
|
12
|
-
|
13
|
-
echo '== Cleaning Dev Dependencies =='
|
14
|
-
rm -rf ./.bundle \
|
15
|
-
./vendor/bundle
|
4
|
+
if [ "$CI" != "true" ]; then
|
5
|
+
echo "== Cleaning dev dependencies for local deploy. Run ./bin/setup again afterward! =="
|
6
|
+
rm -rf ./.bundle \
|
7
|
+
./vendor/bundle \
|
8
|
+
./node_modules
|
9
|
+
fi
|
16
10
|
|
17
11
|
echo '== Bundle For Deployment =='
|
12
|
+
bundle lock --add-platform x86_64-linux
|
18
13
|
bundle config --local deployment true
|
19
14
|
bundle config --local without 'development test'
|
20
15
|
bundle config --local path './vendor/bundle'
|
@@ -27,14 +22,4 @@ echo "== Environments & Configuration =="
|
|
27
22
|
# LAMBY_SSM_PARAMS_PATH="/APPNAMEHERE/${RAILS_ENV}/env"
|
28
23
|
|
29
24
|
echo "== Asset Hosts & Precompiling =="
|
30
|
-
|
31
|
-
# RAILS_GROUPS=assets \
|
32
|
-
# ./bin/rails assets:precompile
|
33
|
-
|
34
|
-
echo "== Cleanup Unused Files & Directories =="
|
35
|
-
rm -rf \
|
36
|
-
log \
|
37
|
-
node_modules \
|
38
|
-
test \
|
39
|
-
tmp \
|
40
|
-
vendor/bundle/ruby/2.7.0/cache
|
25
|
+
NODE_ENV='production' ./bin/rails assets:precompile
|
@@ -1,44 +1,30 @@
|
|
1
|
-
#!/
|
1
|
+
#!/bin/sh
|
2
2
|
set -e
|
3
3
|
|
4
|
-
export DEPLOYMENT_NAME="myorg/APPNAMEHERE"
|
5
|
-
export RAILS_ENV=${RAILS_ENV:="production"}
|
6
|
-
export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
|
7
|
-
export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.${DEPLOYMENT_NAME/\//-}"}
|
8
|
-
|
9
4
|
# https://github.com/aws/aws-sam-cli/issues/2447
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
echo '== Creating ECR repository =='
|
14
|
-
echo 'You can safely ignore any RepositoryAlreadyExistsException errors...'
|
15
|
-
aws ecr create-repository \
|
16
|
-
--repository-name "$DEPLOYMENT_NAME" \
|
17
|
-
--image-tag-mutability MUTABLE \
|
18
|
-
--image-scanning-configuration scanOnPush=true \
|
19
|
-
--region "$AWS_DEFAULT_REGION" || true
|
5
|
+
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
6
|
+
IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/APPNAMEHERE"
|
20
7
|
|
21
|
-
|
8
|
+
echo "== Lamby build =="
|
22
9
|
./bin/_build
|
23
10
|
|
11
|
+
echo "== SAM build =="
|
24
12
|
sam build \
|
25
13
|
--parameter-overrides \
|
26
|
-
|
14
|
+
RailsEnv="${RAILS_ENV}"
|
27
15
|
|
28
|
-
echo "== SAM package
|
16
|
+
echo "== SAM package =="
|
29
17
|
sam package \
|
30
18
|
--region "$AWS_DEFAULT_REGION" \
|
31
19
|
--template-file ./.aws-sam/build/template.yaml \
|
32
20
|
--output-template-file ./.aws-sam/build/packaged.yaml \
|
33
21
|
--image-repository "$IMAGE_REPOSITORY" \
|
34
|
-
--s3-bucket "${CLOUDFORMATION_BUCKET}" \
|
35
|
-
--s3-prefix "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}"
|
36
22
|
|
37
|
-
echo "== SAM deploy
|
23
|
+
echo "== SAM deploy =="
|
38
24
|
sam deploy \
|
39
25
|
--region "$AWS_DEFAULT_REGION" \
|
40
26
|
--template-file ./.aws-sam/build/packaged.yaml \
|
41
|
-
--stack-name "
|
27
|
+
--stack-name "APPNAMEHERE-${RAILS_ENV}" \
|
42
28
|
--image-repository "$IMAGE_REPOSITORY" \
|
43
29
|
--capabilities "CAPABILITY_IAM" \
|
44
30
|
--parameter-overrides \
|
@@ -1,13 +1,8 @@
|
|
1
|
-
#!/
|
1
|
+
#!/bin/sh
|
2
2
|
set -e
|
3
3
|
|
4
4
|
export RAILS_ENV=${RAILS_ENV:=production}
|
5
5
|
|
6
|
-
if [[ "$OSTYPE" == *"darwin"* ]]; then
|
7
|
-
export SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
|
8
|
-
fi
|
9
|
-
|
10
6
|
docker-compose run \
|
11
|
-
|
12
|
-
|
13
|
-
./bin/_deploy
|
7
|
+
APPNAMEHERE \
|
8
|
+
./bin/_deploy
|
@@ -1,17 +1,19 @@
|
|
1
1
|
version: '3.7'
|
2
2
|
services:
|
3
|
-
|
3
|
+
APPNAMEHERE:
|
4
4
|
build:
|
5
|
-
context: .
|
5
|
+
context: '.'
|
6
6
|
dockerfile: Dockerfile-build
|
7
|
+
entrypoint: ./bin/entrypoint
|
7
8
|
environment:
|
8
9
|
- RAILS_ENV=${RAILS_ENV-development}
|
10
|
+
- SAM_CLI_TELEMETRY=0
|
9
11
|
- AWS_PROFILE=${AWS_PROFILE-default}
|
12
|
+
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
|
13
|
+
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
|
10
14
|
- AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION-us-east-1}
|
11
|
-
-
|
15
|
+
- CI=${CI}
|
12
16
|
volumes:
|
13
|
-
- ${
|
14
|
-
-
|
15
|
-
- ~/.ssh/known_hosts:/root/.ssh/known_hosts
|
16
|
-
- .:/var/task:delegated
|
17
|
+
- ${PWD}:/var/task
|
18
|
+
- ${HOME}/.aws:/root/.aws
|
17
19
|
- /var/run/docker.sock:/var/run/docker.sock
|
data/lib/lamby/templates/rest.rb
CHANGED
@@ -10,13 +10,13 @@ gsub_file app_file('template.yaml'), /APPNAMEHERE/, appname
|
|
10
10
|
copy_file tpl_file('Dockerfile'), app_file('Dockerfile')
|
11
11
|
copy_file tpl_file('Dockerfile-build'), app_file('Dockerfile-build')
|
12
12
|
copy_file tpl_file('docker-compose.yml'), app_file('docker-compose.yml')
|
13
|
+
gsub_file app_file('docker-compose.yml'), /APPNAMEHERE/, appname.downcase
|
13
14
|
|
14
15
|
say 'Adding to .gitignore...'
|
15
16
|
FileUtils.touch app_file('.gitignore')
|
16
17
|
append_to_file app_file('.gitignore'), <<~GITIGNORE
|
17
18
|
# Lamby
|
18
19
|
/.aws-sam
|
19
|
-
/.lamby
|
20
20
|
GITIGNORE
|
21
21
|
|
22
22
|
say 'Creating ./bin files for build and deploy...'
|
@@ -24,10 +24,10 @@ copy_file tpl_file('_build'), app_file('bin/_build')
|
|
24
24
|
gsub_file app_file('bin/_build'), /APPNAMEHERE/, appname.downcase
|
25
25
|
chmod app_file('bin/_build'), 0755
|
26
26
|
copy_file tpl_file('deploy'), app_file('bin/deploy')
|
27
|
+
gsub_file app_file('bin/deploy'), /APPNAMEHERE/, appname.downcase
|
27
28
|
chmod app_file('bin/deploy'), 0755
|
28
29
|
copy_file tpl_file('_deploy'), app_file('bin/_deploy')
|
29
30
|
gsub_file app_file('bin/_deploy'), /APPNAMEHERE/, appname.downcase
|
30
31
|
chmod app_file('bin/_deploy'), 0755
|
31
|
-
gsub_file app_file('bin/deploy'), /APPNAMEHERE/, appname.downcase
|
32
32
|
|
33
33
|
say 'Welcome to AWS Lambda and Rails 🎉', :green
|
@@ -1,3 +1,15 @@
|
|
1
1
|
FROM public.ecr.aws/lambda/ruby:2.7
|
2
|
+
ARG RAILS_ENV
|
3
|
+
ENV RAILS_ENV=$RAILS_ENV
|
4
|
+
|
2
5
|
COPY . .
|
6
|
+
|
7
|
+
# == Cleanup Unused Files & Directories ==
|
8
|
+
RUN rm -rf \
|
9
|
+
log \
|
10
|
+
node_modules \
|
11
|
+
test \
|
12
|
+
tmp \
|
13
|
+
vendor/bundle/ruby/2.7.0/cache
|
14
|
+
|
3
15
|
CMD ["app.handler"]
|
@@ -1,15 +1,18 @@
|
|
1
1
|
FROM amazon/aws-sam-cli-build-image-ruby2.7
|
2
2
|
|
3
3
|
# Ensure minimum required SAM version.
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
ENV SAM_CLI_VERSION=1.23.0
|
5
|
+
RUN curl -L "https://github.com/aws/aws-sam-cli/releases/download/v${SAM_CLI_VERSION}/aws-sam-cli-linux-x86_64.zip" \
|
6
|
+
-o "aws-sam-cli-linux-x86_64.zip" && \
|
7
|
+
unzip -q aws-sam-cli-linux-x86_64.zip -d sam-installation && \
|
8
|
+
./sam-installation/install && \
|
9
|
+
rm -rf ./sam-installation ./aws-sam-cli-linux-x86_64.zip
|
7
10
|
|
8
11
|
# Node for JavaScript.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash - && \
|
13
|
+
yum install -y nodejs && \
|
14
|
+
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \
|
15
|
+
rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg && \
|
16
|
+
yum install -y yarn
|
14
17
|
|
15
18
|
WORKDIR /var/task
|
@@ -1,20 +1,15 @@
|
|
1
|
-
#!/
|
1
|
+
#!/bin/sh
|
2
2
|
set -e
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
cp -r "$SAM_TEMP" "./.lamby/$RESOURCE"
|
11
|
-
pushd "./.lamby/$RESOURCE"
|
12
|
-
|
13
|
-
echo '== Cleaning Dev Dependencies =='
|
14
|
-
rm -rf ./.bundle \
|
15
|
-
./vendor/bundle
|
4
|
+
if [ "$CI" != "true" ]; then
|
5
|
+
echo "== Cleaning dev dependencies for local deploy. Run ./bin/setup again afterward! =="
|
6
|
+
rm -rf ./.bundle \
|
7
|
+
./vendor/bundle \
|
8
|
+
./node_modules
|
9
|
+
fi
|
16
10
|
|
17
11
|
echo '== Bundle For Deployment =='
|
12
|
+
bundle lock --add-platform x86_64-linux
|
18
13
|
bundle config --local deployment true
|
19
14
|
bundle config --local without 'development test'
|
20
15
|
bundle config --local path './vendor/bundle'
|
@@ -27,14 +22,4 @@ echo "== Environments & Configuration =="
|
|
27
22
|
# LAMBY_SSM_PARAMS_PATH="/APPNAMEHERE/${RAILS_ENV}/env"
|
28
23
|
|
29
24
|
echo "== Asset Hosts & Precompiling =="
|
30
|
-
|
31
|
-
# RAILS_GROUPS=assets \
|
32
|
-
# ./bin/rails assets:precompile
|
33
|
-
|
34
|
-
echo "== Cleanup Unused Files & Directories =="
|
35
|
-
rm -rf \
|
36
|
-
log \
|
37
|
-
node_modules \
|
38
|
-
test \
|
39
|
-
tmp \
|
40
|
-
vendor/bundle/ruby/2.7.0/cache
|
25
|
+
NODE_ENV='production' ./bin/rails assets:precompile
|
@@ -1,44 +1,30 @@
|
|
1
|
-
#!/
|
1
|
+
#!/bin/sh
|
2
2
|
set -e
|
3
3
|
|
4
|
-
export DEPLOYMENT_NAME="myorg/APPNAMEHERE"
|
5
|
-
export RAILS_ENV=${RAILS_ENV:="production"}
|
6
|
-
export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
|
7
|
-
export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.${DEPLOYMENT_NAME/\//-}"}
|
8
|
-
|
9
4
|
# https://github.com/aws/aws-sam-cli/issues/2447
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
echo '== Creating ECR repository =='
|
14
|
-
echo 'You can safely ignore any RepositoryAlreadyExistsException errors...'
|
15
|
-
aws ecr create-repository \
|
16
|
-
--repository-name "$DEPLOYMENT_NAME" \
|
17
|
-
--image-tag-mutability MUTABLE \
|
18
|
-
--image-scanning-configuration scanOnPush=true \
|
19
|
-
--region "$AWS_DEFAULT_REGION" || true
|
5
|
+
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
6
|
+
IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/APPNAMEHERE"
|
20
7
|
|
21
|
-
|
8
|
+
echo "== Lamby build =="
|
22
9
|
./bin/_build
|
23
10
|
|
11
|
+
echo "== SAM build =="
|
24
12
|
sam build \
|
25
13
|
--parameter-overrides \
|
26
|
-
|
14
|
+
RailsEnv="${RAILS_ENV}"
|
27
15
|
|
28
|
-
echo "== SAM package
|
16
|
+
echo "== SAM package =="
|
29
17
|
sam package \
|
30
18
|
--region "$AWS_DEFAULT_REGION" \
|
31
19
|
--template-file ./.aws-sam/build/template.yaml \
|
32
20
|
--output-template-file ./.aws-sam/build/packaged.yaml \
|
33
21
|
--image-repository "$IMAGE_REPOSITORY" \
|
34
|
-
--s3-bucket "${CLOUDFORMATION_BUCKET}" \
|
35
|
-
--s3-prefix "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}"
|
36
22
|
|
37
|
-
echo "== SAM deploy
|
23
|
+
echo "== SAM deploy =="
|
38
24
|
sam deploy \
|
39
25
|
--region "$AWS_DEFAULT_REGION" \
|
40
26
|
--template-file ./.aws-sam/build/packaged.yaml \
|
41
|
-
--stack-name "
|
27
|
+
--stack-name "APPNAMEHERE-${RAILS_ENV}" \
|
42
28
|
--image-repository "$IMAGE_REPOSITORY" \
|
43
29
|
--capabilities "CAPABILITY_IAM" \
|
44
30
|
--parameter-overrides \
|
@@ -1,13 +1,8 @@
|
|
1
|
-
#!/
|
1
|
+
#!/bin/sh
|
2
2
|
set -e
|
3
3
|
|
4
4
|
export RAILS_ENV=${RAILS_ENV:=production}
|
5
5
|
|
6
|
-
if [[ "$OSTYPE" == *"darwin"* ]]; then
|
7
|
-
export SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
|
8
|
-
fi
|
9
|
-
|
10
6
|
docker-compose run \
|
11
|
-
|
12
|
-
|
13
|
-
./bin/_deploy
|
7
|
+
APPNAMEHERE \
|
8
|
+
./bin/_deploy
|
@@ -1,17 +1,19 @@
|
|
1
1
|
version: '3.7'
|
2
2
|
services:
|
3
|
-
|
3
|
+
APPNAMEHERE:
|
4
4
|
build:
|
5
|
-
context: .
|
5
|
+
context: '.'
|
6
6
|
dockerfile: Dockerfile-build
|
7
|
+
entrypoint: ./bin/entrypoint
|
7
8
|
environment:
|
8
9
|
- RAILS_ENV=${RAILS_ENV-development}
|
10
|
+
- SAM_CLI_TELEMETRY=0
|
9
11
|
- AWS_PROFILE=${AWS_PROFILE-default}
|
12
|
+
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
|
13
|
+
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
|
10
14
|
- AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION-us-east-1}
|
11
|
-
-
|
15
|
+
- CI=${CI}
|
12
16
|
volumes:
|
13
|
-
- ${
|
14
|
-
-
|
15
|
-
- ~/.ssh/known_hosts:/root/.ssh/known_hosts
|
16
|
-
- .:/var/task:delegated
|
17
|
+
- ${PWD}:/var/task
|
18
|
+
- ${HOME}/.aws:/root/.aws
|
17
19
|
- /var/run/docker.sock:/var/run/docker.sock
|
data/lib/lamby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lamby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Collins
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- docker-compose.yml
|
151
151
|
- lamby.gemspec
|
152
152
|
- lib/lamby.rb
|
153
|
+
- lib/lamby/config.rb
|
153
154
|
- lib/lamby/debug.rb
|
154
155
|
- lib/lamby/handler.rb
|
155
156
|
- lib/lamby/logger.rb
|
@@ -158,6 +159,7 @@ files:
|
|
158
159
|
- lib/lamby/rack_http.rb
|
159
160
|
- lib/lamby/rack_rest.rb
|
160
161
|
- lib/lamby/railtie.rb
|
162
|
+
- lib/lamby/runner.rb
|
161
163
|
- lib/lamby/sam_helpers.rb
|
162
164
|
- lib/lamby/ssm_parameter_store.rb
|
163
165
|
- lib/lamby/tasks.rake
|