release_command with multiple commands

Hello,

I have an Elixir app which has more than one release_command to run (seeds and migrations). I tried to concat my three commands using “&&” but that does not work. When I am doing in on the machine itself via ssh console it works though. :man_shrugging:

Any ideas?

Unfortunately docs don’t have a section about release command unless the part in the Elixir guide.

1 Like

You can create a bash script that runs your other commands. The flyctl source has an example: flyctl/example at master · superfly/flyctl · GitHub

2 Likes

Hey @mathiasn how are you running your seeds in there? Can you share an example of how your release script looks like please? I need to do the same here.

Sure. I have a rel/overlays/release.sh with the following content basically

#!/usr/bin/env sh

/app/bin/my_app eval 'MyApp.Release.migrate'
/app/bin/my_app eval 'MyApp.Release.seed(Elixir.MyApp.Repo, "seeds.exs")'

In my fly.toml is a section like this

[deploy]
  release_command = "sh release.sh"

THat’s it :slight_smile:

Thanks @mathiasn ! That helped a lot!

Does the release.sh needs to be under rel/overlays/ though? Because I see you’re invoking it in the fly.toml without its path.

I’m asking because I tried leaving my script on the root folder and under rel/overlays and I’m getting sh: 0: cannot open release_command.sh: No such file