Git Product home page Git Product logo

docker-heroku-phoenix's Introduction

Docker-Heroku-Phoenix

This is a Dockerfile and Docker image for use with Phoenix Framework apps on the Heroku Platform. This is a workflow that largely replaces git push and buildpacks and offers a higher level of dev-prod parity. For more on the workflow, checkout the Heroku Devcenter.

This image a bit more generic than the title lets on. It's not tied to any Phoenix libraries or Brunch, so it's feasible for use on any project that is built on Elixir and Node that you'd like to deploy to Heroku.

What this does:

  • Starts from the base heroku/cedar:14 docker image.
  • Builds and Installs Erlang from source.
  • Builds and Installs Elixir from source.
  • Builds and Installs Node.js from source.
  • Installs Hex, the package manager for Elixir.
  • Installs NPM, the package manager for Node.

Example Usage:

A Dockerfile for a vanilla Phoenix app going to prod would look like this:

FROM joshwlewis/docker-heroku-phoenix:latest

# Compile elixir files for production
ENV MIX_ENV prod
# This prevents us from installing devDependencies
ENV NODE_ENV production
# This causes brunch to build minified and hashed assets
ENV BRUNCH_ENV production

# We add manifests first, to cache deps on successive rebuilds
COPY ["mix.exs", "mix.lock", "/app/user/"]
RUN mix deps.get

# Again, we're caching node_modules if you don't change package.json
ADD package.json /app/user/
RUN npm install

# Add the rest of your app, and compile for production
ADD . /app/user/
RUN mix compile \
    && brunch build \
    && mix phoenix.digest

And your docker-compose would look like this:

web:
  build: .
  command: 'bash -c ''mix phoenix.server'''
  dockerfile: Dockerfile.prod
  working_dir: /app/user
  environment:
    LANG: en_US.UTF-8
    HOST: localhost
    PORT: 4000
    DATABASE_URL: 'postgres://postgres:@postgres:4000/api_prod'
  ports:
    - '4000:4000'
  links:
    - postgres
postgres:
  image: postgres

docker-heroku-phoenix's People

Contributors

joshwlewis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

docker-heroku-phoenix's Issues

Do we need to use Heroku's image?

I just found this in Heroku's container docs:

Both Cedar-14 and Heroku-16 are available as Docker images. However, you are free to use any base image you want โ€“ using a Heroku stack image is not required.

I'm wondering if we can just use the bitwalker/alpine-erlang or something.

As an aside, if we use the Heroku image, we should consider switching to Heroku-16:

If you chose to use a Heroku image we suggest Heroku-16, given it is much smaller than Cedar-14 (465.3 MB).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.