Hello Fly team!
I’m experimenting and learning about Fly and I’m attempting to deploy an Elixir/Phoenix app (more complex than a simple example app). I’m building a Docker image with the usual Mix release flow and I’ve also managed to have the release running in a local Docker instance.
My deployments always fail and I can’t figure out why. Probably some misconfiguration or some detail I’m missing on the live environment. However, logs never show the actual application or container logs and this is making it pretty much impossible to determine the root cause of these issues.
These are the deployment logs, VM status and fly.toml
(app and module names omitted for privacy reasons):
Deployment logs
2022-04-05T16:14:45Z [info]Preparing to run: `bin/<my_app> eval <MyApp>Server.Release.migrate() bin/<my_app> start` as nobody
2022-04-05T16:14:45Z [info]2022/04/05 16:14:45 listening on [fdaa:0:5467:a7b:2656:9ef1:c108:2]:22 (DNS: [fdaa::3]:53)
2022-04-05T16:14:47Z [info]Starting release migrations...
2022-04-05T16:14:47Z [info]Running migrations for repo <MyApp>Server.Queue.Repo
2022-04-05T16:14:47Z [info]Running migrations for repo <MyApp>.<MyModule>.Repo
2022-04-05T16:14:47Z [info][info] [erl_level=info application=ecto_sql domain=elixir file=lib/ecto/migrator.ex function=log/2 line=708 mfa=Ecto.Migrator.log/2 module=Ecto.Migrator pid=<0.95.0> ] Migrations already up
2022-04-05T16:14:47Z [info][info] [erl_level=info application=ecto_sql domain=elixir file=lib/ecto/migrator.ex function=log/2 line=708 mfa=Ecto.Migrator.log/2 module=Ecto.Migrator pid=<0.95.0> ] Migrations already up
2022-04-05T16:14:47Z [info]Done
2022-04-05T16:14:47Z [info]Main child exited normally with code: 0
2022-04-05T16:14:47Z [info]Reaped child process with pid: 562 and signal: SIGUSR1, core dumped? false
2022-04-05T16:14:47Z [info]Starting clean up.
--> v40 failed - Failed due to unhealthy allocations - rolling back to job version 39 and deploying as v41
--> Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/
Error abort
VM status logs
Instance
ID = 93a99fa4
Process =
Version = 42
Region = mad
Desired = stop
Status = failed
Health Checks = 1 total, 1 critical
Restarts = 2
Created = 8m6s ago
Recent Events
TIMESTAMP TYPE MESSAGE
2022-04-05T16:24:03Z Received Task received by client
2022-04-05T16:24:03Z Task Setup Building Task Directory
2022-04-05T16:24:11Z Started Task started by client
2022-04-05T16:24:15Z Terminated Exit Code: 0
2022-04-05T16:24:15Z Restarting Task restarting in 1.192250481s
2022-04-05T16:24:22Z Started Task started by client
2022-04-05T16:24:26Z Terminated Exit Code: 0
2022-04-05T16:24:26Z Restarting Task restarting in 1.017804191s
2022-04-05T16:24:33Z Started Task started by client
2022-04-05T16:24:37Z Terminated Exit Code: 0
2022-04-05T16:24:37Z Not Restarting Exceeded allowed attempts 2 in interval 5m0s and mode is "fail"
2022-04-05T16:24:38Z Killing Sent interrupt. Waiting 5s before force killing
Checks
ID SERVICE STATE OUTPUT
29f781710b9ea2332624cf1966c0c544 tcp-8080 critical dial tcp 172.19.2.130:8080: connect: connection refused
Recent Logs
fly.toml
app = "<my_app>"
kill_signal = "SIGINT"
kill_timeout = 5
[build]
dockerfile = "build/Dockerfile"
[env]
<REDACTED>
[deploy]
release_command = "/app/bin/<my_app> eval <MyApp>Server.Release.migrate()"
[experimental]
allowed_public_ports = []
auto_rollback = true
[[services]]
internal_port = 8080
protocol = "tcp"
[services.concurrency]
hard_limit = 25
soft_limit = 20
[[services.ports]]
# force_https = true
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "300s"
interval = "15s"
restart_limit = 6
timeout = "15s"
I’m not sure where the problem may be, although my main cause for being blocked is the lack of app logs. The health checks I’ve tried (both TCP, HTTP and HTTPS) all fail, but this looks like it’s because the app never fully executes. Furthermore, I’ve tinkered around with the VM memory, but the metrics never show memory usage over 40MB so the lowest 256MB should suffice. Another approach I attempted was to simplify the configuration following the Fly deployment guide on the official Phoenix documentation.
Any help with this would be appreciated