companionstudio / instagram-token-agent

A service to keep your Instagram Basic Display API token fresh.
MIT License
133 stars 70 forks source link

using docker to run the instagram-token-agent. #6

Closed larssb closed 4 years ago

larssb commented 4 years ago

INTRO

I'm trying to setup this instagram-token-agent as part of using InstaFeed towards the new Instagram Basic Display API.

I'm more than willing to share the Docker setup when done. However, I need some pointers as I'm not a particularly experienced Ruby developer to put it mildly. PR and all that jazz 👍

THE ISSUE

So I've been able to install the Gems, postgres. Postgres is running/started. I've set the export DATABASE_URL="https://127.0.0.1:5432" environment variable. However, the following error is thrown:

$ bundle exec rake setup --trace
Rails backports are deprecated.
rake aborted!
LoadError: Could not load the 'https' Active Record adapter. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile.
/Users/lars/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `block in require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:291:in `load_dependency'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/connection_specification.rb:170:in `spec'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:1054:in `establish_connection'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_handling.rb:51:in `establish_connection'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-activerecord-2.0.14/lib/sinatra/activerecord.rb:50:in `database='
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1234:in `set'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-activerecord-2.0.14/lib/sinatra/activerecord.rb:20:in `registered'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1416:in `block in register'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1414:in `each'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1414:in `register'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1907:in `register'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1968:in `register'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-activerecord-2.0.14/lib/sinatra/activerecord.rb:61:in `<module:Sinatra>'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-activerecord-2.0.14/lib/sinatra/activerecord.rb:10:in `<top (required)>'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:88:in `require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:88:in `rescue in block in require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:65:in `block in require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:58:in `each'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:58:in `require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler.rb:174:in `require'
/Users/lars/gitRepos/instagram-token-agent/app.rb:5:in `<top (required)>'
/Users/lars/gitRepos/instagram-token-agent/Rakefile:1:in `require'
/Users/lars/gitRepos/instagram-token-agent/Rakefile:1:in `<top (required)>'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load_rakefile'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:703:in `raw_load_rakefile'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:104:in `block in load_rakefile'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:103:in `load_rakefile'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:82:in `block in run'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/Users/lars/.rvm/gems/ruby-2.6.5/bin/rake:23:in `load'
/Users/lars/.rvm/gems/ruby-2.6.5/bin/rake:23:in `<main>'
/Users/lars/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
/Users/lars/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'

Caused by:
LoadError: cannot load such file -- active_record/connection_adapters/https_adapter
/Users/lars/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `block in require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:291:in `load_dependency'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:325:in `require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/connection_specification.rb:170:in `spec'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:1054:in `establish_connection'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/activerecord-6.0.2.2/lib/active_record/connection_handling.rb:51:in `establish_connection'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-activerecord-2.0.14/lib/sinatra/activerecord.rb:50:in `database='
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1234:in `set'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-activerecord-2.0.14/lib/sinatra/activerecord.rb:20:in `registered'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1416:in `block in register'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1414:in `each'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1414:in `register'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1907:in `register'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1968:in `register'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-activerecord-2.0.14/lib/sinatra/activerecord.rb:61:in `<module:Sinatra>'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/sinatra-activerecord-2.0.14/lib/sinatra/activerecord.rb:10:in `<top (required)>'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:88:in `require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:88:in `rescue in block in require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:65:in `block in require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:58:in `each'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:58:in `require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler.rb:174:in `require'
/Users/lars/gitRepos/instagram-token-agent/app.rb:5:in `<top (required)>'
/Users/lars/gitRepos/instagram-token-agent/Rakefile:1:in `require'
/Users/lars/gitRepos/instagram-token-agent/Rakefile:1:in `<top (required)>'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load_rakefile'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:703:in `raw_load_rakefile'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:104:in `block in load_rakefile'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:103:in `load_rakefile'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:82:in `block in run'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/Users/lars/.rvm/gems/ruby-2.6.5/bin/rake:23:in `load'
/Users/lars/.rvm/gems/ruby-2.6.5/bin/rake:23:in `<main>'
/Users/lars/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
/Users/lars/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'

Caused by:
LoadError: cannot load such file -- sinatra-activerecord
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:74:in `require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:74:in `block (2 levels) in require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:69:in `each'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:69:in `block in require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:58:in `each'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler/runtime.rb:58:in `require'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/bundler-2.1.2/lib/bundler.rb:174:in `require'
/Users/lars/gitRepos/instagram-token-agent/app.rb:5:in `<top (required)>'
/Users/lars/gitRepos/instagram-token-agent/Rakefile:1:in `require'
/Users/lars/gitRepos/instagram-token-agent/Rakefile:1:in `<top (required)>'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load_rakefile'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:703:in `raw_load_rakefile'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:104:in `block in load_rakefile'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:103:in `load_rakefile'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:82:in `block in run'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
/Users/lars/.rvm/gems/ruby-2.6.5/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/Users/lars/.rvm/gems/ruby-2.6.5/bin/rake:23:in `load'
/Users/lars/.rvm/gems/ruby-2.6.5/bin/rake:23:in `<main>'
/Users/lars/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `eval'
/Users/lars/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:24:in `<main>'

Yes I sure don't have a config or a database.yml file. Also, I think the postgres setup I have is not compatible with the way the instagram-token-agent app is "looking" for a database to connect to. Specifically (this)[https://github.com/companionstudio/instagram-token-agent/blob/d88e0192cbe88083295afdfcca9c0c6dfdc28e33/lib/instagram_token_agent/store.rb#L8] part of the code. Where a connection pool is used.

SETUP

SEEKING

Guidance/help on how-to get over this bump of setting the app on my Mac so that I can continue my journey into getting this to work in a container. So, if there is more info that could be helpful to me in regards to getting to the above end goal I'll be more than happy to get that.

Thank you very much 💯

larssb commented 4 years ago

Anyone? Maybe you @benjamin-hull .... thank you.

benjamin-hull commented 4 years ago

Hi @larssb, apologies for the delayed response - I've been out of action the past few days.

As it stands, you'll need a config/database.yml file to run this in development mode. This is left out of source control as it will generally need DB credentials which you won't want to commit. I haven't tried running it via environment variables as Heroku will.

In its simplest form your database.yml file can look like this (assuming using an unprotected development DB):

# Provide the DB connection params for your environments.
# On Heroku, these params are taken from the environment, and this file is not used
#
# Valid keys are:
# - host
# - port
# - options
# - dbname
# - user
# - password

default: &default
  adapter: postgresql
  encoding: unicode
  port: 5432
  pool: 5

development:
  <<: *default
  dbname: instagram-token-agent

test:
  <<: *default
  dbname: instagram-token-agent-test

production:
  <<: *default
  dbname: instagram-token-agent

Once you add that file, you'll also need to run:

I also don't have much experience with Docker, so I'm not sure how that will be affected if at all.

benjamin-hull commented 4 years ago

Hi again @larssb - just a heads-up, a Docker compatible fork of the repo has been created here: https://github.com/maxiR8/instagram-token-agent - I haven't tested it myself, but you might want to check it out.

benjamin-hull commented 4 years ago

Closing for now, as I don't have docker experience, and can't commit to maintaining the functionality.