FROM mysql:5.7
MAINTAINER Mark Moser <markamoser@gmail.com>

WORKDIR ~/

ENV MYSQL_ROOT_PASSWORD=root
ENV BUILD_PACKAGES="build-essential libmysqlclient-dev openssl graphviz nodejs curl wget zlib1g-dev tmux"

RUN apt-get update \
  && apt-get install --fix-missing -y $BUILD_PACKAGES \
  && /usr/sbin/mysqld  --initialize --user=mysql \
  && service mysql start \
  && echo 'gem: --no-document' >> ~/.gemrc \
  && cp ~/.gemrc /etc/gemrc \
  && chmod uog+r /etc/gemrc \
  && mkdir -p /usr/app \
  && ln -s /usr/bin/nodejs /usr/bin/node \
  && echo "alias ll='ls -Ahl'" >> /root/.bashrc \
  && echo "alias la='ls -ahl'" >> /root/.bashrc \
  && echo "export HISTCONTROL=ignoredups" >> /root/.bashrc

# install current Ruby
RUN curl -L --progress https://github.com/postmodern/ruby-install/archive/v0.6.0.tar.gz | tar xz \
  && cd ruby-install-0.6.0 \
  && make install \
  && cd ../ \
  && ruby-install --system ruby \
  && gem install bundler

COPY .tmux.conf /root/
COPY Gemfile* /root/
RUN cd /root \
  && bundle install \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

EXPOSE 3000 3306 35729
WORKDIR /usr/app
CMD /bin/bash
