New to Docker, but I was able to dockerize a rails api, run it locally on Mac and everything works fine. After that I deployed to AWS ECS Fargate and the service starts fine (logs below)
=> Booting Puma => Rails 5.2.1 application starting in production => Run `rails server -h` for more startup options Puma starting in single mode... * Version 3.12.0 (ruby 2.4.1-p111), codename: Llamas in Pajamas * Min threads: 5, max threads: 5 * Environment: production * Listening on tcp://0.0.0.0:3000 Use Ctrl-C to stop
Then I call the API in Postman and as expected it returns a db not found message…
“error”: “Internal Server Error”,
“exception”: “#<ActiveRecord::NoDatabaseError: FATAL: database “railsapi_db” does not exist\n>”,
“Application Trace”: ,
“Framework Trace”: [
So far so good. Then I create a task definition in ECS with a command override to run a rake command to create the db…
The task fails with the following error message.
|Status reason|CannotStartContainerError: API error (400): OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"rails db:setup\": executable file not found in $PATH": unknown| |---|---| |Command|["rails db:setup"]|
No logs are generated by Fargate…
I’m sure many have deployed rails APIs to Fargate and wondering how they execute commands like rails db:setup or create migrate etc?
.Any thoughts / suggestions?