rubyonjets/dynomite

Dynomite::DbConfig.check_local! misdetects when jets running on Docker

Closed this issue · 2 comments

I got troubles on my local development environment.

  • Jets is running on Docker container
  • DynamoDB-local is running on Docker container: amazon/dynamodb-local named dynamodb
  • both containers belongs to same docker network

DynamoDB-local running on http://dynamodb:8000

jets-container $ aws --endpoint-url http://dynamodb:8000 dynamodb list-tables                              
{
    "TableNames": []
}

config/dynamodb.yml in jets:

development:
  table_namespace: <%= Jets.config.table_namespace %>
  endpoint: http://dynamodb:8000

But jets dynamodb:migrate [path] failed.

/home/morimori/.anyenv/envs/rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/dynomite-1.2.2/lib/dynomite/db_config.rb:48:in `check_dynamodb_local!': You have configured your app to use DynamoDB local, but it is not running.  Please start DynamoDB local. Example: brew cask install dynamodb-local && dynamodb-local (RuntimeError)

I checked check_dynamodb_local!

https://github.com/tongueroo/dynomite/blob/master/lib/dynomite/db_config.rb#L43

    def check_dynamodb_local!(endpoint)
      return unless endpoint && endpoint.include?("8000")

      open = port_open?("127.0.0.1", 8000, 0.2)
      unless open
        raise "You have configured your app to use DynamoDB local, but it is not running.  Please start DynamoDB local. Example: brew cask install dynamodb-local && dynamodb-local"
      end
    end

Because Port: 8000 and host: 127.0.0.1 is hardcoded, jets cannot connect http://dynamodb:8000.

Can I fix this behavior and post PR?

RE: Can I fix this behavior and post PR?

Yes please. Thanks!

Thanks for comment!
I'll try to fix it :)