If your application is going mad about the database being not available, you can insert a "wait-for-port" call at the beginning of the entrypoint. This only makes sense if you stick to docker-compose. But a better solution will be using Kubernetes.
There are many implementations of wait-for programs around, but here is the Bitnami's Go binary: https://github.com/bitnami/wait-for-port
If you need run a sequence of jobs, here is the same question with good answers: https://stackoverflow.com/questions/40713573/how-to-run-containers-sequentially-as-a-kubernetes-job