Is this possible to deploy a Phoenix application to Google Cloud Run with MIX_ENV=dev ? For some reasons when I try deploy in dev mode, it just crash when the application starts.
Since Cloud Run is using gVisor, could this be possible that Phoenix is making some system calls that gVisor would consider as dangerous and just kill the process?
We are running MIX_ENV=prod without any problems, not sure why mix_ENV=dev wouldn’t work. Maybe phoenix_live_reload causes this because it tries to access the filesystem (and requires inotify)? You should be able to find more information in the logs on Google Cloud.
Based on this post, signal 10 is for sys_mprotect. So it seems that yes, Phoenix is making some calls in dev mode that trigger some security rules. If anyone has a workaround or more information about this, it would be really cool !
Which “execution environment” are you using? The second generation, which is still in preview though, might fix these system calls. This is what we are currently using.
According to the docs:
The second generation execution environment provides full Linux compatibility rather than system call emulation.
So I did some testing and it appears Google Cloud kills the application because the healthcheck fails. It test if the application is reachable on the given port. Since Phoenix runs on 127.0.0.1 in dev environment it isn’t available. So changing the ip configuration in config/dev.exs fixed the issue for me.
config :phoenix_cloud_run, PhoenixCloudRunWeb.Endpoint,
# Binding to loopback ipv4 address prevents access from other machines.
# Change to `ip: {0, 0, 0, 0}` to allow access from other machines.
- http: [ip: {127, 0, 0, 1}, port: 4000],
+ http: [ip: {0, 0, 0, 0}, port: 4000],
Even with the config/dev.ex update, for some reasons, this is not working for me. Do you use gen2 exec env? Anyway thanks for your help, I might have something else that is causing this crashes, I will investigate more in the next days.