Docker Container

Hi all,

Just interested to know if anyone’s looking at creating a docker image of Dradis, as it might be a good option for easy deployment? I was thinking about looking at it, but didn’t want to get started down that line if I’m just duplicating effort…

Cheers

Rory

ok so I have this working, at least in a basic sense…

once you have docker installed

docker run -d -p 3000:3000 raesene/dradisframework bundle exec rails server

should work ok and bring up a new dradis instance on port 3000 on your host (obv. assuming that you don’t have a conflicting service running there already)

the Dockerfile used to create the image was as below, with the weirdness being having to run bundle install and ruby bin/setup twice to get everything installed/working…

FROM ruby:latest

MAINTAINER Rory McCune <rorym@mccune.org.uk>

# Need Node.JS to provide a JavaScript runtime for Rails
RUN apt-get update -qq && apt-get install -y nodejs

#Create top level dir otherwise we get plugins in the root
RUN mkdir dradis

# Clone only the release-3.0 branch of Dradis
RUN cd dradis && git clone -b release-3.0 --single-branch https://github.com/dradis/dradisframework.git

# Set the work directory to be /dradisframework
WORKDIR /dradis/dradisframework

# install the bundle (get an error on bin/setup if this doesn't go first)
RUN bundle install

# run the setup
RUN ruby bin/setup

# need to do this twice
RUN bundle install

# need to do this twice too
RUN ruby bin/setup

Also done a docker hub “automated build” version here

https://registry.hub.docker.com/u/raesene/auto-docker-dradis/

this has the advantage of the dockerfile being listed on the hub and automatically triggering rebuilds easily.

This is awesomesauce @raesene, many thanks.

I’m curious about this part:

# install the bundle (get an error on bin/setup if this doesn't go first)
RUN bundle install

# run the setup
RUN ruby bin/setup

# need to do this twice
RUN bundle install

# need to do this twice too
RUN ruby bin/setup

Is there any chance we can debug the mystery so we only run this once?

Well usefully this is exactly the kind of scenario that docker can help with as it allows everyone to work from identical builds :smile:

so taking it from the top in a bash shell started with

docker run -t -i -p 3000:3000 ruby:latest /bin/bash

then runnning

apt-get update -qq && apt-get install -y nodejs
mkdir dradis
cd dradis
git clone -b release-3.0 --single-branch https://github.com/dradis/dradisframework.git
cd dradisframework

if I try going straight for

ruby bin/setup

We start to run into errors on the ==Installing Dependencies== section

== Installing dependencies ==
git://github.com/dradis/dradis-theme_snowcrash.git (at master) is not yet checked out. Run bundle install
first.
Don’t run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will
break this application for all non-root users on this machine.
Fetching git://github.com/dradis/dradis-theme_snowcrash.git
Fetching git://github.com/dradis/dradis-projects.git
Some gems seem to be missing from your vendor/cache directory.
Could not find gem ‘foreman (>= 0) ruby’ in any of the gem sources listed in your Gemfile or available on this machine.

== Preparing database ==
Could not find gem ‘foreman (>= 0) ruby’ in any of the gem sources listed in your Gemfile or available on this machine.
Run bundle install to install missing gems.

so instead seemed like a plan to run

bundle install 

first then

ruby bin/setup

doing that gives us a different error

== Installing dependencies ==
Resolving dependencies…
Bundler can’t satisfy your Gemfile’s dependencies.
Install missing gems with bundle install.
Don’t run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will
break this application for all non-root users on this machine.
Resolving dependencies…
Some gems seem to be missing from your vendor/cache directory.
Bundler could not find compatible versions for gem “prawn”:
In Gemfile:
dradis-pdf_export (>= 0) ruby depends on
prawn (~> 0.15.0) ruby
Could not find gem ‘prawn (~> 0.15.0) ruby’, which is required by gem ‘dradis-pdf_export (>= 0) ruby’, in any
of the sources.

== Preparing database ==
Bundler could not find compatible versions for gem “prawn”:
In Gemfile:
dradis-pdf_export (>= 0) ruby depends on
prawn (~> 0.15.0) ruby
Could not find gem ‘prawn (~> 0.15.0) ruby’, which is required by gem ‘dradis-pdf_export (>= 0) ruby’, in any of the sources.

but I found running

bundle install 

again installed prawn and pdf-core this time

so then running

ruby bin/setup

again runs to completion, thus the double run…

playing with it a bit more

bin ruby/setup
bundle install
bin ruby/setup

seems to work, so could cut a line out of the file with that…

So a bit of investigation shows that it looks like it’s the --local on the bundle install in bin/setup that’s causing it to fail as there’s gems not in the vendor/cache. I’ve done a pull request to remove, but not sure if there’s perhaps a reason that’s there…