I attempted to deploy a Rails API application using 1 Click Ruby on Rails option on digital ocean but each time I try to deploy the application I get a health check error.
The build stage is successful:
But it fails when it gets to the deployment stage and there are no details on this error in the logs.
I tried checking the error logs but instead the server appears to be running.
What i have tried so far:
Switched between the scheduled HTTP or TCP under health check in digital ocean.
Confirmed if the droplet is live:
Used the rails build pack to create a new application in the droplet:
::: Current build pack:::: Custom Build Command v0.1.2 Procfilev 0.0.4 Ruby: v1.244.3 ::::::::::::::::::::::::::::::::
Setup the correct environment variables for the app on the digital ocean console.
RAILS_MASTER_KEY=..correct key ommited deliberately..
RACK_ENV=development
RAILS_ENV=development
RAILS_LOG_TO_STDOUT=enabled
RAILS_SERVE_STATIC_FILES=enabled
SECRET_KEY_BASE=key correct ommited deliberately..
In addition,I am currently on the basic plan which should allow me to deploy a rails application and i also tried setting the app level environment variables but they are were overriden by the env i initially setup when creating a new app.
My setup:
Ruby and Rails versions:
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin20] Rails 7.1.3
platform configs in gemfile:
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] group :development, :test do gem 'debug', platforms: %i[mri mingw x64_mingw] end (edited)
The App Platform Error Code Reference stipulates that this issue is caused by *
the container not responding to health checks. If a health check is failing, that means that external traffic is not reaching my service at the expected HTTP route
*.How do ensure external traffic is reaching my service to resolve this if this is the solution?
Finally resolved the issue by updating my environment variables by removing RAILS_SERVE_STATIC_FILES=enabled
and SECRET_KEY_BASE
and then changed the RACK_ENV
and RAILS_ENV
from development to production.
The application deployed successfully.Health check error resolved.
Before
RAILS_MASTER_KEY=..correct key ommited deliberately..
RACK_ENV=development
RAILS_ENV=development
RAILS_LOG_TO_STDOUT=enabled
RAILS_SERVE_STATIC_FILES=enabled
SECRET_KEY_BASE=key correct ommited deliberately..
Updated
RAILS_MASTER_KEY=..correct key ommited deliberately..
RACK_ENV=production
RAILS_ENV=production
RAILS_LOG_TO_STDOUT=enabled