hot_docs 0.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.
Files changed (143) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +8 -0
  3. data/CHANGELOG.md +5 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +39 -0
  6. data/Rakefile +12 -0
  7. data/lib/hot_docs/version.rb +5 -0
  8. data/lib/hot_docs.rb +8 -0
  9. data/sig/hot_docs.rbs +4 -0
  10. data/website/.dockerignore +51 -0
  11. data/website/.gitattributes +9 -0
  12. data/website/.github/dependabot.yml +12 -0
  13. data/website/.github/images/hot_docs.svg +17 -0
  14. data/website/.github/workflows/ci.yml +90 -0
  15. data/website/.gitignore +37 -0
  16. data/website/.kamal/hooks/docker-setup.sample +3 -0
  17. data/website/.kamal/hooks/post-deploy.sample +14 -0
  18. data/website/.kamal/hooks/post-proxy-reboot.sample +3 -0
  19. data/website/.kamal/hooks/pre-build.sample +51 -0
  20. data/website/.kamal/hooks/pre-connect.sample +47 -0
  21. data/website/.kamal/hooks/pre-deploy.sample +109 -0
  22. data/website/.kamal/hooks/pre-proxy-reboot.sample +3 -0
  23. data/website/.kamal/secrets +17 -0
  24. data/website/.rubocop.yml +8 -0
  25. data/website/.ruby-version +1 -0
  26. data/website/Dockerfile +72 -0
  27. data/website/Gemfile +65 -0
  28. data/website/Gemfile.lock +394 -0
  29. data/website/LICENSE.txt +21 -0
  30. data/website/README.md +49 -0
  31. data/website/Rakefile +6 -0
  32. data/website/app/assets/images/.keep +0 -0
  33. data/website/app/assets/images/hot_docs_components_desktop.png +0 -0
  34. data/website/app/assets/images/hot_docs_components_mobile.png +0 -0
  35. data/website/app/assets/stylesheets/hot_docs.css +999 -0
  36. data/website/app/assets/stylesheets/website.css +245 -0
  37. data/website/app/controllers/application_controller.rb +4 -0
  38. data/website/app/controllers/concerns/.keep +0 -0
  39. data/website/app/controllers/hot_docs_controller.rb +3 -0
  40. data/website/app/helpers/application_helper.rb +25 -0
  41. data/website/app/helpers/hot_docs_helper.rb +99 -0
  42. data/website/app/javascript/application.js +3 -0
  43. data/website/app/javascript/controllers/accordion_controller.js +36 -0
  44. data/website/app/javascript/controllers/application.js +9 -0
  45. data/website/app/javascript/controllers/index.js +4 -0
  46. data/website/app/javascript/controllers/sidenav_controller.js +39 -0
  47. data/website/app/javascript/controllers/toc_controller.js +91 -0
  48. data/website/app/javascript/controllers/typewriter_controller.js +59 -0
  49. data/website/app/jobs/application_job.rb +7 -0
  50. data/website/app/mailers/application_mailer.rb +4 -0
  51. data/website/app/models/application_record.rb +3 -0
  52. data/website/app/models/concerns/.keep +0 -0
  53. data/website/app/views/hot_docs/_menu_row.html.erb +11 -0
  54. data/website/app/views/hot_docs/components.html.mderb +32 -0
  55. data/website/app/views/hot_docs/embedded.html.mderb +12 -0
  56. data/website/app/views/hot_docs/footer.html.mderb +13 -0
  57. data/website/app/views/hot_docs/helpers.html.mderb +33 -0
  58. data/website/app/views/hot_docs/index.html.erb +143 -0
  59. data/website/app/views/hot_docs/light_dark.html.mderb +29 -0
  60. data/website/app/views/hot_docs/markdown.html.mderb +27 -0
  61. data/website/app/views/hot_docs/nav.html.mderb +15 -0
  62. data/website/app/views/hot_docs/quickstart.html.mderb +11 -0
  63. data/website/app/views/hot_docs/search.html.mderb +7 -0
  64. data/website/app/views/hot_docs/standalone.html.mderb +11 -0
  65. data/website/app/views/hot_docs/static_export.html.mderb +7 -0
  66. data/website/app/views/hot_docs/toc.html.mderb +11 -0
  67. data/website/app/views/layouts/hot_docs.html.erb +175 -0
  68. data/website/app/views/layouts/mailer.html.erb +13 -0
  69. data/website/app/views/layouts/mailer.text.erb +1 -0
  70. data/website/app/views/layouts/website.html.erb +175 -0
  71. data/website/app/views/pwa/manifest.json.erb +22 -0
  72. data/website/app/views/pwa/service-worker.js +26 -0
  73. data/website/bin/brakeman +7 -0
  74. data/website/bin/bundle +109 -0
  75. data/website/bin/dev +2 -0
  76. data/website/bin/docker-entrypoint +14 -0
  77. data/website/bin/embed_hot_docs +33 -0
  78. data/website/bin/importmap +4 -0
  79. data/website/bin/jobs +6 -0
  80. data/website/bin/kamal +27 -0
  81. data/website/bin/rails +4 -0
  82. data/website/bin/rake +4 -0
  83. data/website/bin/rubocop +8 -0
  84. data/website/bin/setup +34 -0
  85. data/website/bin/thrust +5 -0
  86. data/website/config/application.rb +27 -0
  87. data/website/config/boot.rb +4 -0
  88. data/website/config/cable.yml +17 -0
  89. data/website/config/cache.yml +16 -0
  90. data/website/config/credentials.yml.enc +1 -0
  91. data/website/config/database.yml +41 -0
  92. data/website/config/deploy.yml +116 -0
  93. data/website/config/environment.rb +5 -0
  94. data/website/config/environments/development.rb +72 -0
  95. data/website/config/environments/production.rb +90 -0
  96. data/website/config/environments/test.rb +53 -0
  97. data/website/config/importmap.rb +7 -0
  98. data/website/config/initializers/assets.rb +7 -0
  99. data/website/config/initializers/content_security_policy.rb +25 -0
  100. data/website/config/initializers/filter_parameter_logging.rb +8 -0
  101. data/website/config/initializers/inflections.rb +16 -0
  102. data/website/config/initializers/markdown.mjs +26 -0
  103. data/website/config/initializers/markdown.rb +35 -0
  104. data/website/config/locales/en.yml +31 -0
  105. data/website/config/puma.rb +41 -0
  106. data/website/config/queue.yml +18 -0
  107. data/website/config/recurring.yml +10 -0
  108. data/website/config/routes.rb +28 -0
  109. data/website/config/storage.yml +34 -0
  110. data/website/config.ru +6 -0
  111. data/website/db/cable_schema.rb +11 -0
  112. data/website/db/cache_schema.rb +14 -0
  113. data/website/db/queue_schema.rb +129 -0
  114. data/website/db/seeds.rb +9 -0
  115. data/website/lib/tasks/.keep +0 -0
  116. data/website/log/.keep +0 -0
  117. data/website/public/400.html +114 -0
  118. data/website/public/404.html +114 -0
  119. data/website/public/406-unsupported-browser.html +114 -0
  120. data/website/public/422.html +114 -0
  121. data/website/public/500.html +114 -0
  122. data/website/public/apple-touch-icon.png +0 -0
  123. data/website/public/favicon.ico +0 -0
  124. data/website/public/hot_docs.svg +17 -0
  125. data/website/public/robots.txt +1 -0
  126. data/website/script/.keep +0 -0
  127. data/website/storage/.keep +0 -0
  128. data/website/test/application_system_test_case.rb +5 -0
  129. data/website/test/controllers/.keep +0 -0
  130. data/website/test/fixtures/files/.keep +0 -0
  131. data/website/test/helpers/.keep +0 -0
  132. data/website/test/helpers/hot_docs_helper_test.rb +94 -0
  133. data/website/test/integration/.keep +0 -0
  134. data/website/test/mailers/.keep +0 -0
  135. data/website/test/models/.keep +0 -0
  136. data/website/test/system/.keep +0 -0
  137. data/website/test/test_helper.rb +15 -0
  138. data/website/tmp/.keep +0 -0
  139. data/website/tmp/pids/.keep +0 -0
  140. data/website/tmp/storage/.keep +0 -0
  141. data/website/vendor/.keep +0 -0
  142. data/website/vendor/javascript/.keep +0 -0
  143. metadata +183 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6c8b6e6b3a9171e9dea899d9d4a55686b4acd7e64c992d1652c5b07e2fb20d6e
