Skip to content

blankenshipz/docker-elixir-phoenix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Elixir & Phoenix

This Dockerfile builds on the official elixir image, adding Phoenix and nodejs.

This image can be used either as a CLI entrypoint to the elixir ecosystem or to build and run elixir or phoenix applications.

The following aliases might be useful:

alias elixir='
  docker run \
    -it \
    --rm \
    -v "$PWD":"$PWD" \
    -w "$PWD" \
    blankenshipz/elixir-phoenix \
    elixir'

alias iex='
  docker run \
    -it \
    --rm \
    -v "$PWD":"$PWD" \
    -w "$PWD" \
    blankenshipz/elixir-phoenix'

alias mix='
  docker run \
    -it \
    --rm \
    -v "$PWD":"$PWD" \
    -w "$PWD" \
    blankenshipz/elixir-phoenix \
    mix'

Using this image for development

Here's an example Dockerfile and docker-compose.yml that will work with the phoenix hello_phoenix demo application.

# Dockerfile

FROM blankenshipz/elixir-phoenix

RUN \
  apt-get update && \
  apt-get install -y postgresql-client && \
  apt-get clean && \
  cd /var/lib/apt/lists && rm -fr *Release* *Sources* *Packages* && \
  truncate -s 0 /var/log/*log

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY mix.exs /usr/src/app/
COPY mix.lock /usr/src/app/
COPY package.json /usr/src/app/

RUN \
  mix local.hex --force && \
  mix deps.get && \
  npm install --quiet

COPY . /usr/src/app/

CMD ["mix", "phoenix.server"]

And the docker-compose.yml:

# docker-compose.yml
version: '2'

services:
  web: &default
    build: .
    command: "mix phoenix.server"
    ports:
      - "4000:4000"
    links:
      - postgres
    volumes:
      - .:/usr/src/app

  postgres:
    image: postgres
    ports:
      - "5432:5432"