Can't deploy my Phoenix app to Aptible because compilation time is so long. Any tips?

I’m exploring using Aptible (it’s like Heroku) to host my Phoenix app.

The problem is that there’s a max of 900 seconds for the health check to ping my app:

My application takes about 17 minutes to compile. Tested using mix compile locally.

Is there any way for me to address this?

Ouch, that’s kinda crazy. How many dependencies do you have? Are you not able to cache the compilation of dependencies?

75 packages in our dependencies.

How could I cache this? Aptible works by pushing to a remote git branch, and a Dockerfile performs installs, compiles, yada yada, then finally mix phx.server.

Normally this is a feature of the build platform. Honestly I find aptible’s policy here confusing. It makes sense for an already built artifact to respond within x seconds after an attempted deployment, but they’re including building + deploying as one step which is quite odd.

See if there is a way to build as a separate step from deploying maybe?

I have 98 in my mix.lock file and a full rebuild takes 2 min, 25 seconds, including a rust dependency that takes quite a while to build. 17 minutes is still crazy long to me.

1 Like

May I suggest perhaps building a ready-made Docker container with an Elixir release, for example, that you then can deploy directly?


Yeah this is the first time I’ve seen an Elixir project take so long to compile.

Do you guys have any ideas on what the issue could be? How I could figure out what’s taking so long to compile?

1 Like

Well the output of the compiler itself would be a good start, especially if it’s timestamped (or, say, streamed to something saving and timestamping it as such)?

1 Like

Turns out you can build to your hearts content (timewise) in the Dockerfile.

Support asked me to pass the --no-compile flag to mix phx.server so we’ll see how that turns out and I’ll write a guide for deploying Phoenix apps to Aptible.

The final CMD in my Dockerfile is the one that has a time limit on it, and by passing no-compile the time should be shortened.

In general in build-only docker containers I build in prior steps and the final CMD is either to launch the program or to run a set of tests.