Skip to content

Commit 1ef5646

Browse files
committed
fix: update with vagrant files and tdd
1 parent 2f425d2 commit 1ef5646

File tree

7 files changed

+201
-34
lines changed

7 files changed

+201
-34
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vagrant

.rspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
--require spec_helper
2-
--format documentation
32
--color
3+
--format documentation

Dockerfile

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
FROM fedora:25
2-
MAINTAINER Bradley Leonard <[email protected]>
1+
FROM debian:jessie
2+
LABEL MAINTAINER Bradley Leonard <[email protected]>
3+
LABEL description="This container will run the boinc-client."
34

45
# install boinc
5-
RUN dnf -y install compat-libstdc++-296.i686 compat-libstdc++-33.i686 boinc-client\
6-
&& dnf clean all
6+
RUN apt-get update && \
7+
apt-get -q install -y boinc-client && \
8+
apt-get clean && \
9+
rm -rf /var/lib/apt/lists/*
10+
711

812
EXPOSE 31416
913

1014
WORKDIR /var/lib/boinc
1115

12-
#USER boinc
16+
USER boinc
17+
18+
ENTRYPOINT ["boinc"]
1319

1420
# create directories
15-
RUN mkdir /scripts
21+
#RUN mkdir /scripts
1622

1723
# add the startup.sh
18-
ADD startup.sh /scripts/startup.sh
19-
RUN chmod 755 /scripts/startup.sh
24+
#ADD startup.sh /scripts/startup.sh
25+
#RUN chmod 755 /scripts/startup.sh
2026

21-
CMD ["/scripts/startup.sh"]
27+
#CMD ["/scripts/startup.sh"]

Vagrantfile

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
# Check for missing plugins
5+
required_plugins = %w( vagrant-vbguest )
6+
plugin_installed = false
7+
required_plugins.each do |plugin|
8+
unless Vagrant.has_plugin?(plugin)
9+
system "vagrant plugin install #{plugin}"
10+
plugin_installed = true
11+
end
12+
end
13+
14+
# If new plugins installed, restart Vagrant process
15+
if plugin_installed === true
16+
exec "vagrant #{ARGV.join' '}"
17+
end
18+
19+
# All Vagrant configuration is done below. The "2" in Vagrant.configure
20+
# configures the configuration version (we support older styles for
21+
# backwards compatibility). Please don't change it unless you know what
22+
# you're doing.
23+
Vagrant.configure("2") do |config|
24+
# The most common configuration options are documented and commented below.
25+
# For a complete reference, please see the online documentation at
26+
# https://docs.vagrantup.com.
27+
28+
# Every Vagrant development environment requires a box. You can search for
29+
# boxes at https://atlas.hashicorp.com/search.
30+
config.vm.box = "fedora/25-cloud-base"
31+
32+
# Disable automatic box update checking. If you disable this, then
33+
# boxes will only be checked for updates when the user runs
34+
# `vagrant box outdated`. This is not recommended.
35+
# config.vm.box_check_update = false
36+
37+
# Create a forwarded port mapping which allows access to a specific port
38+
# within the machine from a port on the host machine. In the example below,
39+
# accessing "localhost:8080" will access port 80 on the guest machine.
40+
# NOTE: This will enable public access to the opened port
41+
# config.vm.network "forwarded_port", guest: 80, host: 8080
42+
43+
# Create a forwarded port mapping which allows access to a specific port
44+
# within the machine from a port on the host machine and only allow access
45+
# via 127.0.0.1 to disable public access
46+
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
47+
48+
# Create a private network, which allows host-only access to the machine
49+
# using a specific IP.
50+
# config.vm.network "private_network", ip: "192.168.33.10"
51+
52+
# Create a public network, which generally matched to bridged network.
53+
# Bridged networks make the machine appear as another physical device on
54+
# your network.
55+
# config.vm.network "public_network"
56+
57+
# we will try to autodetect this path.
58+
# However, if we cannot or you have a special one you may pass it like:
59+
# config.vbguest.iso_path = "#{ENV['HOME']}/Downloads/VBoxGuestAdditions.iso"
60+
# or an URL:
61+
# config.vbguest.iso_path = "http://company.server/VirtualBox/%{version}/VBoxGuestAdditions.iso"
62+
# or relative to the Vagrantfile:
63+
# config.vbguest.iso_path = File.expand_path("../relative/path/to/VBoxGuestAdditions.iso", __FILE__)
64+
65+
# set auto_update to false, if you do NOT want to check the correct
66+
# additions version when booting this machine
67+
config.vbguest.auto_update = true
68+
69+
# do NOT download the iso file from a webserver
70+
config.vbguest.no_remote = true
71+
72+
# Share an additional folder to the guest VM. The first argument is
73+
# the path on the host to the actual folder. The second argument is
74+
# the path on the guest to mount the folder. And the optional third
75+
# argument is a set of non-required options.
76+
# config.vm.synced_folder "../data", "/vagrant_data"
77+
config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
78+
79+
# Provider-specific configuration so you can fine-tune various
80+
# backing providers for Vagrant. These expose provider-specific options.
81+
# Example for VirtualBox:
82+
#
83+
config.vm.provider "virtualbox" do |vb|
84+
# # Display the VirtualBox GUI when booting the machine
85+
# vb.gui = true
86+
#
87+
# # Customize the amount of memory on the VM:
88+
vb.memory = "1024"
89+
end
90+
#
91+
# View the documentation for the provider you are using for more
92+
# information on available options.
93+
94+
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
95+
# such as FTP and Heroku are also available. See the documentation at
96+
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
97+
# config.push.define "atlas" do |push|
98+
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
99+
# end
100+
101+
# Enable provisioning with a shell script. Additional provisioners such as
102+
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
103+
# documentation for more information about their specific syntax and use.
104+
# config.vm.provision "shell", inline: <<-SHELL
105+
# apt-get update
106+
# apt-get install -y apache2
107+
# SHELL
108+
config.vm.provision "shell", inline: <<-OSPREREQ
109+
echo "installing os pre reqs:"
110+
dnf install -y unix2dos dos2unix
111+
OSPREREQ
112+
config.vm.provision "shell", inline: <<-SHELL
113+
echo "installing ruby & prereq for installing gems:"
114+
dnf install -y ruby ruby-devel redhat-rpm-config zlib-devel patch
115+
echo "installing ruby gems:"
116+
gem install bundler
117+
gem install dockerspec
118+
echo "installing docker:"
119+
dnf -y install dnf-plugins-core
120+
dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
121+
dnf makecache fast
122+
dnf -y install docker-ce
123+
usermod -aG docker vagrant
124+
systemctl enable docker
125+
systemctl start docker
126+
SHELL
127+
config.vm.provision "shell", inline: <<-DOCKERRAIC
128+
echo "installing docker_raic:"A
129+
if [ ! -f /usr/local/bin/docker_raic ]
130+
then
131+
cp /vagrant/bin/docker_raic /usr/local/bin/docker_raic
132+
chmod 755 /usr/local/bin/docker_raic
133+
fi
134+
DOCKERRAIC
135+
end

bin/docker_raic

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
# Delete all containers
4+
docker rm $(docker ps -a -q)
5+
6+
# Delete all images
7+
docker rmi $(docker images -q)
8+

spec/Dockerfile_spec.rb

+40-24
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,55 @@
1-
require "serverspec"
2-
require "docker"
3-
require "spec_helper"
4-
require "os_spec"
1+
require "dockerspec/serverspec"
52

63
Docker.options[:read_timeout] = 900
74
BOINC_PORT = 31416
85

96
describe "Dockerfile" do
10-
before(:all) do
11-
@image = Docker::Image.build_from_dir('.', {'networkmode' => 'host'})
127

13-
set :os, family: :fedora
14-
set :backend, :docker
15-
set :docker_image, @image.id
16-
end
8+
describe docker_build(path: '.', tag: 'boinc') do
9+
it { should have_label 'MAINTAINER' => 'Bradley Leonard <[email protected]>' }
10+
it { should have_label 'description' => 'This container will run the boinc-client.' }
11+
it { should have_expose '31416' }
12+
it { should have_user 'boinc' }
13+
it { should have_workdir '/var/lib/boinc' }
14+
it { should have_entrypoint 'boinc'}
1715

18-
it "installs the right version of fedora" do
19-
expect(os_version).to include("Fedora release 25")
16+
describe docker_run('boinc', family: :debian) do
17+
describe 'boinc-client' do
18+
describe package('boinc-client') do
19+
it { should be_installed }
20+
end
21+
end
22+
end
2023
end
24+
end
25+
# before(:all) do
26+
# @image = Docker::Image.build_from_dir('.', {'networkmode' => 'host'})
27+
#
28+
# set :os, family: :fedora
29+
# set :backend, :docker
30+
# set :docker_image, @image.id
31+
# end
2132

22-
describe package("boinc-client") do
23-
it { should be_installed.with_version('7.6.22') }
24-
end
2533

26-
describe file('/scripts/startup.sh') do
27-
it { should be_mode 755 }
28-
end
34+
# it "installs the right version of fedora" do
35+
# expect(os_version).to include("Fedora release 25")
36+
# end
37+
38+
# describe package("boinc-client") do
39+
# it { should be_installed.with_version('7.6.22') }
40+
# end
2941

30-
describe 'Dockerfile#config' do
42+
# describe file('/scripts/startup.sh') do
43+
# it { should be_mode 755 }
44+
# end
3145

32-
it 'should expose the boinc management port' do
33-
expect(@image.json['ContainerConfig']['ExposedPorts']).to include("#{BOINC_PORT}/tcp")
34-
end
46+
# describe 'Dockerfile#config' do
3547

36-
end
48+
# it 'should expose the boinc management port' do
49+
# expect(@image.json['ContainerConfig']['ExposedPorts']).to include("#{BOINC_PORT}/tcp")
50+
# end
51+
#
52+
# end
3753

3854

3955
# possible tests for Dockerfile
@@ -89,4 +105,4 @@
89105
#
90106
# end
91107

92-
end
108+
#end

test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ echo "Executing tests:"
55
echo ""
66
rspec spec/Dockerfile_spec.rb
77
echo ""
8+

0 commit comments

Comments
 (0)