Hello! I run a cloud company, we want to build the best possible Phoenix deployment experience. The goal is a CLI based launch command that takes a Phoenix app directory, sets the right configuration secrets on our service (SECRET_KEY_BASE and DATABASE_URL, so far) and then builds + deploys the app as quickly as possible.
For Ruby and Rails, we just use the default Heroku builder. It works very well.
The available Phoenix buildpacks are very slow and incredibly brittle. We can’t really use those, we need a better option.
How do you all package your apps for deployment today? Specifically:
How do you all package your apps for deployment today? Specifically:
Do you use mix release?
Yes, mix release is the inbuilt and easier way to distribute elixir applications. I have used distillery and edeliver also for deployments. There are multiple Elixir PAAS vendors for elixir deployments to try if you want to.
Do you have a Dockerfile?
Yes, Dockerfile based containerization is easier to be embedded into development or deployment.
Do you run a CI system, and which one?
I have used Pipelines, Github Actions, AWS or GCP based Pipelines and also Gitlab runner.
To answer briefly, it’s a mixture of all the three for most of the deployments, based on the Client’s convenience factors and productivity factors.
Depends - when I was using my own rolled out deployer it used docker to assemble the release locally and then would just deploy it to a target, change the symlink to the new one and restart the systemd service
I’ve only recently started using Github actions but just for running tests before merge on a lib
# ---- Application Stage ----
FROM alpine:3.10 AS app
# Install openssl
RUN apk add --no-cache openssl zlib ncurses-libs ca-certificates
# Copy over the build artifact from the previous step and create a
# non-root user
RUN adduser -D app
WORKDIR /home/app
COPY _build/prod/rel/myapp .
RUN mkdir -p var/private-conf
RUN chown -R app: .
USER app
# Run the release
CMD ["./bin/myapp", "start"]
(Those are old versions I have on this computer).
I have a JavaScript build too but currently I just commit the build result. I should add a node docker image for that too.
When you use mix release but don’t package it with Docker, are you bundling everything up into a zip/tarball and deploying that? Or some other package format?
Not really, I just rsync everything.
But that only works because I don’t have to worry about the OS on the host.
I reckon the most common solution is indeed a docker container, maybe others will mention a different package format but I’m not aware of a spread solution other than docker.
We actually want to support something rsync-y too. I’m very interested in creating a hot code reload process. Once we have the first deploy for a given app done, it should be pretty straightforward to just push the release files.
I run releases in production but git pull in the prod machine and mix release right there. my dev machine and prod machine are not exactly the same so I don’t want to mess with system libraries.
How long do builds take? That buildpack gets us in the 7 minute range. Heroku’s buildpack caching is pretty good, though, are repeated deploys quicker?
Earthly is great although the caching story isn’t quite there yet, but it should get very very interesting soon. Here’s the Earthfile I use for all my projects these days: potionx/Earthfile at main · PotionApps/potionx · GitHub. You can also see the Pulumi code here and the Github Actions code here.
I don’t have an exact time, but I think it’s generally around 4-10 minutes. (But I generally deploy as part of a full CI build, and the CI portion is what takes up the majority of the time on top of that 4-10 minutes)
Do you have a Dockerfile?
Yes, most of the times. Using multistage builds, I use Docker Hub as base image for building a release and plain alpine as the runner.
I’ve deployed apps in different envs, but always used docker to package the app:
multi-cloud k8s abstracted by team infra,
heroku
AWS ECS
Do you run a CI system, and which one?
Yes. Using Github Actions now, but also used Jenkins A LOT. I also have used Circle CI and enjoyed it.
For CI I usually run mix test, check for compile warnings, sometimes use credo, and also dialyzer
extra: no matter where I’m deploying an elixir app, I find it really important to be able to: