Docker + Elixir + Phoenixframework
Just playing around docker and elixir. The followings are some notes about deploying sample phoenixframework application on docker.
- https://registry.hub.docker.com/u/parroty/docker-elixir/
- A container for elixir v0.14.2 on Ubuntu 14.04.
- https://registry.hub.docker.com/u/parroty/docker-spawn-viewer/
- A container for SpawnViewer sample application using phoenixframework.
- https://github.com/parroty/chef-docker-spawn-viewer/
- A chef cookbook to deploy docker-spawn-viewer container using chef-dooker.
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
Posted on July 19, 2014, in Elixir, Web. Bookmark the permalink. Leave a comment.
Leave a comment
Comments 0