Skip to content

Commit 7ac555a

Browse files
committed
Initial commit
0 parents  commit 7ac555a

9 files changed

+198
-0
lines changed

.dockerignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
rspec/
2+
.git
3+
Gemfile
4+
.rspec
5+
circle.yml

.gitignore

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

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.3.3

Dockerfile

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM ubuntu:16.04
2+
MAINTAINER Maciej Litwiniuk <[email protected]>
3+
4+
RUN apt-get update
5+
RUN apt-get -y upgrade
6+
7+
RUN apt-get -y install build-essential zlib1g-dev libssl-dev \
8+
libreadline6-dev libyaml-dev git-core \
9+
libmagickwand-dev imagemagick libcurl4-openssl-dev
10+
11+
# Install node
12+
ENV NODEJS_DOWNLOAD_SHA256 2c7a643b199c63390f4e33359e82f1449b84ec94d647c606fc0f1d1a2b5bdedd
13+
ADD https://nodejs.org/dist/v6.10.1/node-v6.10.1.tar.gz /tmp/
14+
15+
RUN \
16+
cd /tmp && \
17+
echo "$NODEJS_DOWNLOAD_SHA256 *node-v6.10.1.tar.gz" | sha256sum -c - && \
18+
tar xvzf node-v6.10.1.tar.gz && \
19+
rm -f node-v6.10.1.tar.gz && \
20+
cd node-v* && \
21+
./configure && \
22+
CXX="g++ -Wno-unused-local-typedefs" make && \
23+
CXX="g++ -Wno-unused-local-typedefs" make install && \
24+
cd /tmp && \
25+
rm -rf /tmp/node-v* && \
26+
echo -e '\n# Node.js\nexport PATH="node_modules/.bin:$PATH"' >> /root/.bashrc
27+
28+
# Common ruby/gems dependencies
29+
RUN apt-get -y install libpq-dev libmysqlclient-dev libxslt-dev libsqlite3-dev libmagickwand-dev imagemagick
30+
31+
ENV RUBY_DOWNLOAD_SHA256 a330e10d5cb5e53b3a0078326c5731888bb55e32c4abfeb27d9e7f8e5d000250
32+
ADD https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.gz /tmp/
33+
34+
# Install ruby
35+
RUN \
36+
cd /tmp && \
37+
echo "$RUBY_DOWNLOAD_SHA256 *ruby-2.4.1.tar.gz" | sha256sum -c - && \
38+
tar -xzf ruby-2.4.1.tar.gz && \
39+
cd ruby-2.4.1 && \
40+
./configure && \
41+
make && \
42+
make install && \
43+
cd .. && \
44+
rm -rf ruby-2.4.1 && \
45+
rm -f ruby-2.4.1.tar.gz
46+
47+
RUN gem install bundler --no-ri --no-rdoc
48+

Gemfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
source "https://rubygems.org"
2+
3+
group :integration do
4+
# Circle CI uses LXC which doesn't support `docker exec`
5+
# which is faster then the previous method they used
6+
# yet building is the wait anyway
7+
gem "specinfra", "2.12.7"
8+
9+
gem "serverspec"
10+
gem "docker"
11+
gem "rspec"
12+
gem "docker-api", require: "docker"
13+
end

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Edwin van der Graaf
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# prograils/ruby-node:latest
2+
3+
Starting point for running Rails specs - includes lastest stable ruby and
4+
node 6.10.1
5+
6+
## What's inside
7+
8+
The supplied `Dockerfile` will create an images for docker containers
9+
with ruby and nodejs.
10+
11+
## Getting started
12+
13+
### Getting the image
14+
15+
```
16+
$ docker pull prograils/ruby-node
17+
```
18+
19+
### Running
20+
21+
```
22+
$ docker run -t -i prograils/ruby-node
23+
```
24+
25+
### Testing
26+
```
27+
$ bundle exec rspec
28+
```
29+
30+
31+
## References
32+
33+
* [Test Drive Your Dockerfiles with RSpec and ServerSpec](https://robots.thoughtbot.com/tdd-your-dockerfiles-with-rspec-and-serverspec)

circle.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
machine:
2+
services:
3+
- docker
4+
5+
dependencies:
6+
cache_directories:
7+
- "~/docker"
8+
override:
9+
- bundle install
10+
- docker info
11+
- if [[ -e ~/docker/image.tar ]]; then docker load --input ~/docker/image.tar; fi
12+
- docker build -t digitpaint/ruby-node-phantomjs .
13+
- mkdir -p ~/docker; docker save digitpaint/ruby-node-phantomjs > ~/docker/image.tar
14+
15+
test:
16+
override:
17+
- bundle exec rspec spec --format progress:
18+
timeout: 1200 # Compiling node.js takes a while
19+
20+
deployment:
21+
hub:
22+
tag: /v[0-9]+(\.[0-9]+)*/
23+
commands:
24+
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
25+
- docker tag digitpaint/ruby-node-phantomjs digitpaint/ruby-node-phantomjs:$CIRCLE_TAG
26+
- docker push digitpaint/ruby-node-phantomjs:$CIRCLE_TAG

spec/dockerfile_spec.rb

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
require 'serverspec'
2+
require 'docker'
3+
4+
# Workaround needed for circleCI
5+
if ENV['CIRCLECI']
6+
class Docker::Container
7+
def remove(*); end
8+
alias delete remove
9+
end
10+
end
11+
12+
describe 'Dockerfile' do
13+
before(:all) do
14+
image = Docker::Image.build_from_dir('.') do |v|
15+
matches = v.match(/{\"stream\":\"(Step[^\\"]*)/)
16+
puts "=> #{matches.captures[0]}" if matches
17+
end
18+
19+
set :os, family: :debian
20+
set :backend, :docker
21+
set :docker_image, image.id
22+
end
23+
24+
it 'ubuntu' do
25+
expect(os_version).to include('Ubuntu 16.04')
26+
end
27+
28+
#
29+
%w(git-core).each do |p|
30+
it "installs package #{p}" do
31+
expect(package(p)).to be_installed
32+
end
33+
end
34+
35+
describe command('ruby -v') do
36+
its(:stdout) { should match(/2\.4\.1p111/) }
37+
end
38+
39+
describe command('node -v') do
40+
its(:stdout) { should match(/6\.10\.1/) }
41+
end
42+
43+
describe command('npm -v') do
44+
its(:stdout) { should match(/3\.10\.10/) }
45+
end
46+
47+
def os_version
48+
command('cat /etc/issue.net').stdout
49+
end
50+
end

0 commit comments

Comments
 (0)