Hi
what is the right format to chain commands in the “Docker command” settings in order to run the following: flask db upgrade, flask translate compile and then the command to run the application?
At the moment when calling this command the deployment is successful:
gunicorn src.app:create_main_and_celery_apps()
but before doing this I need to run the other 2 flask commands
Note: FLASK_APP has been set to src.app:create_main_and_celery_apps()
You can chain commands like this: “command 1 && command 2” or like this: “command 1; command 2;”
The difference between the 2 methods lies in how the second command is executed relative to the success or failure of the first command.
When you use "&&" to chain commands… command2 will only be executed if command1 succeeds (returns a zero exit status). Example:
echo "This is command 1" && echo "This is command 2"
In this case, “This is command 2” will only be printed if “This is command 1” is printed successfully.
When you use ";" to chain commands… command2 will be executed regardless of whether command1 succeeds or fails (irrespective of its exit status). Example:
echo "This is command 1"; echo "This is command 2"
Here, “This is command 2” will be printed even if there is some problem with printing “This is command 1” (although echo is likely to succeed in this trivial case).
Good morning Jeremy
I might be doing something wrong but I tried your suggestion and it seems to me that it is not working.
I used your suggested command, echo “This is command 1” && echo “This is command 2” and this is the output
I also tried launching my flask app in between the echo commands but the application is not launched
The ‘echo’ statements were merely examples to demonstrate how you can chain commands on Render. You could use something like ‘flask db upgrade && flask translate compile && src.app:create_main_and_celery_apps’ for your build and start commands. Since you’re using a Docker environment, these would need to be applied within the Dockerfile, at least for the build phase.
Hi Jeremy
thanks for getting back me and sorry for not being clear. Yes I understand the echos were examples, but based on the screenshot I provided, it seems to be that even that simple chained commands is not working, maybe I am wrong.
AnywayI tried specifying this command instead, with and without the quote, without success
flask db upgrade && flask translate compile && src.app:create_main_and_celery_apps
If I run any of the above commands independently (not chained) they work but as soon as I chained them I get an error.
For example with this command: flask db upgrade && flask translate compile, I get this error: