anyone got wxwidgets working with erlang in a dockerfile with ubuntu 14.04.4 LTS? (was [elixir-talk:12406] Re: :observer.start gives error WX failed loading)

799 views
Skip to first unread message

Stefan Houtzager

unread,
Apr 8, 2016, 8:59:22 AM4/8/16
to elixir-l...@googlegroups.com
I tried to create a dockerfile with the latest erlang, elixir and phoenix. With wxwidgets working, if that is possible at all. Would be nice to be able to offer this to others starting elixir and phoenix tutorials. Moreover I added nano, node, emacs and spacemacs (the last two not yet tested, I will have to add some config I think, suggestions welcome). It looks like elixir end phoenix are working after some simple tests. The dockerfile I copied below. 
  I started out learning elixir with the excellent trenpixster/elixir docker image. But allas :observer.start did not work (see https://groups.google.com/forum/#!msg/elixir-lang-talk/kZour7VvQ_M/8Su0g5oKBwAJ ). So I asked here, looked after the suggestions and googled for solutions.
  I start the dockerfile with the same image as trenpixter: FROM phusion/baseimage:0.9.18. This is a reworked (for docker) version of

Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
Codename: trusty

After the install I get for which wx-config && wx-config --version-full:

/usr/bin/wx-config
2.8.12.1

But :observer.start() in iex returns

Error: Unable to initialize gtk, is DISPLAY set properly?
{:error,
 {{:einval, 'Could not initiate graphics'},
  [{:wxe_server, :start, 1, [file: 'wxe_server.erl', line: 65]},
   {:wx, :new, 1, [file: 'wx.erl', line: 115]},
   {:observer_wx, :init, 1, [file: 'observer_wx.erl', line: 96]},
   {:wx_object, :init_it, 6, [file: 'wx_object.erl', line: 337]},
   {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 240]}]}}

The output of the docker build I is attached. 

Regards, Stefan

# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# @trenpixster wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return
# ----------------------------------------------------------------------------

# Use phusion/baseimage as base image. To make your builds reproducible, make
# sure you lock down to a specific version, not to `latest`!
# a list of version numbers.
#
# Usage Example : Run One-Off commands
# where <VERSION> is one of the baseimage-docker version numbers.
#
#  docker run --rm -t -i phusion/baseimage:<VERSION> /sbin/my_init -- bash -l
#
# Thanks to @hqmq_ for the heads up
FROM phusion/baseimage:0.9.18
MAINTAINER Stefan Houtzager <stefan.h...@gmail.com>

# Important!  Update this no-op ENV variable when this Dockerfile
# is updated with the current date. It will force refresh of all
# of the base images and things like `apt-get update` won't be using
# old cached versions when the Dockerfile is built.
ENV REFRESHED_AT 05-04-2016

# Set correct environment variables.

# Setting ENV HOME does not seem to work currently. HOME is unset in Docker container.
#ENV HOME /root
# Workaround:
RUN echo /root > /etc/container_environment/HOME

# Regenerate SSH host keys. baseimage-docker does not contain any, so you
# have to do that yourself. You may also comment out this instruction; the
# init system will auto-generate one during boot.
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh

# Baseimage-docker enables an SSH server by default, so that you can use SSH
# to administer your container. In case you do not want to enable SSH, here's
# how you can disable it. Uncomment the following:
#RUN rm -rf /etc/service/sshd /etc/my_init.d/00_regen_ssh_host_keys.sh

# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]

# ...put your own build instructions here...

# Set the locale
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

WORKDIR /tmp

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

# Avoid ERROR: invoke-rc.d: policy-rc.d denied execution of start. Avoid warning: update-rc.d: warning: default stop runlevel arguments (0 1 6) do not match rsync Default-Stop values (none)
#RUN echo '#!/bin/sh\nexit 0' > /usr/sbin/policy-rc.d && \
#    echo '#!/bin/sh' > /usr/sbin/policy-rc.d && \
#    echo 'exit 101' >> /usr/sbin/policy-rc.d && \
#    chmod +x /usr/sbin/policy-rc.d

# update and install some software requirements
RUN apt-get update && apt-get upgrade -y && apt-get install -y curl wget git unzip autoconf make g++ gcc fop libxml2-utils xsltproc

