Posting a few pointers that fixed this issue for me and a warning against several insecure suggestions for accessing DATABASE_URL during build time.
- Securely handling DATABASE_URL at buildtime
Do not use ARG (–build-arg) or ENV, do not hardcode the url. You can use Docker secrets as described here: Build Secrets · Fly Docs
-
Chained commands with secrets
What is a little unclear is whether secrets are propagated to chained commands, the docs show && more_commands_maybe. However, the fly deploy --build-secret only resolved with the first command (i.e. some_command) for me. -
Database connection during build time
Database connections during Docker build are not available with Depot. If you are experiencing a database connection error during build time try --depot=false in your flyctl deploy command
Cannot deploy using build-time database connection for last 24hr - #4 by joshua-fly
I hope this information saves you time.