I've made a simple Ruby api, using Sinatra. It accesses an mlabs mongodb using Mongoid. If I run docker-compose build
followed by docker-compose up
, I can access and use the api on localhost. However, if I push and release to Heroku using heroku container:push web
and heroku container:release web
, it crashes a few seconds after starting. The Heroku logs don't provide much info:
2019-03-07T17:40:33.307048+00:00 app[api]: Release v10 created by user ****@gmail.com
2019-03-07T17:40:33.307048+00:00 app[api]: Deployed web (4cd454c25995) by user user ****@gmail.com
2019-03-07T17:40:33.485337+00:00 heroku[web.1]: State changed from crashed to starting
2019-03-07T17:40:56.940967+00:00 heroku[web.1]: Starting process with command `irb`
2019-03-07T17:40:59.715826+00:00 heroku[web.1]: State changed from starting to crashed
2019-03-07T17:40:59.696826+00:00 heroku[web.1]: Process exited with status 0
2019-03-07T17:40:59.630419+00:00 app[web.1]: Switch to inspect mode.
2019-03-07T17:40:59.631325+00:00 app[web.1]:
My Dockerfile:
FROM ruby:2.5.3
RUN apt-get update -qq && apt-get install -y build-essential
RUN gem install bundler
ENV APP_HOME /app
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
ADD Gemfile* $APP_HOME/
ADD mongoid.config $APP_HOME/
RUN bundle install
ADD . $APP_HOME
My docker-compose.yml:
version: "2"
services:
web:
build: .
command: bundle exec ruby server.rb
ports:
- "80:4567"
My Mongoid configuration (mongoid.config):
development:
clients:
default:
uri: mongodb://myUsername:myPassword@hostAddress:hostPort/databaseName
Where myUsername, myPassword, hostAddress, hostPort and databaseName is switched out for the actual values.
In my ruby file, I load the Mongoid configuration with Mongoid.load! "mongoid.config"
.
My Gemfile, for completeness:
source 'https://rubygems.org'
gem 'sinatra'
gem 'mongoid'
gem 'sinatra-contrib'
Does anyone have an idea on how I can find out what causes the crash?