matthieuchabert

matthieuchabert

Migrating a Phoenix app from Heroku to Render

Hi!

I’m migrating a big Phoenix project from Heroku to Render and I’d like to know if someone has done it before.

We’ll use a custom Dockerfile because we need to install a bunch of dependencies. Do you know of any good Docker image that I can use?

I came across this Medium tutorial (paywall) but it uses Docker Compose which we won’t need.

Also I’m evaluating potential unknowns. What gotchas should I be aware of?

Thank you.

Most Liked

stefanchrobot

stefanchrobot

I’ve ran an app on Render for some time, but I’ve moved to Digital Ocean’s App Platform and I’m happy with it so far. It has the same features as Render, but the console and logs feel snappier. You get some basic charts (RAM, CPU usage) out of the box for free. Other than that both do Docker + ENV and they handle HTTPS for you, which is really nice.

The advantage of Docker is that once you’re happy with your Dockerfile, you can run the same image on any platform (Heroku, Render, Digital Ocean).

Either way, here’s what Phoenix guides suggest for the Dockerfile. And here’s mine:

FROM hexpm/elixir:1.11.3-erlang-23.3.2-alpine-3.13.3 AS builder

# Install build tools.
RUN apk add --no-cache build-base nodejs=14.16.1-r1 npm=14.16.1-r1

# Prepare build directory.
WORKDIR /app

# Copy the sources.
COPY . ./

# Install Hex and Rebar.
RUN mix local.hex --force && \
    mix local.rebar --force

# Build in prod env.
ENV MIX_ENV=prod

# Get and build dependencies.
RUN mix deps.get && \
    mix deps.compile

# Build assets.
RUN cd assets && \
    npm install && \
    npm run build

# Prepare assets.
RUN mix phx.digest

# Assemble the release.
RUN mix release

# Prepare the release image.
FROM alpine:3.11.3 AS release

# Install dependencies:
# - Erlang requires ncurses-libs
# - the :ssl module dynamically links to openssl
RUN apk add --no-cache openssl ncurses-libs

WORKDIR /app
COPY --from=builder --chown=nobody:nobody /app/_build/prod/rel/app ./

# Use the user with minimal permissions.
RUN chown -R nobody:nobody /app
USER nobody:nobody
ENV HOME=/app

CMD ["sh", "-c", "bin/app eval MyApp.Release.migrate && bin/app start"]

One thing I’m doing differently is that I control the files I copy to the builder image with .dockerignore.

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New

We're in Beta

About us Mission Statement