brut 0.20.2 → 0.21.0.pre.1
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/lib/brut/cli/apps/deploy/deploy_config.rb +62 -0
- data/lib/brut/cli/apps/deploy/git_checks.rb +54 -0
- data/lib/brut/cli/apps/deploy.rb +275 -304
- data/lib/brut/cli/apps/new/add_segment.rb +5 -0
- data/lib/brut/cli/apps/new/app.rb +10 -0
- data/lib/brut/cli/apps/new/segments/docker_deploy.rb +30 -0
- data/lib/brut/cli/apps/new/segments/sidekiq.rb +8 -8
- data/lib/brut/cli/apps/new/segments.rb +1 -0
- data/lib/brut/cli/commands/base_command.rb +6 -2
- data/lib/brut/framework/app.rb +2 -1
- data/lib/brut/framework/config.rb +13 -1
- data/lib/brut/framework/mcp.rb +1 -4
- data/lib/brut/front_end/csrf_protector.rb +10 -6
- data/lib/brut/front_end/handlers/instrumentation_handler.rb +1 -1
- data/lib/brut/front_end/middlewares/annotate_brut_owned_paths.rb +2 -0
- data/lib/brut/front_end/routing.rb +22 -0
- data/lib/brut/instrumentation/open_telemetry.rb +5 -0
- data/lib/brut/sinatra_helpers.rb +16 -4
- data/lib/brut/spec_support/cli_command_support.rb +60 -7
- data/lib/brut/spec_support/matchers/have_executed.rb +2 -0
- data/lib/brut/version.rb +1 -1
- data/templates/Base/dx/exec +10 -3
- data/templates/segments/DockerDeploy/deploy/Dockerfile +126 -0
- data/templates/segments/DockerDeploy/deploy/deploy_config.rb +17 -0
- data/templates/segments/DockerDeploy/deploy/docker-entrypoint +15 -0
- data/templates/segments/Heroku/deploy/deploy_config.rb +21 -0
- metadata +8 -3
- data/lib/brut/cli/apps/new/old_app.rb +0 -81
- data/templates/segments/Heroku/deploy/docker_config.rb +0 -30
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 465fa110056a12dd5c33e2fac0754dfbba25c5928f23e4fb08f3f5976cf9a384
|
|
4
|
+
data.tar.gz: 3c6598da1ce0bf9e2655c56fb4edce22293a90d98cfef9cab855df210e5964fb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 183335e5d4fc53b5d30ac5eb1c783bad929b782860d2de117ece54e1ac26e96f52466bfd36e8fc26d6e7209a1a88c8337e08a1c3cc30091ed5687baad063c137
|
|
7
|
+
data.tar.gz: 4c744e3e2d7f8c6e02d6ed6f3f0192af1184fea1aa4ccc66e068a68bade6ed0a4abf03b2a8a2562991dd39b1e4cad840bd3e28251ef0ab48c7cb8c6bc1cba100
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Describes your app's need for deployment, which can drive
|
|
2
|
+
# the automatic deploy system. You must subclass this in
|
|
3
|
+
# deploy/deploy_config.rb. This class is used in a somewhat
|
|
4
|
+
# isolated environment, so you will not have access to your
|
|
5
|
+
# app's Brut configuration or any of your app's code.
|
|
6
|
+
# To say it another way, this is a way to store
|
|
7
|
+
# configuration information without having to use YAML. You're welcome.
|
|
8
|
+
class Brut::CLI::Apps::Deploy::DeployConfig
|
|
9
|
+
|
|
10
|
+
# Override this to push to another registory
|
|
11
|
+
def registry_hostname = nil
|
|
12
|
+
|
|
13
|
+
# Returns the Docker platform for which the images should be built
|
|
14
|
+
def platform = "linux/amd64"
|
|
15
|
+
|
|
16
|
+
# Returns a hash where each key is the name of a process
|
|
17
|
+
# you wish to run, other than the default, 'web'.
|
|
18
|
+
# The keys are largely arbitrary and for documentation purposes,
|
|
19
|
+
# however you are advised to make them ASCII alphanumerics only
|
|
20
|
+
# with no whitespace.
|
|
21
|
+
#
|
|
22
|
+
# The values of each key should be an instance `ProcessDescription`.
|
|
23
|
+
#
|
|
24
|
+
# @example Running Sidekiq
|
|
25
|
+
#
|
|
26
|
+
# class AppDeployConfig < Brut::CLI::Apps::Deploy::DeployConfig
|
|
27
|
+
# def additional_processes = [
|
|
28
|
+
# ProcessDescription.new(name: "sidekiq", cmd: "bin/run sidekiq")
|
|
29
|
+
# ]
|
|
30
|
+
# end
|
|
31
|
+
#
|
|
32
|
+
#
|
|
33
|
+
def additional_processes = []
|
|
34
|
+
|
|
35
|
+
# Returns all processes this app needs in production.
|
|
36
|
+
# Generally, do not override this since it configures your
|
|
37
|
+
# web process. Override {#additional_processes} instead.
|
|
38
|
+
def processes = [
|
|
39
|
+
process_description("web", ["bundle", "exec", "bin/run"])
|
|
40
|
+
] + (additional_processes || [])
|
|
41
|
+
|
|
42
|
+
private def process_description(name,cmd)
|
|
43
|
+
ProcessDescription.new(name:, cmd:)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# Describes a process you wish to run in production.
|
|
48
|
+
class ProcessDescription
|
|
49
|
+
|
|
50
|
+
attr_reader :name, :cmd
|
|
51
|
+
|
|
52
|
+
def initialize(name:, cmd:)
|
|
53
|
+
@name = name
|
|
54
|
+
@cmd = Array(cmd)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def cmd_directive
|
|
58
|
+
"CMD [ " + @cmd.map { "\"#{it}\"" }.join(", ") + " ]"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
class Brut::CLI::Apps::Deploy::GitChecks
|
|
2
|
+
def initialize(executor:)
|
|
3
|
+
@executor = executor
|
|
4
|
+
end
|
|
5
|
+
class Results
|
|
6
|
+
attr_reader :errors
|
|
7
|
+
def initialize(errors = {})
|
|
8
|
+
@errors = errors
|
|
9
|
+
end
|
|
10
|
+
def errors? = errors.any?
|
|
11
|
+
end
|
|
12
|
+
def check!
|
|
13
|
+
branch = ""
|
|
14
|
+
@executor.system!("git branch --show-current") do |output|
|
|
15
|
+
branch << output
|
|
16
|
+
end
|
|
17
|
+
branch = branch.strip.chomp
|
|
18
|
+
if branch != "main"
|
|
19
|
+
return Results.new("main-branch" => "You are on branch '#{branch}', but should be on branch 'main'")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
@executor.system!("git status") do |*| # reset local caches to account for Docker/host wierdness
|
|
23
|
+
# ignore
|
|
24
|
+
end
|
|
25
|
+
local_changes = ""
|
|
26
|
+
@executor.system!("git diff-index --name-only HEAD --") do |output|
|
|
27
|
+
local_changes << output
|
|
28
|
+
end
|
|
29
|
+
if local_changes.strip != ""
|
|
30
|
+
return Results.new("local-changes" => "The following files have not been checked in: #{local_changes}")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
rev_list = ""
|
|
34
|
+
@executor.system!("git rev-list --left-right --count origin/main...main") do |output|
|
|
35
|
+
rev_list << output
|
|
36
|
+
end
|
|
37
|
+
remote_ahead, local_ahead = rev_list.strip.chomp.split(/\t/,2).map(&:to_i)
|
|
38
|
+
if remote_ahead != 0
|
|
39
|
+
if remote_ahead == 1
|
|
40
|
+
return Results.new("remote-ahead" => "There is 1 commit in origin you don't have")
|
|
41
|
+
else
|
|
42
|
+
return Results.new("remote-ahead" => "There are #{remote_ahead} commits in origin you don't have")
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
if local_ahead != 0
|
|
46
|
+
if local_ahead == 1
|
|
47
|
+
return Results.new("remote-behind" => "There is 1 commit not pushed to origin")
|
|
48
|
+
else
|
|
49
|
+
return Results.new("remote-behind" => "There are #{local_ahead} commits not pushed to origin")
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
Results.new
|
|
53
|
+
end
|
|
54
|
+
end
|