Skip to content

Commit

Permalink
Add support for using kamal inside of the generated devcontainer
Browse files Browse the repository at this point in the history
Kamal requires docker. The docker-in-docker devcontainer feature allow
running docker inside the container.
  • Loading branch information
JoeDupuis committed Oct 16, 2024
1 parent aeb0828 commit 91cacf7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions railties/lib/rails/generators/rails/app/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ def devcontainer
devcontainer_options = {
database: options[:database],
redis: options[:skip_solid] && !(options[:skip_action_cable] && options[:skip_active_job]),
kamal: !options[:skip_kamal],
system_test: depends_on_system_test?,
active_storage: !options[:skip_active_storage],
dev: options[:dev],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class DevcontainerGenerator < Base # :nodoc:
class_option :dev, type: :boolean, default: false,
desc: "For applications pointing to a local Rails checkout"

class_option :kamal, type: :boolean, default: true,
desc: "Include configuration for Kamal"


source_paths << File.expand_path(File.join(base_name, "app", "templates"), base_root)

def create_devcontainer
Expand Down Expand Up @@ -80,6 +84,7 @@ def container_env
@container_env["CAPYBARA_SERVER_PORT"] = "45678" if options[:system_test]
@container_env["SELENIUM_HOST"] = "selenium" if options[:system_test]
@container_env["REDIS_URL"] = "redis://redis:6379/1" if options[:redis]
@container_env["KAMAL_REGISTRY_PASSWORD"] = "$KAMAL_REGISTRY_PASSWORD" if options[:kamal]
@container_env["DB_HOST"] = database.name if database.service

@container_env
Expand All @@ -105,6 +110,7 @@ def features

@features["ghcr.io/rails/devcontainer/features/activestorage"] = {} if options[:active_storage]
@features["ghcr.io/devcontainers/features/node:1"] = {} if options[:node]
@features["ghcr.io/devcontainers/features/docker-in-docker:2"] = {} if options[:kamal]

@features.merge!(database.feature) if database.feature

Expand Down

0 comments on commit 91cacf7

Please sign in to comment.