Edit: I’ll create a github project in a couple of days and update this message when I’m done.
Succeeded. Below the pick the dockerfile + some more. If you see an improvement please let me know. I want to add it to github and update this project https://github.com/StefanHoutzager/elixir-dev-anywhere-docker
Dockerfile:
FROM ubuntu:16.04
MAINTAINER Stefan Houtzager "stefan.houtzager@gmail.com"
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV TERM xterm
RUN sed 's/main$/main universe/' -i /etc/apt/sources.list && \
apt-get update -qq && \
echo 'Installing OS dependencies' && \
apt-get install -qq -y --fix-missing sudo software-properties-common git libxext-dev libxrender-dev libxslt1.1 \
libxtst-dev libgtk2.0-0 libcanberra-gtk-module curl git unzip wget && \
echo 'Cleaning up' && \
apt-get clean -qq -y && \
apt-get autoclean -qq -y && \
apt-get autoremove -qq -y && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/*
RUN echo 'Creating user: developer' && \
mkdir -p /home/developer && \
echo "developer:x:1000:1000:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
echo "developer:x:1000:" >> /etc/group && \
sudo echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
sudo chmod 0440 /etc/sudoers.d/developer && \
sudo chown developer:developer -R /home/developer && \
sudo chown root:root /usr/bin/sudo && \
chmod 4755 /usr/bin/sudo
RUN mkdir -p /home/developer/.IdeaIC2016.2/config/options && \
mkdir -p /home/developer/.IdeaIC2016.2/config/plugins
ADD ./jdk.table.xml /home/developer/.IdeaIC2016.2/config/options/jdk.table.xml
ADD ./jdk.table.xml /home/developer/.jdk.table.xml
ADD ./run /usr/local/bin/intellij
ADD ./intellij-elixir.zip /home/developer/.IdeaIC2016.2/config/plugins/intellij-elixir.zip
RUN chmod +x /usr/local/bin/intellij && \
chown developer:developer -R /home/developer/.IdeaIC2016.2
RUN echo 'Downloading IntelliJ IDEA' && \
wget https://download.jetbrains.com/idea/ideaIC-2016.2.tar.gz -O /tmp/intellij.tar.gz -q && \
echo 'Installing IntelliJ IDEA' && \
mkdir -p /opt/intellij && \
tar -xf /tmp/intellij.tar.gz --strip-components=1 -C /opt/intellij && \
rm /tmp/intellij.tar.gz
RUN echo 'Installing Elixir plugin' && \
cd /home/developer/.IdeaIC2016.2/config/plugins/ && \
unzip -q intellij-elixir.zip && \
rm intellij-elixir.zip
RUN echo 'Installing Markdown plugin' && \
wget https://plugins.jetbrains.com/files/7793/25156/markdown-2016.1.20160405.zip -O markdown.zip -q && \
unzip -q markdown.zip && \
rm markdown.zip
RUN sudo chown developer:developer -R /home/developer
WORKDIR /
# erlang install
RUN echo "deb http://packages.erlang-solutions.com/ubuntu trusty contrib" >> /etc/apt/sources.list && \
apt-key adv --fetch-keys http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc && \
apt-get -qq update && apt-get install -y \
esl-erlang \
build-essential \
wget && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Download and Install Specific Version of Elixir
WORKDIR /elixir
RUN wget -q https://github.com/elixir-lang/elixir/releases/download/v1.3.2/Precompiled.zip && \
unzip Precompiled.zip && \
rm -f Precompiled.zip && \
ln -s /elixir/bin/elixirc /usr/local/bin/elixirc && \
ln -s /elixir/bin/elixir /usr/local/bin/elixir && \
ln -s /elixir/bin/mix /usr/local/bin/mix && \
ln -s /elixir/bin/iex /usr/local/bin/iex
WORKDIR /
# install Node.js (>= 5.0.0) and NPM in order to satisfy brunch.io dependencies
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - && apt-get -y install nodejs inotify-tools
# install phoenix
RUN mix archive.install https://github.com/phoenixframework/archives/raw//master/phoenix_new.ez --force
USER developer
ENV HOME /home/developer
ENV PATH $PATH:/home/developer/elixir/bin:/usr/local/elixir/bin
WORKDIR /home/developer/elixir
CMD /usr/local/bin/intellij
jdk.table.xml:
<application>
<component name="ProjectJdkTable">
<jdk version="2">
<name value="Elixir 1.3" />
<type value="Elixir SDK" />
<version value="1.3" />
<homePath value="/usr/local/bin/elixir" />
<roots>
<annotationsPath>
<root type="composite" />
</annotationsPath>
<classPath>
<root type="composite">
<root type="simple" url="file:///usr/local/bin" />
</root>
</classPath>
<javadocPath>
<root type="composite" />
</javadocPath>
<sourcePath>
<root type="composite">
<root type="simple" url="file:///usr/local/bin" />
</root>
</sourcePath>
</roots>
<additional />
</jdk>
</component>
</application>
run:
#!/usr/bin/env bash
function delayedPluginInstall {
sudo mkdir -p /home/developer/.IdeaIC2016.2/config/plugins
sudo mkdir -p /home/developer/.IdeaIC2016.2/config/options
sudo chown developer:developer -R /home/developer/.IdeaIC2016.2
cd /home/developer/.IdeaIC2016.2/config/plugins/
echo 'Installing Markdown support plugin'
wget https://plugins.jetbrains.com/files/7793/25156/markdown-2016.1.20160405.zip -O markdown.zip -q && unzip -q markdown.zip && rm markdown.zip
}
if [ ! -d /home/developer/.IdeaIC2016.2/config/plugins/intellij-elixir ]; then
# We are running with a non-Docker contained volume for IntelliJ prefs so we need to setup the plugin again
delayedPluginInstall
fi
if [ -d /home/developer/.IdeaIC2016.2 ]; then
# Ensure proper permissions
sudo chown developer:developer -R /home/developer/.IdeaIC2016.2
fi
exec /opt/intellij/bin/idea.sh
intellij-elixir.zip:
download it from https://github.com/KronicDeth/intellij-elixir/releases
make connection to the X11 server possible by f.e. adding
xhost +local:all
to your .bashrc
start the container with (use your own datavolume instead of stefan and your own imagename instead of stefan/intellij)
sudo docker run -ti --rm --net=“host” --privileged=true -e DISPLAY=${DISPLAY} -v /var/lib/docker/volumes/stefancontainer/_data:/stefan -v /tmp/.X11-unix:/tmp/.X11-unix -v ${HOME}/.IdeaIC2016.1_docker:/home/developer/.IdeaIC2016.1 stefan/intellij
If you want to use a postgres container you can take this docker-compose.yml as an example:
version: '2'
services:
web:
image: stefan/intellij
environment:
DATABASE_URL: postgres://bpmdemo:bpmdemo@db/bpmdemo
PORT: 5432
MIX_ENV: "dev"
DISPLAY: $DISPLAY
links:
- postgres
ports:
- 4000:4000
- 6080:6080
volumes:
- /var/lib/docker/volumes/stefancontainer/_data:/stefan
- /tmp/.X11-unix:/tmp/.X11-unix
- $HOME/.IdeaIC2016.1_docker:/home/developer/.IdeaIC2016.1
stdin_open: true
privileged: true
postgres:
image: postgres
environment:
LC_ALL: C.UTF-8
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
volumes:
- "db-data-bpmdemo:/var/lib/postgresql/data"
volumes:
stefan:
db-data-bpmdemo: