Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Kamal by default to Rails 8 #51798

Merged
merged 18 commits into from
May 14, 2024
Merged

Add Kamal by default to Rails 8 #51798

merged 18 commits into from
May 14, 2024

Conversation

dhh
Copy link
Member

@dhh dhh commented May 12, 2024

Rails should have a default answer to deploying applications out of the box to cloud or bare metal. Kamal is that answer. We'll configure it automatically as far as we can, but allow an opt-out with --skip-kamal.

@rails-bot rails-bot bot added the railties label May 12, 2024
@dhh dhh added this to the 8.0.0 milestone May 12, 2024
@dhh
Copy link
Member Author

dhh commented May 12, 2024

cc @djmb

@dhh
Copy link
Member Author

dhh commented May 13, 2024

Unrelated flaky build failures.

@dhh
Copy link
Member Author

dhh commented May 13, 2024

The flaky tests that keep tripping intermittently:

image

@dhh dhh merged commit bee3fa4 into main May 14, 2024
2 of 5 checks passed
@dhh dhh deleted the kamal-by-default branch May 14, 2024 00:32
@dhh
Copy link
Member Author

dhh commented May 14, 2024

Closes #50441

dhh added a commit that referenced this pull request May 14, 2024
@laptopmutia
Copy link

laptopmutia commented May 14, 2024

some people really work like a beast!

thanks for your hardwork

@plattenschieber
Copy link

Should we also adapt the base kamal deploy config to reflect the new default config?

The diff
diff --git a/config/deploy.yml b/config/deploy.yml
index de5a4d4..2602c66 100644
--- a/config/deploy.yml
+++ b/config/deploy.yml
@@ -1,23 +1,18 @@
# Name of your application. Used to uniquely configure containers.
-service: application
+service: my-app

# Name of the container image.
-image: your-user/application
+image: user/my-app

# Deploy to these servers.
servers:
-  web:
-    - 192.168.0.1
-  # job:
-  #   hosts:
-  #     - 192.168.0.1
-  #   cmd: bin/solid_queue work
+  - 192.168.0.1

# Credentials for your image host.
registry:
 # Specify the registry server, if you're not using Docker Hub
 # server: registry.digitalocean.com / ghcr.io / ...
-  username: your-user
+  username: my-user

 # Always use an access token rather than real password when possible.
 password:
@@ -25,43 +20,25 @@ registry:

# Inject ENV variables into containers (secrets come from .env).
# Remember to run `kamal env push` after making changes!
-env:
-  secret:
-    - RAILS_MASTER_KEY
-  # clear:
-  #   DB_HOST: 192.168.0.2
-
-
-# Use a persistent storage volume for sqlite database files and local Active Storage files.
-# Recommended to change this to a mounted volume path that is backed up off server.
-volumes:
-  - "application_storage:/rails/storage"
-
-
-# Bridge fingerprinted assets, like JS and CSS, between versions to avoid
-# hitting 404 on in-flight requests. Combines all files from new and old
-# version inside the asset_path.
-asset_path: /rails/public/assets
+# env:
+#   clear:
+#     DB_HOST: 192.168.0.2
+#   secret:
+#     - RAILS_MASTER_KEY

# Use a different ssh user than root
# ssh:
#   user: app

-# Configure builder setup (defaults to multi-arch images).
+# Configure builder setup.
# builder:
-#   # Build same-arch image locally (use for x86->x86)
-#   multiarch: false
-#
-#   # Build diff-arch image via remote server
-#   remote:
-#     arch: amd64
-#     host: ssh://app@192.168.0.1
-#
#   args:
-#     RUBY_VERSION: 3.3.1
+#     RUBY_VERSION: 3.2.0
#   secrets:
#     - GITHUB_TOKEN
-#     - RAILS_MASTER_KEY
+#   remote:
+#     arch: amd64
+#     host: ssh://app@192.168.0.1

# Use accessory services (secrets come from .env).
# accessories:
@@ -85,3 +62,40 @@ asset_path: /rails/public/assets
#     port: 6379
#     directories:
#       - data:/data
+
+# Configure custom arguments for Traefik. Be sure to reboot traefik when you modify it.
+# traefik:
+#   args:
+#     accesslog: true
+#     accesslog.format: json
+
+# Configure a custom healthcheck (default is /up on port 3000)
+# healthcheck:
+#   path: /healthz
+#   port: 4000
+
+# Bridge fingerprinted assets, like JS and CSS, between versions to avoid
+# hitting 404 on in-flight requests. Combines all files from new and old
+# version inside the asset_path.
+#
+# If your app is using the Sprockets gem, ensure it sets `config.assets.manifest`.
+# See https://github.com/basecamp/kamal/issues/626 for details
+#
+# asset_path: /rails/public/assets
+
+# Configure rolling deploys by setting a wait time between batches of restarts.
+# boot:
+#   limit: 10 # Can also specify as a percentage of total hosts, such as "25%"
+#   wait: 2
+
+# Configure the role used to determine the primary_host. This host takes
+# deploy locks, runs health checks during the deploy, and follow logs, etc.
+#
+# Caution: there's no support for role renaming yet, so be careful to cleanup
+#          the previous role on the deployed hosts.
+# primary_role: web
+
+# Controls if we abort when see a role with no hosts. Disabling this may be
+# useful for more complex deploy configurations.
+#
+# allow_empty_roles: false

@dhh
Copy link
Member Author

dhh commented May 28, 2024

No, the base Kamal can't be Rails specific. Lots of Kamal users in other environments than Rails.

xjunior pushed a commit to xjunior/rails that referenced this pull request Jun 9, 2024
jianbo pushed a commit to jianbo/setter-with-association that referenced this pull request Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants