I have a docker container: (called Dockerfile.web
, relevant parts)
ARG PORT=3000
ENV PORT=$PORT
EXPOSE $PORT
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["rails", "server"]
Puma: config/puma.rb
before_fork do
ActiveRecord::Base.connection_pool.disconnect! if defined? ActiveRecord
end
on_worker_boot do
ActiveRecord::Base.establish_connection if defined? ActiveRecord
end
preload_app!
So when I run heroku container:push web
followed by heroku container:release web
, the app deploys, but the puma server doesn't come up b/c the port cannot be connected to:
Booting Puma
Rails 5.2.2 application starting in development
Run `rails server -h` for more startup options
Puma starting in cluster mode...
* Version 3.12.0 (ruby 2.6.0-p0), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Process workers: 1
* Preloading application
* Listening on tcp://localhost:41626
Use Ctrl-C to stop
- Worker 0 (pid: 28) booted, phase: 0
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
Stopping process with SIGKILL
I'm following the official guide but I haven't added the sections:
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
Where could my error be? Any ideas?
I'm not sure why you left this part out:
port ENV['PORT'] || 3000
You can't pick your own port. Use the $PORT
that Heroku gives you.