4
+ data.tar.gz: 7b4db00d1b9d70d610846e1f647d66947da3716191e095b236098abb934c306b
5
+ SHA512:
6
+ metadata.gz: b9f5e9ed69b9ecdb0ad57c8010a3e9c2091019081d442fdf235da88cca03eee2ae2f5e5607b5012e07a8dc603ab98a934713f3ad750124df708bcf87e5c87048
7
+ data.tar.gz: baa27d1bc4585142ce895a09397d913474b4921b77949853087078327ad837709af837eb4921bf7d6afb09e6a6c50d8c68e5f81d25312a67f0f7975f6d808a20
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.1
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.0.0] - 2025-02-25
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 3v0k4
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # HotDocs
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/hot_docs`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ ```bash
14
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
+ ```
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ ```bash
20
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/hot_docs.
36
+
37
+ ## License
38
+
39
+ 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,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[test rubocop]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HotDocs
4
+ VERSION = "0.0.0"
5
+ end
data/lib/hot_docs.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "hot_docs/version"
4
+
5
+ module HotDocs
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
data/sig/hot_docs.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module HotDocs
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
@@ -0,0 +1,51 @@
1
+ # See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
2
+
3
+ # Ignore git directory.
4
+ /.git/
5
+ /.gitignore
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore all environment files.
11
+ /.env*
12
+
13
+ # Ignore all default key files.
14
+ /config/master.key
15
+ /config/credentials/*.key
16
+
17
+ # Ignore all logfiles and tempfiles.
18
+ /log/*
19
+ /tmp/*
20
+ !/log/.keep
21
+ !/tmp/.keep
22
+
23
+ # Ignore pidfiles, but keep the directory.
24
+ /tmp/pids/*
25
+ !/tmp/pids/.keep
26
+
27
+ # Ignore storage (uploaded files in development and any SQLite databases).
28
+ /storage/*
29
+ !/storage/.keep
30
+ /tmp/storage/*
31
+ !/tmp/storage/.keep
32
+
33
+ # Ignore assets.
34
+ /node_modules/
35
+ /app/assets/builds/*
36
+ !/app/assets/builds/.keep
37
+ /public/assets
38
+
39
+ # Ignore CI service files.
40
+ /.github
41
+
42
+ # Ignore Kamal files.
43
+ /config/deploy*.yml
44
+ /.kamal
45
+
46
+ # Ignore development files
47
+ /.devcontainer
48
+
49
+ # Ignore Docker-related files
50
+ /.dockerignore
51
+ /Dockerfile*
@@ -0,0 +1,9 @@
1
+ # See https://git-scm.com/docs/gitattributes for more about git attribute files.
2
+
3
+ # Mark the database schema as having been generated.
4
+ db/schema.rb linguist-generated
5
+
6
+ # Mark any vendored files as having been vendored.
7
+ vendor/* linguist-vendored
8
+ config/credentials/*.yml.enc diff=rails_credentials
9
+ config/credentials.yml.enc diff=rails_credentials
@@ -0,0 +1,12 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
8
+ - package-ecosystem: github-actions
9
+ directory: "/"
10
+ schedule:
11
+ interval: daily
12
+ open-pull-requests-limit: 10
@@ -0,0 +1,17 @@
1
+ <svg viewBox="0 0 500 500" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M90 328C243.479 290.664 328.011 197.596 359 91" stroke="#F1B869" stroke-width="120" stroke-linecap="round"/>
3
+ <path d="M67 376C252.429 326.849 354.56 204.329 392 64" stroke="#E34752" stroke-width="120" stroke-linecap="round"/>
4
+ <path d="M147 415C300.479 377.664 385.011 284.596 416 178" stroke="#F1B869" stroke-width="160" stroke-linecap="round"/>
5
+ <circle cx="230" cy="316" r="45" fill="#0A0A0A"/>
6
+ <circle cx="218.5" cy="302.5" r="17.5" fill="#F1F1F1"/>
7
+ <circle cx="243.5" cy="320.5" r="7.5" fill="#F1F1F1"/>
8
+ <path d="M251.01 290L253.792 297.32L261.617 300.607L253.792 302.813L251.01 311.213L247.981 302.813L240.404 300.607L247.981 297.32L251.01 290Z" fill="#F1F1F1"/>
9
+ <path d="M224.657 328L226.14 331.904L230.314 333.657L226.14 334.833L224.657 339.314L223.041 334.833L219 333.657L223.041 331.904L224.657 328Z" fill="#F1F1F1"/>
10
+ <circle cx="332" cy="227" r="45" fill="#0A0A0A"/>
11
+ <circle cx="320.5" cy="213.5" r="17.5" fill="#F1F1F1"/>
12
+ <circle cx="345.5" cy="231.5" r="7.5" fill="#F1F1F1"/>
13
+ <path d="M353.01 201L355.792 208.32L363.617 211.607L355.792 213.813L353.01 222.213L349.981 213.813L342.404 211.607L349.981 208.32L353.01 201Z" fill="#F1F1F1"/>
14
+ <path d="M326.657 239L328.14 242.904L332.314 244.657L328.14 245.833L326.657 250.314L325.041 245.833L321 244.657L325.041 242.904L326.657 239Z" fill="#F1F1F1"/>
15
+ <path d="M422.301 297.436C438.008 323.094 421.058 362.066 384.442 384.481C347.825 406.897 305.409 404.268 289.702 378.61C273.994 352.952 303.683 334.79 340.3 312.374C376.916 289.959 406.594 271.778 422.301 297.436Z" fill="#0A0A0A"/>
16
+ <path d="M409.899 350.314C417.051 360.608 400.145 374.476 388.212 382.766C376.279 391.057 365.573 397.144 358.421 386.85C351.268 376.556 355.144 361.489 367.077 353.198C379.01 344.907 402.747 340.019 409.899 350.314Z" fill="#E5757D"/>
17
+ </svg>
@@ -0,0 +1,90 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [ main ]
7
+
8
+ jobs:
9
+ scan_ruby:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout code
14
+ uses: actions/checkout@v4
15
+
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: .ruby-version
20
+ bundler-cache: true
21
+
22
+ - name: Scan for common Rails security vulnerabilities using static analysis
23
+ run: bin/brakeman --no-pager
24
+
25
+ scan_js:
26
+ runs-on: ubuntu-latest
27
+
28
+ steps:
29
+ - name: Checkout code
30
+ uses: actions/checkout@v4
31
+
32
+ - name: Set up Ruby
33
+ uses: ruby/setup-ruby@v1
34
+ with:
35
+ ruby-version: .ruby-version
36
+ bundler-cache: true
37
+
38
+ - name: Scan for security vulnerabilities in JavaScript dependencies
39
+ run: bin/importmap audit
40
+
41
+ lint:
42
+ runs-on: ubuntu-latest
43
+ steps:
44
+ - name: Checkout code
45
+ uses: actions/checkout@v4
46
+
47
+ - name: Set up Ruby
48
+ uses: ruby/setup-ruby@v1
49
+ with:
50
+ ruby-version: .ruby-version
51
+ bundler-cache: true
52
+
53
+ - name: Lint code for consistent style
54
+ run: bin/rubocop -f github
55
+
56
+ test:
57
+ runs-on: ubuntu-latest
58
+
59
+ # services:
60
+ # redis:
61
+ # image: redis
62
+ # ports:
63
+ # - 6379:6379
64
+ # options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
65
+ steps:
66
+ - name: Install packages
67
+ run: sudo apt-get update && sudo apt-get install --no-install-recommends -y build-essential git pkg-config google-chrome-stable
68
+
69
+ - name: Checkout code
70
+ uses: actions/checkout@v4
71
+
72
+ - name: Set up Ruby
73
+ uses: ruby/setup-ruby@v1
74
+ with:
75
+ ruby-version: .ruby-version
76
+ bundler-cache: true
77
+
78
+ - name: Run tests
79
+ env:
80
+ RAILS_ENV: test
81
+ # REDIS_URL: redis://localhost:6379/0
82
+ run: bin/rails test test:system
83
+
84
+ - name: Keep screenshots from failed system tests
85
+ uses: actions/upload-artifact@v4
86
+ if: failure()
87
+ with:
88
+ name: screenshots
89
+ path: ${{ github.workspace }}/tmp/screenshots
90
+ if-no-files-found: ignore
@@ -0,0 +1,37 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # Temporary files generated by your text editor or operating system
4
+ # belong in git's global ignore instead:
5
+ # `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore`
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore all environment files.
11
+ /.env*
12
+
13
+ # Ignore all logfiles and tempfiles.
14
+ /log/*
15
+ /tmp/*
16
+ !/log/.keep
17
+ !/tmp/.keep
18
+
19
+ # Ignore pidfiles, but keep the directory.
20
+ /tmp/pids/*
21
+ !/tmp/pids/
22
+ !/tmp/pids/.keep
23
+
24
+ # Ignore storage (uploaded files in development and any SQLite databases).
25
+ /storage/*
26
+ !/storage/.keep
27
+ /tmp/storage/*
28
+ !/tmp/storage/
29
+ !/tmp/storage/.keep
30
+
31
+ /public/assets
32
+
33
+ # Ignore master key for decrypting credentials and more.
34
+ /config/master.key
35
+
36
+ # HotDocs
37
+ /node_modules
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ echo "Docker set up on $KAMAL_HOSTS..."
@@ -0,0 +1,14 @@
1
+ #!/bin/sh
2
+
3
+ # A sample post-deploy hook
4
+ #
5
+ # These environment variables are available:
6
+ # KAMAL_RECORDED_AT
7
+ # KAMAL_PERFORMER
8
+ # KAMAL_VERSION
9
+ # KAMAL_HOSTS
10
+ # KAMAL_ROLE (if set)
11
+ # KAMAL_DESTINATION (if set)
12
+ # KAMAL_RUNTIME
13
+
14
+ echo "$KAMAL_PERFORMER deployed $KAMAL_VERSION to $KAMAL_DESTINATION in $KAMAL_RUNTIME seconds"
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ echo "Rebooted kamal-proxy on $KAMAL_HOSTS"
@@ -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,3 @@
1
+ #!/bin/sh
2
+
3
+ echo "Rebooting kamal-proxy on $KAMAL_HOSTS..."
@@ -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,8 @@
1
+ # Omakase Ruby styling for Rails
2
+ inherit_gem: { rubocop-rails-omakase: rubocop.yml }
3
+
4
+ # Overwrite or add rules to create your own house style
5
+ #
6
+ # # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
7
+ # Layout/SpaceInsideArrayLiteralBrackets:
8
+ # Enabled: false
@@ -0,0 +1 @@
1
+ ruby-3.4.1