title: How to create/migrate Elixir Phoenix Docker image on Heroku?
body: <p>I am trying to figure out how to run Elixir Phoenix on Heroku using Docker. I am pretty much using this Dockerfile: (<a href="https://github.com/jpiepkow/phoenix-docker/blob/master/Dockerfile" rel="nofollow noreferrer">https://github.com/jpiepkow/phoenix-docker/blob/master/Dockerfile</a>)</p>
  
  <pre><code># ---- Build Base Stage ----
  FROM elixir:1.9.1-alpine AS app_builder
  RUN apk add --no-cache=true \
      gcc \
      g++ \
      git \
      make \
      musl-dev
  RUN mix do local.hex --force, local.rebar --force   
  
  # ---- Build Deps Stage ----
  FROM app_builder as deps
  COPY mix.exs mix.lock ./
  ARG MIX_ENV=prod
  ENV MIX_ENV=$MIX_ENV
  RUN mix do deps.get --only=$MIX_ENV, deps.compile
  
  # ---- Build Release Stage ----
  FROM deps as releaser
  RUN echo $MIX_ENV
  COPY config ./config
  COPY lib ./lib
  COPY priv ./priv
  RUN mix release &amp;&amp; \
      cat mix.exs | grep app: | sed -e 's/ app: ://' | tr ',' ' ' | sed 's/ //g' &gt; app_name.txt
  
  # ---- Final Image Stage ----
  FROM alpine:3.9 as app
  RUN apk add --no-cache bash libstdc++ openssl
  ENV CMD=start
  COPY --from=releaser ./_build .
  COPY --from=releaser ./app_name.txt ./app_name.txt
  CMD ["sh","-c","./prod/rel/$(cat ./app_name.txt)/bin/$(cat ./app_name.txt) $CMD"]
  </code></pre>
  
  <p>I have pushed to Heroku and the app is running but when I try to using database things that's when it blows up. The logs say the database needs to be migrated, which makes sense since I haven't done it. But now I realize I'm not sure how to do that when <code>mix</code> is not available and I'm using Docker.</p>
  
  <p>Does anyone know how to create and migrate postgres heroku when deployed with Docker?</p>