WORKDIR /

## Install emacs
RUN apt-get -y build-dep emacs24
RUN tar -xf emacs-24.5.tar.*  
WORKDIR emacs-24.5
RUN ./configure
RUN make
RUN make install
WORKDIR /
RUN rm -R /emacs-24.5.tar.gz


RUN add-apt-repository ppa:openjdk-r/ppa
RUN apt-get update && apt-get install openjdk-8-jdk -y

WORKDIR /

RUN git clone --recursive https://github.com/syl20bnr/spacemacs ~/.emacs.d
#RUN emacs --daemon && emacsclient --eval "(kill-emacs)"

# install nano (and pico)
RUN apt-get update && apt-get install nano -y

# Needed for terminal handling (libc-dev libncurses5 libtinfo-dev libtinfo5 ncurses-bin)
RUN apt-get -y install libncurses5-dev openssl libssl-dev

# For building with wxWidgets
RUN apt-get -y install libwxbase2.8 libwxgtk2.8-dev libqt4-opengl-dev libgtk2.0-dev libgl1-mesa-dev libglu1-mesa-dev libpng3

# For building ssl (libssh-4 libssl-dev zlib1g-dev)
RUN apt-get -y install libssh-dev

# ODBC support (libltdl3-dev odbcinst1debian2 unixodbc)
RUN apt-get -y install unixodbc-dev
RUN apt-get -y install ncurses-dev
RUN tar -xvzf otp_src_18.3.tar.gz
RUN chmod -R 777 otp_src_18.3
WORKDIR otp_src_18.3
RUN ./configure
RUN make
RUN make install
RUN cd .. && rm -R otp_src_18.3/

RUN echo "ERLANG_HOME=/usr/local/lib/erlang" >> ~/.bashrc
RUN echo "export PATH=$PATH:$ERLANG_HOME/bin" >> ~/.bashrc
RUN echo "export DISPLAY=:100.0" >> ~/.bashrc

RUN apt-get purge --auto-remove openjdk-8-jdk -y 
RUN rm -R /usr/lib/jvm

# Download and Install Specific Version of Elixir
WORKDIR /elixir
    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

# Install local Elixir hex and rebar
RUN /usr/local/bin/mix local.hex --force && \
    /usr/local/bin/mix local.rebar --force

WORKDIR /

# install Node.js (>= 5.0.0) and NPM in order to satisfy brunch.io dependencies
RUN curl -sL https://deb.nodesource.com/setup_5.x | sudo bash - && apt-get -y install nodejs inotify-tools






build.log

Boris Mühmer

unread,
Apr 8, 2016, 9:07:35 AM4/8/16
to elixir-l...@googlegroups.com
I believe wx in Erlang 18.x needs at least version 3.0 of wxWidgets:


Regards,
Boris

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/CANJtTDmN-fr1L6j1J8a1PdENMcTa1DTy0%2B-E3gwjwPc9x40UwA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Boris Mühmer

unread,
Apr 8, 2016, 9:09:55 AM4/8/16
to elixir-l...@googlegroups.com

Stefan Houtzager

unread,
Apr 8, 2016, 9:23:22 AM4/8/16
to elixir-l...@googlegroups.com
Thanks Boris, 

I noticed this piece of info before, but skipped it because it seems to be os x mavericks specific.

Regards, Stefan.


For more options, visit https://groups.google.com/d/optout.



--
Kind regards,

Stefan Houtzager

Houtzager ICT consultancy & development

www.linkedin.com/in/stefanhoutzager

Alex Shneyderman

unread,
Apr 8, 2016, 12:09:54 PM4/8/16
to elixir-lang-talk
On a related note, why would you want wx widgets on the container? You can easily run observer on local instance and connect to a remote node or several in your cluster.

Note sure if you saw this before: https://gist.github.com/pnc/9e957e17d4f9c6c81294

Stefan Houtzager

unread,
Apr 8, 2016, 12:47:38 PM4/8/16
to elixir-l...@googlegroups.com
Simply because of the benefits of containers. No installation of wxwidgets (besides while creating of the image of course) needed, just get the image from dockerhub and sudo docker run. Would be nice for starters like me to have such an image. Besides it's nice to learn to work with all this of course. But maybe I do not understand your point?


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages