shark-on-lambda 0.6.10 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/push-gem.yml +67 -0
- data/.github/workflows/tests.yml +32 -0
- data/README.md +10 -12
- data/changelog.md +11 -0
- data/gems.locked +73 -23
- data/lib/shark_on_lambda/api_gateway_handler.rb +61 -0
- data/lib/shark_on_lambda/application.rb +17 -0
- data/lib/shark_on_lambda/base_controller.rb +50 -0
- data/lib/shark_on_lambda/configuration.rb +9 -1
- data/lib/shark_on_lambda/dispatcher.rb +26 -0
- data/lib/shark_on_lambda/errors/base.rb +47 -0
- data/lib/shark_on_lambda/errors/base_serializer.rb +18 -0
- data/lib/shark_on_lambda/jsonapi_controller.rb +29 -0
- data/lib/shark_on_lambda/jsonapi_parameters.rb +66 -0
- data/lib/shark_on_lambda/jsonapi_renderer.rb +115 -0
- data/lib/shark_on_lambda/middleware/base.rb +23 -0
- data/lib/shark_on_lambda/middleware/jsonapi_rescuer.rb +31 -0
- data/lib/shark_on_lambda/middleware/rescuer.rb +38 -0
- data/lib/shark_on_lambda/query.rb +67 -0
- data/lib/shark_on_lambda/rack_adapters/api_gateway.rb +127 -0
- data/lib/shark_on_lambda/request.rb +9 -0
- data/lib/shark_on_lambda/response.rb +6 -0
- data/lib/shark_on_lambda/rspec/env_builder.rb +64 -0
- data/lib/shark_on_lambda/rspec/helpers.rb +84 -0
- data/lib/shark_on_lambda/rspec/jsonapi_helpers.rb +27 -0
- data/lib/shark_on_lambda/version.rb +1 -1
- data/lib/shark_on_lambda.rb +25 -28
- data/shark-on-lambda.gemspec +8 -3
- metadata +104 -24
- data/.gitlab-ci.yml +0 -39
- data/.travis.yml +0 -14
- data/lib/shark_on_lambda/api_gateway/base_controller.rb +0 -76
- data/lib/shark_on_lambda/api_gateway/base_handler.rb +0 -82
- data/lib/shark_on_lambda/api_gateway/concerns/http_response_validation.rb +0 -61
- data/lib/shark_on_lambda/api_gateway/errors.rb +0 -49
- data/lib/shark_on_lambda/api_gateway/headers.rb +0 -37
- data/lib/shark_on_lambda/api_gateway/jsonapi_controller.rb +0 -77
- data/lib/shark_on_lambda/api_gateway/jsonapi_parameters.rb +0 -68
- data/lib/shark_on_lambda/api_gateway/jsonapi_renderer.rb +0 -105
- data/lib/shark_on_lambda/api_gateway/parameters.rb +0 -18
- data/lib/shark_on_lambda/api_gateway/query.rb +0 -69
- data/lib/shark_on_lambda/api_gateway/request.rb +0 -148
- data/lib/shark_on_lambda/api_gateway/response.rb +0 -82
- data/lib/shark_on_lambda/api_gateway/serializers/base_error_serializer.rb +0 -20
- data/lib/shark_on_lambda/concerns/filter_actions.rb +0 -93
- data/lib/shark_on_lambda/tasks/build.rake +0 -146
- data/lib/shark_on_lambda/tasks.rb +0 -3
@@ -1,146 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'shark-on-lambda'
|
4
|
-
|
5
|
-
class DockerContainer
|
6
|
-
attr_reader :project_dir, :tag
|
7
|
-
attr_accessor :params, :commands
|
8
|
-
|
9
|
-
def initialize(project_dir:, tag: 'latest')
|
10
|
-
@project_dir = project_dir
|
11
|
-
@tag = tag
|
12
|
-
@params = default_params
|
13
|
-
@commands = default_commands
|
14
|
-
end
|
15
|
-
|
16
|
-
def build
|
17
|
-
sh("cd #{project_dir} && docker build . -t #{name}")
|
18
|
-
end
|
19
|
-
|
20
|
-
def exist?
|
21
|
-
system("docker image inspect #{name} &> /dev/null")
|
22
|
-
end
|
23
|
-
|
24
|
-
def mount_dir
|
25
|
-
File.join('/src', project_name)
|
26
|
-
end
|
27
|
-
|
28
|
-
def name
|
29
|
-
"#{project_name}-builder:#{tag}"
|
30
|
-
end
|
31
|
-
|
32
|
-
def remove
|
33
|
-
sh("docker image rm #{name}")
|
34
|
-
end
|
35
|
-
|
36
|
-
def run
|
37
|
-
arguments = params.join(' ')
|
38
|
-
command = commands.join(' && ')
|
39
|
-
|
40
|
-
sh(%(docker run #{arguments} #{name} /bin/bash -c "#{command}"))
|
41
|
-
end
|
42
|
-
|
43
|
-
def working_dir
|
44
|
-
File.join('/tmp', project_name)
|
45
|
-
end
|
46
|
-
|
47
|
-
protected
|
48
|
-
|
49
|
-
def default_commands
|
50
|
-
[
|
51
|
-
"cp -a #{mount_dir} #{working_dir}",
|
52
|
-
"cd #{working_dir}"
|
53
|
-
]
|
54
|
-
end
|
55
|
-
|
56
|
-
def default_params
|
57
|
-
[
|
58
|
-
'--rm',
|
59
|
-
"-v #{project_dir}:#{mount_dir}"
|
60
|
-
]
|
61
|
-
end
|
62
|
-
|
63
|
-
def project_name
|
64
|
-
File.basename(project_dir)
|
65
|
-
end
|
66
|
-
|
67
|
-
def sh(command)
|
68
|
-
puts command
|
69
|
-
system(command)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def build_stage(stage)
|
74
|
-
container = DockerContainer.new(project_dir: SharkOnLambda.root)
|
75
|
-
Rake::Task['docker:build'].invoke unless container.exist?
|
76
|
-
|
77
|
-
container.commands += build_commands(container, stage: stage)
|
78
|
-
container.run
|
79
|
-
end
|
80
|
-
|
81
|
-
def deploy_stage(stage)
|
82
|
-
deploy_command = deploy_commands(stage: stage).join(' && ')
|
83
|
-
sh(deploy_command)
|
84
|
-
end
|
85
|
-
|
86
|
-
def remove_stage(stage)
|
87
|
-
sh("sls remove -v -s #{stage}")
|
88
|
-
end
|
89
|
-
|
90
|
-
namespace :docker do
|
91
|
-
container = DockerContainer.new(project_dir: SharkOnLambda.root)
|
92
|
-
|
93
|
-
desc 'Build the Docker container required for... building.'
|
94
|
-
task :build do
|
95
|
-
container.build
|
96
|
-
end
|
97
|
-
|
98
|
-
desc 'Remove the Docker container required for building.'
|
99
|
-
task :remove do
|
100
|
-
container.remove
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
%i[integration staging production].each do |stage|
|
105
|
-
namespace :build do
|
106
|
-
desc "Build this service for the '#{stage}' stage."
|
107
|
-
task stage => [:clean] do
|
108
|
-
build_stage(stage)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
namespace :deploy do
|
113
|
-
desc "Deploy this service to the '#{stage}' stage."
|
114
|
-
task stage => ["build:#{stage}"] do
|
115
|
-
deploy_stage(stage)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
namespace :remove do
|
120
|
-
desc "Remove this service from the '#{stage}' stage."
|
121
|
-
task stage do
|
122
|
-
remove_stage(stage)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
desc 'Build this service for STAGE.'
|
128
|
-
task :build, [:stage] => [:clean] do |_, args|
|
129
|
-
build_stage(args.stage)
|
130
|
-
end
|
131
|
-
|
132
|
-
desc 'Remove package build directory.'
|
133
|
-
task :clean do
|
134
|
-
package_dir = SharkOnLambda.root.join('pkg')
|
135
|
-
FileUtils.rm_rf(package_dir)
|
136
|
-
end
|
137
|
-
|
138
|
-
desc 'Deploy this service to STAGE.'
|
139
|
-
task :deploy, [:stage] => [:build] do |_, args|
|
140
|
-
deploy_stage(args.stage)
|
141
|
-
end
|
142
|
-
|
143
|
-
desc 'Remove this service from STAGE.'
|
144
|
-
task :remove, [:stage] do |_, args|
|
145
|
-
remove_stage(args.stage)
|
146
|
-
end
|