diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2337cd2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,101 @@ +# Created by .ignore support plugin (hsz.mobi) + +.dockerignore +Dockerfile +Procfile +docker-compose.yml +CHANGELOG.md +Gemfile.lock +.git + +.Trash-* +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Ruby template +*.gem +*.rbc +.config +coverage/ +InstalledFiles +pkg/ +spec/reports/ +spec/examples.txt +test/tmp/ +test/version_tmp/ +tmp/ + +## Documentation cache and generated files: +.yardoc/ +_yardoc/ +doc/ +rdoc/ + +## Environment normalization: +.bundle/ +vendor +lib/bundler/man/ + +### Vim template +# swap +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +# session +Session.vim +# temporary +.netrwhist +# auto-generated tag files +tags + +.idea +*.iws + +### Rails template +capybara-*.html +.rspec +log +db/*.sqlite3 +db/*.sqlite3-journal +public/system +spec/tmp +**.orig +rerun.txt +pickle-email-*.html + +#config/initializers/secret_token.rb +#config/secrets.yml + +# dotenv +.env + +*.bowerrc +bower.json + +# Ignore pow environment settings +.powenv + +# Ignore Byebug command history file. +.byebug_history diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..566da7e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +FROM ubuntu:trusty + +# Create base directory for the application +RUN mkdir -p /app +WORKDIR /app + +RUN apt-get -qq update \ + && apt-get -qq install -y \ + wget \ + software-properties-common \ + && rm -rf /var/lib/apt/lists/* + +# Install the latest version of Ceph to get the latest librbd and the like (required by the tool). +RUN wget -q -O- 'https://download.ceph.com/keys/release.asc' | apt-key add - \ + && echo "deb http://download.ceph.com/debian-jewel/ trusty main" | tee /etc/apt/sources.list.d/ceph-jewel.list \ + && apt-add-repository ppa:brightbox/ruby-ng \ + && apt-get update \ + && apt-get install -y --force-yes \ + build-essential \ + ceph \ + git \ + radosgw \ + ruby2.3 ruby2.3-dev \ + && apt-get autoremove -y \ + && rm -rf /var/lib/apt/lists/* + +COPY lib/ceph-ruby/version.rb /app/lib/ceph-ruby/version.rb +COPY Gemfile ceph-ruby.gemspec ./ + +RUN gem install bundler --no-ri --no-rdoc && bundle install -j2 + +COPY . /app + +CMD ["docker/start.sh"] diff --git a/README.md b/README.md index afe0a70..639eb51 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,19 @@ Easy management of Ceph Distributed Storage System (rbd, images, rados objects) using ruby. +## Development + +```ruby +docker-compose build +docker-compose run app # Will open a console for you to work with +``` + +## Tests + +```ruby +docker-compose build +docker-compose run app rspec +``` ## Installation @@ -17,7 +30,6 @@ Or install it yourself as: $ gem install ceph-ruby - ## Usage require "ceph-ruby" diff --git a/bin/ceph-ruby b/bin/ceph-ruby new file mode 100755 index 0000000..57e7622 --- /dev/null +++ b/bin/ceph-ruby @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby + +require 'pathname' +require 'pry' + +APP_ROOT = File.join(File.dirname(Pathname.new(__FILE__).realpath), '..') + +$LOAD_PATH.unshift File.join(APP_ROOT, 'lib') +$LOAD_PATH.unshift File.join(APP_ROOT, 'vendor/bundle') + +Dir.chdir(APP_ROOT) + +require 'bundler/setup' +require 'ceph-ruby' + +binding.pry diff --git a/ceph-ruby.gemspec b/ceph-ruby.gemspec index 2a18f5c..db72389 100644 --- a/ceph-ruby.gemspec +++ b/ceph-ruby.gemspec @@ -20,4 +20,5 @@ Gem::Specification.new do |gem| gem.add_dependency('ffi', '~> 1.1.5') gem.add_dependency('activesupport', '>= 3.0.0') + gem.add_development_dependency('pry') end diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f43c342 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,33 @@ +version: '2' +services: + app: + build: . + volumes: + - .:/app + depends_on: + - ceph + networks: + default: + ceph: + ipv4_address: 10.28.0.20 + volumes_from: + - ceph + + ceph: + image: ceph/demo:tag-build-master-jewel-ubuntu-14.04 + environment: + - MON_IP=10.28.0.10 + - CEPH_PUBLIC_NETWORK=10.28.0.0/24 + networks: + ceph: + ipv4_address: 10.28.0.10 + volumes: + - /etc/ceph + +# Default network (required by the Ceph cluster, as we need to pass our own IP as env. variable) +networks: + ceph: + ipam: + driver: default + config: + - subnet: 10.28.0.0/24 diff --git a/docker/start.sh b/docker/start.sh new file mode 100755 index 0000000..d3581c2 --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Create the pools +ceph osd pool create my-pool-xyz 100 + +bundle # This is in case you use a volume locally + +bundle exec bin/ceph-ruby