Skip to content

Instantly share code, notes, and snippets.

@sporto
Last active February 24, 2016 04:33
Show Gist options
  • Save sporto/7df189a578c3c7730a2e to your computer and use it in GitHub Desktop.
Save sporto/7df189a578c3c7730a2e to your computer and use it in GitHub Desktop.
Deploy Phoenix app using docker

Deploying an Phonenix App with Docker

I'm attempting to build and deploy a Phoenix (Elixir) application using Docker. I would like to produce a container or set of container, that I can simply push to my server and run using docker-compose

1. Build container for front end

Includes IOJS NPM Copy package json, then NPM install

2. Compile FE assets

Inside the FE container, run webpack for production Assets output is ~/tmp/app/bundles in host machine

3. Build Phoenix container

Install Phoenix and Elixir stuff Copy App Install App dependencies (like gems in Rails) Compile elixir dependencies (This is a required step in elixir)

4. Digest assets for production

This needs to happen in Phoenix container Fingerprints and gzips assets To do this I mount ~/tmp/app/bundles Digested assets go to ~/tmp/app/static in host

5. Build a release

This happens in Phoenix container Mount diggested assets Release is copied to ~/tmp/app/rel in host Then release is copied to ./release in project (so the next step has access to it)

6. Build application container

This is the container that will be deployed Copy the release folder generated above to the container

Issues

  • Release produces a binary, when I shell into the app container and run the binary manually it runs. But when trying to use docker compose to run this binary, it fails with permission denied, clues?

  • Where would nginx fit into this? Another container with just nginx that pipes to the app container?

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