Skip to content
This repository has been archived by the owner on Aug 30, 2018. It is now read-only.

Feature/docker advanced config #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions config/worker.example.docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
env: linux
linux:
amqp:
host: host
port: port
username: username
password: password
virtual_host: vhost
vms:
provider: blue_box
count: 3
docker:
cmd:
username: travis
enable_cpuset: true
image_name: cip
default_image: cip:latest
private_key_path: /path/to/ssh/id_rsa
api:
host: localhost
port: 4234
memory: 4
expose_ports:
language_mappings:
haskell: jvm
13 changes: 8 additions & 5 deletions lib/travis/worker/virtual_machine/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ def create_server(opts = {})

def create_container(image_id)
create_options = {
'Cmd' => ['/sbin/init'],
'Image' => image_id,
'Memory' => (1024 * 1024 * 1024 * (docker_config.memory || 4)),
'Cpuset' => cpu_set,
'Hostname' => short_hostname,
}

create_options['Cpuset'] = cpu_set if docker_config.enable_cpuset
create_options['Cmd'] = docker_config.cmd if docker_config.cmd

# Allow for opting out of 'Domainname' as this results in lxc-start
# explosions on docker 1.3.2 (and maybe others?)
create_options['Domainname'] = domainname unless docker_config.omit_domainname
Expand Down Expand Up @@ -117,7 +118,7 @@ def session
@session ||= Ssh::Session.new(name,
:host => ssh_host,
:port => ssh_port,
:username => 'travis',
:username => docker_config.username,
:private_key_path => docker_config.private_key_path,
:buffer => Travis::Worker.config.shell.buffer,
:timeouts => Travis::Worker.config.timeouts
Expand Down Expand Up @@ -157,7 +158,9 @@ def fixed_ssh_host?
end

def latest_images
@latest_images ||= ::Docker::Image.all({}, connection).find_all { |i| image_matches?(i, /^travis:/) }
@latest_images ||= ::Docker::Image.all({}, connection).find_all do |i|
image_matches?(i, /^#{Regexp.escape(docker_config.image_name)}:/)
end
end

def image_for_language(lang)
Expand All @@ -174,7 +177,7 @@ def image_for_language(lang)
end

def default_image
latest_images.detect { |i| image_matches?(i, 'travis:ruby') }
latest_images.detect { |i| image_matches?(i, docker_config.default_image) }
end

def image_matches?(image, tag)
Expand Down