Description
On my machine I usually prefer not to install a bag full of libraries and run a bunch of processes to facilitate development. This allows me to keep the system clean while I context-switch a lot. For this reason, I have written a simple Dockerfile that packages necessary requirements to work with classifier-reborn
. It looks something like this:
FROM ruby:2.3
MAINTAINER Sawood Alam <https://github.com/ibnesayeed>
ENV LANG C.UTF-8
RUN apt update && apt install -y libgsl0-dev && rm -rf /var/lib/apt/lists/*
RUN cd /tmp \
&& wget http://download.redis.io/redis-stable.tar.gz \
&& tar xvzf redis-stable.tar.gz \
&& cd redis-stable \
&& make && make install \
&& cd /tmp && rm -rf redis-stable*
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN bundle install
RUN gem install narray nmatrix gsl redis
CMD redis-server --daemonize yes && rake
Using this file I have built a Docker image named classifier-reborn
:
$ docker build -t classifier-reborn .
Now, anytime I make any changes in the code, I can simply run the following command to test it:
$ docker run --rm -it -v "$PWD":/usr/src/app classifier-reborn
It will use the Docker image I built before that has all the dependencies installed. Then it will run a Redis server inside the container and invoke the default Rake task. Once the task is done, everything will be wiped clean.
If I want to do something more than running the default Rake task, I can access the Bash prompt of the container:
$ docker run --rm -it -v "$PWD":/usr/src/app classifier-reborn bash
Once I exit from the Bash prompt, my machine will be clean again.
If some dependencies have changed that require to re-run bundle install
then the image can be built again.
If this workflow seems useful for others then I can push the Dockerfile in the repo with some documentation.