coding rails ecs docker
2019.01.13 00:00 | Kurt Tomlinson
Running delayed job in a container and on ECS is not too hard, but there are a few gotchas to watch out for. I'll show you the basic steps to getting delayed_job running and the more general steps that need to be taken when dockerizing any app.
The most important thing is to make sure that each of your jobs is written in such a way that it's not dependent on the local file system being permanent. Containers can be killed and recreated at any time, so a file that was there a minute ago might not be there now.
Once you've updated your app to be compatible with Docker, all that's left is crafting the correct Docker CMD. In a Dockerfile, you'd write something like this:
CMD bundle exec bin/delayed_job run
However, this gets a bit more tricky in ECS. ECS interprets commands as arrays, so you need to use commas instead of spaces:
# Edit container > Environment > Command
And that's about it for running delayed job in a Docker container on ECS. Check out my other articles about Dockerizing Ruby apps in the box at the top of this article.
Let me know in the comments if this article was helpful or if I missed anything!
Photo by Clark Young