Skip to content

Instantly share code, notes, and snippets.

@gabrieljoelc
Last active May 22, 2017 18:01
Show Gist options
  • Save gabrieljoelc/f4995f8af406d3c6a932e333ee30d0e2 to your computer and use it in GitHub Desktop.
Save gabrieljoelc/f4995f8af406d3c6a932e333ee30d0e2 to your computer and use it in GitHub Desktop.

Generic Host w/ Docker

WORKDIR /opt/app

ENV MIX_ENV=prod

# Cache node deps
COPY package.json ./
RUN npm install

and package.json:

"dependencies": {
  "phoenix": "file:deps/phoenix",
  "phoenix_html": "file:deps/phoenix_html"
}

I've tried lots of things but still can't figure it out.

  • I figured it out. The npm install line needed to be after mix deps.get runs so that deps/phoenix and deps/phoenix_html exist.
  • I got Dockerfile.release working with Docker Compose, but now I'm stuck on how to create a database for Dockerfile.release. I'm trying to create the prod database from within the docker-compose.yml web service:
# host
docker run -it --rm -e MIX_ENV=prod -e DB_HOST=db a540246dbcc5 /bin/bash

# container
MIX_ENV=prod mix deps.get
MIX_ENV=prod mix compile
MIX_ENV=prod mix ecto.create
07:10:27.256 [error] GenServer #PID<0.178.0> terminating
** (DBConnection.ConnectionError) tcp connect (${DB_HOST}:5432): non-existing domain - :nxdomain
    (db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2
    (connection) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
** (Mix) The database for HelloWorld.Repo couldn't be created: an exception was raised:
    ** (DBConnection.ConnectionError) tcp connect (${DB_HOST}:5432): non-existing domain - :nxdomain
        (db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2
        (connection) lib/connection.ex:622: Connection.enter_connect/5
        (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

Heroku Only

Without Docker (buildpacks)

Following the config steps on here.

Output: PR

With Docker

I'm going to try and use this

Misc work

Other resources I'm considering

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment