Docker + Elixir + Phoenixframework

Just playing around docker and elixir. The followings are some notes about deploying sample phoenixframework application on docker.

Deploying using Vagrant is just adding the recipe to the chef.run_list.

config.vm.provision :chef_solo do |chef|
  ...
  chef.run_list = [
    "recipe[docker]",
    "recipe[chef-docker-spawn-viewer]"
  ]

Notes

Creating Eixir Container for Docker

https://github.com/parroty/docker-elixir/blob/master/Dockerfile

It’s just installing the erlang pack and then build elixir.

# Install base package
RUN apt-get update
RUN apt-get install -y wget git build-essential

# Install Erlang
RUN wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
RUN dpkg -i erlang-solutions_1.0_all.deb
RUN apt-get update
RUN apt-get install -y erlang

# Install Elixir
WORKDIR /tmp/elixir-build
RUN git clone https://github.com/elixir-lang/elixir.git
WORKDIR elixir
RUN git checkout v0.14.2 && make && make install

Creating Phoenix Application Container for Docker

https://github.com/parroty/docker-spawn-viewer

It’s about fetching git repo and comple and start with “mix run” with “–no-halt” option. I’ve used phoenix-docker-example as reference.

## Prerequisites ##
RUN mix do local.rebar, local.hex --force

## Fetch the phoenix application ##
WORKDIR /usr/local/lib
RUN git clone https://github.com/parroty/spawn_viewer.git

## Compile ##
WORKDIR spawn_viewer
RUN mix do deps.get, compile

CMD ["mix", "run", "-e", "SpawnViewer.Router.start", "--no-deps-check", "--no-compile", "--no-halt"]

EXPOSE 4000

Deploying Phoenix Application using Chef

https://github.com/parroty/chef-docker-spawn-viewer

chef-dooker makes it pretty easy to configure parameters for docker deployment.

# Pull latest image
docker_image 'parroty/docker-spawn-viewer'

# Run container exposing ports
docker_container 'parroty/docker-spawn-viewer' do
  detach true
  port '4000:4000'
end
Advertisements

Posted on July 19, 2014, in Elixir, Web. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: