Skip to content

Commit 62f98d7

Browse files
author
Robert Kaczmarek
committed
Initial commit - setup dockerfile
0 parents  commit 62f98d7

7 files changed

+187
-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

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.tool-versions
2+
.DS_Store
3+
.idea/

Dockerfile

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
FROM ubuntu:16.04
2+
MAINTAINER Robert Kaczmarek <[email protected]>
3+
4+
# Update & upgrade
5+
RUN apt-get update
6+
RUN apt-get -y upgrade
7+
8+
# Install Ruby on Rails dependencies
9+
RUN apt-get -y install build-essential zlib1g-dev libssl-dev \
10+
libreadline6-dev libyaml-dev git \
11+
libcurl4-openssl-dev libpq-dev libmysqlclient-dev libxslt-dev \
12+
libsqlite3-dev libmagickwand-dev imagemagick \
13+
python apt-utils curl
14+
15+
# Install node
16+
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
17+
RUN apt install nodejs
18+
RUN npm install -g yarn
19+
20+
# Install ruby
21+
ENV RUBY_DOWNLOAD_SHA256 dac81822325b79c3ba9532b048c2123357d3310b2b40024202f360251d9829b1
22+
ADD https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.gz /tmp/
23+
24+
RUN \
25+
cd /tmp && \
26+
echo "$RUBY_DOWNLOAD_SHA256 *ruby-2.5.1.tar.gz" | sha256sum -c - && \
27+
tar -xzf ruby-2.5.1.tar.gz && \
28+
cd ruby-2.5.1 && \
29+
./configure && \
30+
make && \
31+
make install && \
32+
cd .. && \
33+
rm -rf ruby-2.5.1 && \
34+
rm -f ruby-2.5.1.tar.gz
35+
36+
RUN gem install bundler --no-document
37+
38+
# Install Google Chrome
39+
RUN apt-get install -y wget
40+
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
41+
RUN echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list
42+
RUN apt-get update && apt-get install -y google-chrome-stable
43+
44+
# Install chromedriver
45+
RUN apt-get install -y zip unzip
46+
RUN wget https://chromedriver.storage.googleapis.com/2.9/chromedriver_linux64.zip
47+
RUN unzip chromedriver_linux64.zip
48+
RUN rm -f chromedriver_linux64.zip
49+
RUN mv chromedriver /usr/bin/chromedriver
50+
RUN chown root:root /usr/bin/chromedriver
51+
RUN chmod +x /usr/bin/chromedriver
52+
53+
# Install other dependencies
54+
RUN apt-get install -y cmake libmagic-dev tzdata xvfb

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+
# docker-ruby-node-chrome-pack
2+
3+
Starting point for running Rails specs - includes Ruby 2.5.1 and
4+
nodejs 8.16.0 and Chrome (Google Chrome & Chromedriver)
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-chrome-pack
17+
```
18+
19+
### Running
20+
21+
```
22+
$ docker run -t -i prograils/ruby-node-chrome-pack
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 prograils/ruby-node-chrome-pack .
13+
- mkdir -p ~/docker; docker save prograils/ruby-node-chrome-pack > ~/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 prograils/ruby-node-chrome-pack prograils/ruby-node-chrome-pack:$CIRCLE_TAG
26+
- docker push prograils/ruby-node-chrome-pack:$CIRCLE_TAG

spec/dockerfile_spec.rb

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
%w(libpq-dev imagemagick git).each do |p|
29+
it "installs package #{p}" do
30+
expect(package(p)).to be_installed
31+
end
32+
end
33+
34+
describe command('ruby -v') do
35+
its(:stdout) { should match(/2\.5\.1/) }
36+
end
37+
38+
describe command('node -v') do
39+
its(:stdout) { should match(/8\./) }
40+
end
41+
42+
def os_version
43+
command('cat /etc/issue.net').stdout
44+
end
45+
end

0 commit comments

Comments
 (0)