itsi 0.1.6 → 0.1.8
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/Cargo.lock +49 -0
- data/Rakefile +20 -0
- data/crates/itsi_error/src/from.rs +26 -29
- data/crates/itsi_error/src/lib.rs +1 -1
- data/crates/itsi_server/Cargo.lock +2956 -0
- data/crates/itsi_server/Cargo.toml +2 -1
- data/crates/itsi_server/src/env.rs +43 -0
- data/crates/itsi_server/src/lib.rs +1 -0
- data/crates/itsi_server/src/request/itsi_request.rs +7 -7
- data/crates/itsi_server/src/server/bind.rs +4 -3
- data/crates/itsi_server/src/server/itsi_server.rs +1 -8
- data/crates/itsi_server/src/server/listener.rs +98 -107
- data/crates/itsi_server/src/server/serve_strategy/single_mode.rs +22 -12
- data/crates/itsi_server/src/server/tls/locked_dir_cache.rs +3 -3
- data/crates/itsi_server/src/server/tls.rs +83 -44
- data/gems/scheduler/ext/itsi_error/src/from.rs +26 -29
- data/gems/scheduler/ext/itsi_error/src/lib.rs +1 -1
- data/gems/scheduler/ext/itsi_server/Cargo.lock +2956 -0
- data/gems/scheduler/ext/itsi_server/Cargo.toml +2 -1
- data/gems/scheduler/ext/itsi_server/src/env.rs +43 -0
- data/gems/scheduler/ext/itsi_server/src/lib.rs +1 -0
- data/gems/scheduler/ext/itsi_server/src/request/itsi_request.rs +7 -7
- data/gems/scheduler/ext/itsi_server/src/server/bind.rs +4 -3
- data/gems/scheduler/ext/itsi_server/src/server/itsi_server.rs +1 -8
- data/gems/scheduler/ext/itsi_server/src/server/listener.rs +98 -107
- data/gems/scheduler/ext/itsi_server/src/server/serve_strategy/single_mode.rs +22 -12
- data/gems/scheduler/ext/itsi_server/src/server/tls/locked_dir_cache.rs +3 -3
- data/gems/scheduler/ext/itsi_server/src/server/tls.rs +83 -44
- data/gems/scheduler/lib/itsi/scheduler/version.rb +1 -1
- data/gems/server/Cargo.lock +2917 -0
- data/gems/server/Cargo.toml +7 -0
- data/gems/server/ext/itsi_error/src/from.rs +26 -29
- data/gems/server/ext/itsi_error/src/lib.rs +1 -1
- data/gems/server/ext/itsi_server/Cargo.lock +2956 -0
- data/gems/server/ext/itsi_server/Cargo.toml +2 -1
- data/gems/server/ext/itsi_server/src/env.rs +43 -0
- data/gems/server/ext/itsi_server/src/lib.rs +1 -0
- data/gems/server/ext/itsi_server/src/request/itsi_request.rs +7 -7
- data/gems/server/ext/itsi_server/src/server/bind.rs +4 -3
- data/gems/server/ext/itsi_server/src/server/itsi_server.rs +1 -8
- data/gems/server/ext/itsi_server/src/server/listener.rs +98 -107
- data/gems/server/ext/itsi_server/src/server/serve_strategy/single_mode.rs +22 -12
- data/gems/server/ext/itsi_server/src/server/tls/locked_dir_cache.rs +3 -3
- data/gems/server/ext/itsi_server/src/server/tls.rs +83 -44
- data/gems/server/lib/itsi/index.html.erb +91 -0
- data/gems/server/lib/itsi/server/scheduler_mode.rb +1 -1
- data/gems/server/lib/itsi/server/version.rb +1 -1
- data/gems/server/lib/itsi/server.rb +22 -2
- data/lib/itsi/version.rb +1 -1
- data/sandbox/deploy/main.tf +237 -0
- data/sandbox/deploy/outputs.tf +4 -0
- data/sandbox/deploy/vars.tf +11 -0
- data/sandbox/falcon_benchmark/Gemfile +10 -0
- data/sandbox/falcon_benchmark/Gemfile.lock +140 -0
- data/sandbox/falcon_benchmark/config.ru +54 -0
- data/sandbox/itsi_sandbox_async/Gemfile +10 -0
- data/sandbox/itsi_sandbox_async/Gemfile.lock +69 -0
- data/sandbox/itsi_sandbox_async/config.ru +10 -0
- data/sandbox/itsi_sandbox_hanami/.env +2 -0
- data/sandbox/itsi_sandbox_hanami/.gitignore +6 -0
- data/sandbox/itsi_sandbox_hanami/.rspec +1 -0
- data/sandbox/itsi_sandbox_hanami/Gemfile +49 -0
- data/sandbox/itsi_sandbox_hanami/Gemfile.lock +440 -0
- data/sandbox/itsi_sandbox_hanami/Guardfile +9 -0
- data/sandbox/itsi_sandbox_hanami/Procfile.dev +2 -0
- data/sandbox/itsi_sandbox_hanami/README.md +1 -0
- data/sandbox/itsi_sandbox_hanami/Rakefile +3 -0
- data/sandbox/itsi_sandbox_hanami/app/action.rb +12 -0
- data/sandbox/itsi_sandbox_hanami/app/actions/.keep +0 -0
- data/sandbox/itsi_sandbox_hanami/app/assets/css/app.css +5 -0
- data/sandbox/itsi_sandbox_hanami/app/assets/images/favicon.ico +0 -0
- data/sandbox/itsi_sandbox_hanami/app/assets/js/app.js +1 -0
- data/sandbox/itsi_sandbox_hanami/app/db/relation.rb +10 -0
- data/sandbox/itsi_sandbox_hanami/app/db/repo.rb +10 -0
- data/sandbox/itsi_sandbox_hanami/app/db/struct.rb +10 -0
- data/sandbox/itsi_sandbox_hanami/app/operation.rb +9 -0
- data/sandbox/itsi_sandbox_hanami/app/relations/.keep +0 -0
- data/sandbox/itsi_sandbox_hanami/app/repos/.keep +0 -0
- data/sandbox/itsi_sandbox_hanami/app/structs/.keep +0 -0
- data/sandbox/itsi_sandbox_hanami/app/templates/layouts/app.html.erb +14 -0
- data/sandbox/itsi_sandbox_hanami/app/view.rb +9 -0
- data/sandbox/itsi_sandbox_hanami/app/views/helpers.rb +10 -0
- data/sandbox/itsi_sandbox_hanami/bin/dev +8 -0
- data/sandbox/itsi_sandbox_hanami/config/app.rb +8 -0
- data/sandbox/itsi_sandbox_hanami/config/assets.js +16 -0
- data/sandbox/itsi_sandbox_hanami/config/db/migrate/.keep +0 -0
- data/sandbox/itsi_sandbox_hanami/config/db/seeds.rb +15 -0
- data/sandbox/itsi_sandbox_hanami/config/puma.rb +47 -0
- data/sandbox/itsi_sandbox_hanami/config/routes.rb +7 -0
- data/sandbox/itsi_sandbox_hanami/config/settings.rb +9 -0
- data/sandbox/itsi_sandbox_hanami/config.ru +5 -0
- data/sandbox/itsi_sandbox_hanami/db/.keep +0 -0
- data/sandbox/itsi_sandbox_hanami/lib/itsi_hanami/types.rb +11 -0
- data/sandbox/itsi_sandbox_hanami/lib/tasks/.keep +0 -0
- data/sandbox/itsi_sandbox_hanami/package-lock.json +946 -0
- data/sandbox/itsi_sandbox_hanami/package.json +8 -0
- data/sandbox/itsi_sandbox_hanami/spec/requests/root_spec.rb +11 -0
- data/sandbox/itsi_sandbox_hanami/spec/spec_helper.rb +9 -0
- data/sandbox/itsi_sandbox_hanami/spec/support/db/cleaning.rb +42 -0
- data/sandbox/itsi_sandbox_hanami/spec/support/db.rb +10 -0
- data/sandbox/itsi_sandbox_hanami/spec/support/features.rb +5 -0
- data/sandbox/itsi_sandbox_hanami/spec/support/operations.rb +8 -0
- data/sandbox/itsi_sandbox_hanami/spec/support/requests.rb +13 -0
- data/sandbox/itsi_sandbox_hanami/spec/support/rspec.rb +61 -0
- data/sandbox/itsi_sandbox_rack/Gemfile +17 -0
- data/sandbox/itsi_sandbox_rack/Gemfile.lock +153 -0
- data/sandbox/itsi_sandbox_rack/config.ru +18 -0
- data/sandbox/itsi_sandbox_rack_lint/Gemfile +7 -0
- data/sandbox/itsi_sandbox_rack_lint/Gemfile.lock +27 -0
- data/sandbox/itsi_sandbox_rack_lint/config.ru +3 -0
- data/sandbox/itsi_sandbox_rails/.dockerignore +51 -0
- data/sandbox/itsi_sandbox_rails/.gitattributes +9 -0
- data/sandbox/itsi_sandbox_rails/.github/dependabot.yml +12 -0
- data/sandbox/itsi_sandbox_rails/.github/workflows/ci.yml +90 -0
- data/sandbox/itsi_sandbox_rails/.gitignore +34 -0
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/docker-setup.sample +3 -0
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/post-app-boot.sample +3 -0
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/post-deploy.sample +14 -0
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/post-proxy-reboot.sample +3 -0
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-app-boot.sample +3 -0
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-build.sample +51 -0
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-connect.sample +47 -0
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-deploy.sample +109 -0
- data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-proxy-reboot.sample +3 -0
- data/sandbox/itsi_sandbox_rails/.kamal/secrets +17 -0
- data/sandbox/itsi_sandbox_rails/.rubocop.yml +8 -0
- data/sandbox/itsi_sandbox_rails/.ruby-version +1 -0
- data/sandbox/itsi_sandbox_rails/Dockerfile +72 -0
- data/sandbox/itsi_sandbox_rails/Gemfile +72 -0
- data/sandbox/itsi_sandbox_rails/Gemfile.lock +480 -0
- data/sandbox/itsi_sandbox_rails/README.md +24 -0
- data/sandbox/itsi_sandbox_rails/Rakefile +6 -0
- data/sandbox/itsi_sandbox_rails/app/assets/images/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/app/assets/stylesheets/application.css +10 -0
- data/sandbox/itsi_sandbox_rails/app/controllers/application_controller.rb +4 -0
- data/sandbox/itsi_sandbox_rails/app/controllers/concerns/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/app/controllers/home_controller.rb +51 -0
- data/sandbox/itsi_sandbox_rails/app/controllers/live_controller.rb +41 -0
- data/sandbox/itsi_sandbox_rails/app/controllers/uploads_controller.rb +32 -0
- data/sandbox/itsi_sandbox_rails/app/helpers/application_helper.rb +2 -0
- data/sandbox/itsi_sandbox_rails/app/javascript/application.js +3 -0
- data/sandbox/itsi_sandbox_rails/app/javascript/controllers/application.js +9 -0
- data/sandbox/itsi_sandbox_rails/app/javascript/controllers/hello_controller.js +7 -0
- data/sandbox/itsi_sandbox_rails/app/javascript/controllers/index.js +4 -0
- data/sandbox/itsi_sandbox_rails/app/jobs/application_job.rb +7 -0
- data/sandbox/itsi_sandbox_rails/app/mailers/application_mailer.rb +4 -0
- data/sandbox/itsi_sandbox_rails/app/models/application_record.rb +3 -0
- data/sandbox/itsi_sandbox_rails/app/models/concerns/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/app/models/post.rb +2 -0
- data/sandbox/itsi_sandbox_rails/app/views/layouts/application.html.erb +28 -0
- data/sandbox/itsi_sandbox_rails/app/views/layouts/mailer.html.erb +13 -0
- data/sandbox/itsi_sandbox_rails/app/views/layouts/mailer.text.erb +1 -0
- data/sandbox/itsi_sandbox_rails/app/views/pwa/manifest.json.erb +22 -0
- data/sandbox/itsi_sandbox_rails/app/views/pwa/service-worker.js +26 -0
- data/sandbox/itsi_sandbox_rails/bin/brakeman +7 -0
- data/sandbox/itsi_sandbox_rails/bin/bundle +109 -0
- data/sandbox/itsi_sandbox_rails/bin/dev +2 -0
- data/sandbox/itsi_sandbox_rails/bin/docker-entrypoint +14 -0
- data/sandbox/itsi_sandbox_rails/bin/importmap +4 -0
- data/sandbox/itsi_sandbox_rails/bin/jobs +6 -0
- data/sandbox/itsi_sandbox_rails/bin/kamal +27 -0
- data/sandbox/itsi_sandbox_rails/bin/rails +4 -0
- data/sandbox/itsi_sandbox_rails/bin/rake +4 -0
- data/sandbox/itsi_sandbox_rails/bin/rubocop +8 -0
- data/sandbox/itsi_sandbox_rails/bin/setup +34 -0
- data/sandbox/itsi_sandbox_rails/bin/thrust +5 -0
- data/sandbox/itsi_sandbox_rails/config/application.rb +61 -0
- data/sandbox/itsi_sandbox_rails/config/boot.rb +4 -0
- data/sandbox/itsi_sandbox_rails/config/cable.yml +17 -0
- data/sandbox/itsi_sandbox_rails/config/cache.yml +16 -0
- data/sandbox/itsi_sandbox_rails/config/credentials.yml.enc +1 -0
- data/sandbox/itsi_sandbox_rails/config/database.yml +40 -0
- data/sandbox/itsi_sandbox_rails/config/deploy.yml +116 -0
- data/sandbox/itsi_sandbox_rails/config/environment.rb +5 -0
- data/sandbox/itsi_sandbox_rails/config/environments/development.rb +72 -0
- data/sandbox/itsi_sandbox_rails/config/environments/production.rb +90 -0
- data/sandbox/itsi_sandbox_rails/config/environments/test.rb +53 -0
- data/sandbox/itsi_sandbox_rails/config/importmap.rb +7 -0
- data/sandbox/itsi_sandbox_rails/config/initializers/assets.rb +7 -0
- data/sandbox/itsi_sandbox_rails/config/initializers/content_security_policy.rb +25 -0
- data/sandbox/itsi_sandbox_rails/config/initializers/filter_parameter_logging.rb +8 -0
- data/sandbox/itsi_sandbox_rails/config/initializers/inflections.rb +16 -0
- data/sandbox/itsi_sandbox_rails/config/locales/en.yml +31 -0
- data/sandbox/itsi_sandbox_rails/config/puma.rb +41 -0
- data/sandbox/itsi_sandbox_rails/config/queue.yml +18 -0
- data/sandbox/itsi_sandbox_rails/config/recurring.yml +10 -0
- data/sandbox/itsi_sandbox_rails/config/routes.rb +21 -0
- data/sandbox/itsi_sandbox_rails/config/storage.yml +34 -0
- data/sandbox/itsi_sandbox_rails/config.ru +7 -0
- data/sandbox/itsi_sandbox_rails/db/cable_schema.rb +11 -0
- data/sandbox/itsi_sandbox_rails/db/cache_schema.rb +14 -0
- data/sandbox/itsi_sandbox_rails/db/migrate/20250301041554_create_posts.rb +10 -0
- data/sandbox/itsi_sandbox_rails/db/queue_schema.rb +129 -0
- data/sandbox/itsi_sandbox_rails/db/schema.rb +23 -0
- data/sandbox/itsi_sandbox_rails/db/seeds.rb +9 -0
- data/sandbox/itsi_sandbox_rails/lib/tasks/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/log/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/public/400.html +114 -0
- data/sandbox/itsi_sandbox_rails/public/404.html +114 -0
- data/sandbox/itsi_sandbox_rails/public/406-unsupported-browser.html +114 -0
- data/sandbox/itsi_sandbox_rails/public/422.html +114 -0
- data/sandbox/itsi_sandbox_rails/public/500.html +114 -0
- data/sandbox/itsi_sandbox_rails/public/icon.png +0 -0
- data/sandbox/itsi_sandbox_rails/public/icon.svg +3 -0
- data/sandbox/itsi_sandbox_rails/public/robots.txt +1 -0
- data/sandbox/itsi_sandbox_rails/script/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/storage/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/test/application_system_test_case.rb +5 -0
- data/sandbox/itsi_sandbox_rails/test/controllers/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/test/fixtures/files/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/test/fixtures/posts.yml +9 -0
- data/sandbox/itsi_sandbox_rails/test/helpers/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/test/integration/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/test/mailers/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/test/models/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/test/models/post_test.rb +7 -0
- data/sandbox/itsi_sandbox_rails/test/system/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/test/test_helper.rb +15 -0
- data/sandbox/itsi_sandbox_rails/tmp/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/tmp/pids/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/tmp/storage/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/vendor/.keep +0 -0
- data/sandbox/itsi_sandbox_rails/vendor/javascript/.keep +0 -0
- data/sandbox/itsi_sandbox_roda/Gemfile +5 -0
- data/sandbox/itsi_sandbox_roda/Gemfile.lock +44 -0
- data/sandbox/itsi_sandbox_roda/config.ru +39 -0
- data/sandbox/itsi_sinatra/Gemfile +9 -0
- data/sandbox/itsi_sinatra/Gemfile.lock +81 -0
- data/sandbox/itsi_sinatra/app.rb +9 -0
- data/sandbox/pebble/docker-compose.yml +11 -0
- data/tasks.txt +10 -4
- metadata +196 -12
- data/crates/itsi_server/src/server/itsi_ca/itsi_ca.crt +0 -13
- data/crates/itsi_server/src/server/itsi_ca/itsi_ca.key +0 -5
- data/gems/scheduler/ext/itsi_server/src/server/itsi_ca/itsi_ca.crt +0 -13
- data/gems/scheduler/ext/itsi_server/src/server/itsi_ca/itsi_ca.key +0 -5
- data/gems/server/ext/itsi_server/src/server/itsi_ca/itsi_ca.crt +0 -13
- data/gems/server/ext/itsi_server/src/server/itsi_ca/itsi_ca.key +0 -5
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# A sample pre-build hook
|
4
|
+
#
|
5
|
+
# Checks:
|
6
|
+
# 1. We have a clean checkout
|
7
|
+
# 2. A remote is configured
|
8
|
+
# 3. The branch has been pushed to the remote
|
9
|
+
# 4. The version we are deploying matches the remote
|
10
|
+
#
|
11
|
+
# These environment variables are available:
|
12
|
+
# KAMAL_RECORDED_AT
|
13
|
+
# KAMAL_PERFORMER
|
14
|
+
# KAMAL_VERSION
|
15
|
+
# KAMAL_HOSTS
|
16
|
+
# KAMAL_ROLE (if set)
|
17
|
+
# KAMAL_DESTINATION (if set)
|
18
|
+
|
19
|
+
if [ -n "$(git status --porcelain)" ]; then
|
20
|
+
echo "Git checkout is not clean, aborting..." >&2
|
21
|
+
git status --porcelain >&2
|
22
|
+
exit 1
|
23
|
+
fi
|
24
|
+
|
25
|
+
first_remote=$(git remote)
|
26
|
+
|
27
|
+
if [ -z "$first_remote" ]; then
|
28
|
+
echo "No git remote set, aborting..." >&2
|
29
|
+
exit 1
|
30
|
+
fi
|
31
|
+
|
32
|
+
current_branch=$(git branch --show-current)
|
33
|
+
|
34
|
+
if [ -z "$current_branch" ]; then
|
35
|
+
echo "Not on a git branch, aborting..." >&2
|
36
|
+
exit 1
|
37
|
+
fi
|
38
|
+
|
39
|
+
remote_head=$(git ls-remote $first_remote --tags $current_branch | cut -f1)
|
40
|
+
|
41
|
+
if [ -z "$remote_head" ]; then
|
42
|
+
echo "Branch not pushed to remote, aborting..." >&2
|
43
|
+
exit 1
|
44
|
+
fi
|
45
|
+
|
46
|
+
if [ "$KAMAL_VERSION" != "$remote_head" ]; then
|
47
|
+
echo "Version ($KAMAL_VERSION) does not match remote HEAD ($remote_head), aborting..." >&2
|
48
|
+
exit 1
|
49
|
+
fi
|
50
|
+
|
51
|
+
exit 0
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# A sample pre-connect check
|
4
|
+
#
|
5
|
+
# Warms DNS before connecting to hosts in parallel
|
6
|
+
#
|
7
|
+
# These environment variables are available:
|
8
|
+
# KAMAL_RECORDED_AT
|
9
|
+
# KAMAL_PERFORMER
|
10
|
+
# KAMAL_VERSION
|
11
|
+
# KAMAL_HOSTS
|
12
|
+
# KAMAL_ROLE (if set)
|
13
|
+
# KAMAL_DESTINATION (if set)
|
14
|
+
# KAMAL_RUNTIME
|
15
|
+
|
16
|
+
hosts = ENV["KAMAL_HOSTS"].split(",")
|
17
|
+
results = nil
|
18
|
+
max = 3
|
19
|
+
|
20
|
+
elapsed = Benchmark.realtime do
|
21
|
+
results = hosts.map do |host|
|
22
|
+
Thread.new do
|
23
|
+
tries = 1
|
24
|
+
|
25
|
+
begin
|
26
|
+
Socket.getaddrinfo(host, 0, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME)
|
27
|
+
rescue SocketError
|
28
|
+
if tries < max
|
29
|
+
puts "Retrying DNS warmup: #{host}"
|
30
|
+
tries += 1
|
31
|
+
sleep rand
|
32
|
+
retry
|
33
|
+
else
|
34
|
+
puts "DNS warmup failed: #{host}"
|
35
|
+
host
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
tries
|
40
|
+
end
|
41
|
+
end.map(&:value)
|
42
|
+
end
|
43
|
+
|
44
|
+
retries = results.sum - hosts.size
|
45
|
+
nopes = results.count { |r| r == max }
|
46
|
+
|
47
|
+
puts "Prewarmed %d DNS lookups in %.2f sec: %d retries, %d failures" % [ hosts.size, elapsed, retries, nopes ]
|
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# A sample pre-deploy hook
|
4
|
+
#
|
5
|
+
# Checks the Github status of the build, waiting for a pending build to complete for up to 720 seconds.
|
6
|
+
#
|
7
|
+
# Fails unless the combined status is "success"
|
8
|
+
#
|
9
|
+
# These environment variables are available:
|
10
|
+
# KAMAL_RECORDED_AT
|
11
|
+
# KAMAL_PERFORMER
|
12
|
+
# KAMAL_VERSION
|
13
|
+
# KAMAL_HOSTS
|
14
|
+
# KAMAL_COMMAND
|
15
|
+
# KAMAL_SUBCOMMAND
|
16
|
+
# KAMAL_ROLE (if set)
|
17
|
+
# KAMAL_DESTINATION (if set)
|
18
|
+
|
19
|
+
# Only check the build status for production deployments
|
20
|
+
if ENV["KAMAL_COMMAND"] == "rollback" || ENV["KAMAL_DESTINATION"] != "production"
|
21
|
+
exit 0
|
22
|
+
end
|
23
|
+
|
24
|
+
require "bundler/inline"
|
25
|
+
|
26
|
+
# true = install gems so this is fast on repeat invocations
|
27
|
+
gemfile(true, quiet: true) do
|
28
|
+
source "https://rubygems.org"
|
29
|
+
|
30
|
+
gem "octokit"
|
31
|
+
gem "faraday-retry"
|
32
|
+
end
|
33
|
+
|
34
|
+
MAX_ATTEMPTS = 72
|
35
|
+
ATTEMPTS_GAP = 10
|
36
|
+
|
37
|
+
def exit_with_error(message)
|
38
|
+
$stderr.puts message
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
|
42
|
+
class GithubStatusChecks
|
43
|
+
attr_reader :remote_url, :git_sha, :github_client, :combined_status
|
44
|
+
|
45
|
+
def initialize
|
46
|
+
@remote_url = `git config --get remote.origin.url`.strip.delete_prefix("https://github.com/")
|
47
|
+
@git_sha = `git rev-parse HEAD`.strip
|
48
|
+
@github_client = Octokit::Client.new(access_token: ENV["GITHUB_TOKEN"])
|
49
|
+
refresh!
|
50
|
+
end
|
51
|
+
|
52
|
+
def refresh!
|
53
|
+
@combined_status = github_client.combined_status(remote_url, git_sha)
|
54
|
+
end
|
55
|
+
|
56
|
+
def state
|
57
|
+
combined_status[:state]
|
58
|
+
end
|
59
|
+
|
60
|
+
def first_status_url
|
61
|
+
first_status = combined_status[:statuses].find { |status| status[:state] == state }
|
62
|
+
first_status && first_status[:target_url]
|
63
|
+
end
|
64
|
+
|
65
|
+
def complete_count
|
66
|
+
combined_status[:statuses].count { |status| status[:state] != "pending"}
|
67
|
+
end
|
68
|
+
|
69
|
+
def total_count
|
70
|
+
combined_status[:statuses].count
|
71
|
+
end
|
72
|
+
|
73
|
+
def current_status
|
74
|
+
if total_count > 0
|
75
|
+
"Completed #{complete_count}/#{total_count} checks, see #{first_status_url} ..."
|
76
|
+
else
|
77
|
+
"Build not started..."
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
$stdout.sync = true
|
84
|
+
|
85
|
+
puts "Checking build status..."
|
86
|
+
attempts = 0
|
87
|
+
checks = GithubStatusChecks.new
|
88
|
+
|
89
|
+
begin
|
90
|
+
loop do
|
91
|
+
case checks.state
|
92
|
+
when "success"
|
93
|
+
puts "Checks passed, see #{checks.first_status_url}"
|
94
|
+
exit 0
|
95
|
+
when "failure"
|
96
|
+
exit_with_error "Checks failed, see #{checks.first_status_url}"
|
97
|
+
when "pending"
|
98
|
+
attempts += 1
|
99
|
+
end
|
100
|
+
|
101
|
+
exit_with_error "Checks are still pending, gave up after #{MAX_ATTEMPTS * ATTEMPTS_GAP} seconds" if attempts == MAX_ATTEMPTS
|
102
|
+
|
103
|
+
puts checks.current_status
|
104
|
+
sleep(ATTEMPTS_GAP)
|
105
|
+
checks.refresh!
|
106
|
+
end
|
107
|
+
rescue Octokit::NotFound
|
108
|
+
exit_with_error "Build status could not be found"
|
109
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Secrets defined here are available for reference under registry/password, env/secret, builder/secrets,
|
2
|
+
# and accessories/*/env/secret in config/deploy.yml. All secrets should be pulled from either
|
3
|
+
# password manager, ENV, or a file. DO NOT ENTER RAW CREDENTIALS HERE! This file needs to be safe for git.
|
4
|
+
|
5
|
+
# Example of extracting secrets from 1password (or another compatible pw manager)
|
6
|
+
# SECRETS=$(kamal secrets fetch --adapter 1password --account your-account --from Vault/Item KAMAL_REGISTRY_PASSWORD RAILS_MASTER_KEY)
|
7
|
+
# KAMAL_REGISTRY_PASSWORD=$(kamal secrets extract KAMAL_REGISTRY_PASSWORD ${SECRETS})
|
8
|
+
# RAILS_MASTER_KEY=$(kamal secrets extract RAILS_MASTER_KEY ${SECRETS})
|
9
|
+
|
10
|
+
# Use a GITHUB_TOKEN if private repositories are needed for the image
|
11
|
+
# GITHUB_TOKEN=$(gh config get -h github.com oauth_token)
|
12
|
+
|
13
|
+
# Grab the registry password from ENV
|
14
|
+
KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD
|
15
|
+
|
16
|
+
# Improve security by using a password manager. Never check config/master.key into git!
|
17
|
+
RAILS_MASTER_KEY=$(cat config/master.key)
|
@@ -0,0 +1 @@
|
|
1
|
+
ruby-3.4.2
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# syntax=docker/dockerfile:1
|
2
|
+
# check=error=true
|
3
|
+
|
4
|
+
# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
|
5
|
+
# docker build -t itsi_sandbox_rails .
|
6
|
+
# docker run -d -p 80:80 -e RAILS_MASTER_KEY=<value from config/master.key> --name itsi_sandbox_rails itsi_sandbox_rails
|
7
|
+
|
8
|
+
# For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html
|
9
|
+
|
10
|
+
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
|
11
|
+
ARG RUBY_VERSION=3.4.2
|
12
|
+
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
|
13
|
+
|
14
|
+
# Rails app lives here
|
15
|
+
WORKDIR /rails
|
16
|
+
|
17
|
+
# Install base packages
|
18
|
+
RUN apt-get update -qq && \
|
19
|
+
apt-get install --no-install-recommends -y curl libjemalloc2 libvips sqlite3 && \
|
20
|
+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
21
|
+
|
22
|
+
# Set production environment
|
23
|
+
ENV RAILS_ENV="production" \
|
24
|
+
BUNDLE_DEPLOYMENT="1" \
|
25
|
+
BUNDLE_PATH="/usr/local/bundle" \
|
26
|
+
BUNDLE_WITHOUT="development"
|
27
|
+
|
28
|
+
# Throw-away build stage to reduce size of final image
|
29
|
+
FROM base AS build
|
30
|
+
|
31
|
+
# Install packages needed to build gems
|
32
|
+
RUN apt-get update -qq && \
|
33
|
+
apt-get install --no-install-recommends -y build-essential git pkg-config && \
|
34
|
+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
35
|
+
|
36
|
+
# Install application gems
|
37
|
+
COPY Gemfile Gemfile.lock ./
|
38
|
+
RUN bundle install && \
|
39
|
+
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
|
40
|
+
bundle exec bootsnap precompile --gemfile
|
41
|
+
|
42
|
+
# Copy application code
|
43
|
+
COPY . .
|
44
|
+
|
45
|
+
# Precompile bootsnap code for faster boot times
|
46
|
+
RUN bundle exec bootsnap precompile app/ lib/
|
47
|
+
|
48
|
+
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
|
49
|
+
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
# Final stage for app image
|
55
|
+
FROM base
|
56
|
+
|
57
|
+
# Copy built artifacts: gems, application
|
58
|
+
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
|
59
|
+
COPY --from=build /rails /rails
|
60
|
+
|
61
|
+
# Run and own only the runtime files as a non-root user for security
|
62
|
+
RUN groupadd --system --gid 1000 rails && \
|
63
|
+
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
|
64
|
+
chown -R rails:rails db log storage tmp
|
65
|
+
USER 1000:1000
|
66
|
+
|
67
|
+
# Entrypoint prepares the database.
|
68
|
+
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
|
69
|
+
|
70
|
+
# Start server via Thruster by default, this can be overwritten at runtime
|
71
|
+
EXPOSE 80
|
72
|
+
CMD ["./bin/thrust", "./bin/rails", "server"]
|
@@ -0,0 +1,72 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
|
4
|
+
gem "rails", "~> 8.0.1"
|
5
|
+
# The modern asset pipeline for Rails [https://github.com/rails/propshaft]
|
6
|
+
gem "propshaft"
|
7
|
+
# Use sqlite3 as the database for Active Record
|
8
|
+
gem "sqlite3", ">= 2.1"
|
9
|
+
# Use the Puma web server [https://github.com/puma/puma]
|
10
|
+
gem "puma", ">= 5.0"
|
11
|
+
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
|
12
|
+
gem "importmap-rails"
|
13
|
+
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
|
14
|
+
gem "turbo-rails"
|
15
|
+
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
|
16
|
+
gem "stimulus-rails"
|
17
|
+
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
|
18
|
+
gem "jbuilder"
|
19
|
+
gem "iodine"
|
20
|
+
gem "pg"
|
21
|
+
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
|
22
|
+
# gem "bcrypt", "~> 3.1.7"
|
23
|
+
|
24
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
25
|
+
gem "tzinfo-data", platforms: %i[ windows jruby ]
|
26
|
+
|
27
|
+
# Use the database-backed adapters for Rails.cache, Active Job, and Action Cable
|
28
|
+
gem "solid_cache"
|
29
|
+
gem "solid_queue"
|
30
|
+
gem "solid_cable"
|
31
|
+
|
32
|
+
# Reduces boot times through caching; required in config/boot.rb
|
33
|
+
gem "bootsnap", require: false
|
34
|
+
|
35
|
+
# Deploy this application anywhere as a Docker container [https://kamal-deploy.org]
|
36
|
+
gem "kamal", require: false
|
37
|
+
|
38
|
+
# Add HTTP asset caching/compression and X-Sendfile acceleration to Puma [https://github.com/basecamp/thruster/]
|
39
|
+
gem "thruster", require: false
|
40
|
+
|
41
|
+
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
|
42
|
+
# gem "image_processing", "~> 1.2"
|
43
|
+
|
44
|
+
group :development, :test do
|
45
|
+
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
|
46
|
+
gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"
|
47
|
+
|
48
|
+
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
|
49
|
+
gem "brakeman", require: false
|
50
|
+
|
51
|
+
# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
|
52
|
+
gem "rubocop-rails-omakase", require: false
|
53
|
+
end
|
54
|
+
|
55
|
+
group :development do
|
56
|
+
# Use console on exceptions pages [https://github.com/rails/web-console]
|
57
|
+
gem "web-console"
|
58
|
+
end
|
59
|
+
|
60
|
+
group :test do
|
61
|
+
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
|
62
|
+
gem "capybara"
|
63
|
+
gem "selenium-webdriver"
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
# gem "itsi", path: "../.."
|
68
|
+
gem "itsi-scheduler", path: "../../gems/scheduler"
|
69
|
+
gem "itsi-server", path: "../../gems/server"
|
70
|
+
gem "async"
|
71
|
+
gem "osprey_scheduler", path: "../../../osprey_scheduler"
|
72
|
+
gem "falcon"
|