With this repository you can build a docker image that makes it possible to develop and test elixir / phoenix applications in your browser (it must be HTML5 capable) from anywhere, using docker, intellij IDEA, the intellij-elixir plugin and noVNC. With noVNC you can connect to docker containers on a server. No install of a vnc viewer on the client needed. This connection will be via https or http, password protected. You're not bound to a windows client as with RDP. And with x11 in your container you can run GUI apps in the browser. See elixir-intellij-noVNC.jpg in the repo with the erlang observer, pgadmin3, intellij and firefox running.
Docker is mostly used to containerize applications for deployment into production. But development is a production environment also, from a certain viewpoint, and it can be handy to ship developmentcontainers. I don't like installing on my host with files being placed everywhere, not knowing if an eventual deinstall will completely remove everything. I want to be able to delete an application and know for sure it is removed completely. Docker gives that. Moreover you can control how much CPU and memory the application uses.
Of course this repo can be improved. At the end of this readme I will name my own wishlist, suggestions welcome.
On the server you will have two images and volumes with mutable data. You will build the image with the application (erlang/elixir/phoenix/node/pgadmin3/intellij/intellij-elixir plugin), an x11vncserver and clientsoftware (javascript) for noVNC. The other image contains the postgresql database. You will get that one from dockerhub. The containers will be started and connected with docker-compose. I assume docker and docker-compose known and installed on your host, documentation can be found online.
-
Make sure you have port 6080 for noVNC and 4000 for phoenix open in your router ("port forward" for the ip-address check eth0 with ifconfig and make this address fixed), see that you have no blocking firewalls
-
Get the postgres image with docker pull postgres (from https://hub.docker.com/_/postgres/).
-
Create a folder for your repo.
-
Make sure that you have the latest version of docker-compose (my machine gives with docker-compose version 1.7.0rc2, build ea2d526), and also a docker version that supports this new docker-compose (mine is 1.10.3)
-
CD to you repo folder and git clone https://github.com/StefanHoutzager/elixir-dev-anywhere-docker.git
-
You have an elixir-dev-anywhere-docker folder in your repofolder now. Copy
Dockerfile
anddocker-compose.yml
fromelixir-dev-anywhere-docker
to your repo folder. There are a couple of ADD statements in the Dockerfile that put files from the elixir-dev-anywhere-docker folder on the host into your image, this way you make sure you have the original files in the repo. Look for the newest version of the intellij-elixir plugin at https://github.com/KronicDeth/intellij-elixir/releases, intellij-elixir.zip , I placed version 7.4.0 in the elixir-dev-anywhere-docker folder. Replace it if you want. -
Look for the string
badpassword
in theDockerfile
and replace it with the ones you prefer use. -
To enable encrypted connections, you need to (at a minimum) create a noVNC self.pem certificate file: https://github.com/kanaka/websockify/wiki/Encrypted-Connections, put it in
elixir-dev-anywhere-docker/noVNC
-
Edit
docker-compose.yml
, replace eachfolder_name_in_container
andvolume_name_onhost
with names of your choice. Edit further environment variables as you wish. If you commentENABLE_HTTP: "Y"
you cannot use http besides https in your URL. You can overrideVNC
andUBUNTU
passwords from theDockerfile
here if you wish, the vars are not mandatory.VIRTUAL_HEIGHT
andVIRTUAL_WIDTH
are mandatory env vars. They are filled in for my own screen resolution now, which is 1920X1080. Note that screenresolution !== browseviewport resolution
(except width). -
Enter your repo folder and build the image with
docker build -t stefan/phoenix . | tee build.log
-
If the build has been succesfull start the app with
docker-compose up -d
-
Note the container names that show up in your terminal. You can use
compose_postgres_1
as hostname when you startpgadmin3
later -
If you want to check the status of the containers:
docker ps -a
-
Point your browser to
https://yourexternalip:6080/vnc.html
(or use http), or use the inet address of the router (ifconfig) -
Start intellij in the browser (right mouse should show a menu with an intellij item). This menu is configurable, if you want uncomment the following line
/var/lib/docker/volumes/openbox/_data:/home/ubuntu/.config/openbox
indocker-compose.yml
create the folder on your host and copy the contents ofelixir-dev-anywhere-docker/openbox-config/.config/openbox
into it -
Follow instruction here: https://github.com/KronicDeth/intellij-elixir to configure
-
Configure your IDE settings (the theme shown in the jpg contained in this github project f.e. is darcula) https://www.jetbrains.com/help/idea/2016.3/project-and-ide-settings.html. Save the
settings.jar
in the default folder (file -> export settings) -
Close intellij and copy the IDE setting from the running docker-container to the volume on your host (sudo -i to get rights):
docker cp your_containername:/home/ubuntu/.IdeaIC2017.3/config /var/lib/docker/volumes/intellij/_data/.IdeaIC2017.3
-
Shutdown the running containers, remove the comment sign (#) in
docker-compose.yml
from the line- /var/lib/docker/volumes/intellij/_data/.IdeaIC2017.3/config:/home/ubuntu/.IdeaIC2017.3/config
and restart withdocker-compose up -d
-
If you get an http timeout error when bringing down the containers with
docker-compose down
create a.env
file with f.e. (default forCOMPOSE_HTTP_TIMEOUT
is 50).COMPOSE_HTTP_TIMEOUT=200
For the noVNC part I used the following repo and made some small modifications: https://github.com/mccahill/docker-eclipse-novnc. Interesting notes from Mark McCahill: https://gitlab.oit.duke.edu/mccahill/docker-novnc-template The noVNC folder was taken frome https://github.com/kanaka/noVNC on sept 6 2016
All the people that built elixir, phoenix and the intellij-elixir plugin of course.
- The applications could be spread over more images to make them more reusable, some maybe with a small FROM image like alpine. My docker knowledge is not enough to do this at the moment. There could be one image for noVNC + x11vncserver, one for intellij, one for pgadmin3, one for erlang/elixir/phoenix and one for postgres maybe.
- It would be nice to make the openbox theme configurable. Here you can find themes: https://www.box-look.org (look for openbox themes only). I shortly tried to make this work, but miss openbox knowledge
- Make this fit for use with multiple users.