providers/dock: pull image prior to starting
This commit is contained in:
parent
26fe5ac89f
commit
c2cae80de5
|
@ -26,6 +26,7 @@ IMPROVEMENTS:
|
||||||
- guests/photon: initial support [GH-5612]
|
- guests/photon: initial support [GH-5612]
|
||||||
- guests/solaris,solaris11: support inserting generated key [GH-5182]
|
- guests/solaris,solaris11: support inserting generated key [GH-5182]
|
||||||
[GH-5290]
|
[GH-5290]
|
||||||
|
- providers/docker: images are pulled prior to starting [GH-5249]
|
||||||
- provisioners/chef: add capability for checking if Chef is installed on Windows [GH-5669]
|
- provisioners/chef: add capability for checking if Chef is installed on Windows [GH-5669]
|
||||||
- provisioners/puppet: add support for Puppet 4 and configuration options [GH-5601]
|
- provisioners/puppet: add support for Puppet 4 and configuration options [GH-5601]
|
||||||
- provisioners/puppet: add support for `synced_folder_args` in apply [GH-5359]
|
- provisioners/puppet: add support for `synced_folder_args` in apply [GH-5359]
|
||||||
|
|
|
@ -4,65 +4,7 @@
|
||||||
# Ruby, run unit tests, etc.
|
# Ruby, run unit tests, etc.
|
||||||
|
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
config.vm.box = "hashicorp/precise64"
|
config.vm.provider "docker" do |d|
|
||||||
config.vm.hostname = "vagrant"
|
d.image = "nginx"
|
||||||
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
|
|
||||||
|
|
||||||
["vmware_fusion", "vmware_workstation", "virtualbox"].each do |provider|
|
|
||||||
config.vm.provider provider do |v, override|
|
|
||||||
v.memory = "1024"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.provision "shell", inline: $shell
|
|
||||||
|
|
||||||
config.push.define "www", strategy: "local-exec" do |push|
|
|
||||||
push.script = "scripts/website_push_www.sh"
|
|
||||||
end
|
|
||||||
|
|
||||||
config.push.define "docs", strategy: "local-exec" do |push|
|
|
||||||
push.script = "scripts/website_push_docs.sh"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
$shell = <<-CONTENTS
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
|
||||||
MARKER_FILE="/usr/local/etc/vagrant_provision_marker"
|
|
||||||
|
|
||||||
# Only provision once
|
|
||||||
if [ -f "${MARKER_FILE}" ]; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update apt
|
|
||||||
apt-get update
|
|
||||||
|
|
||||||
# Install basic dependencies
|
|
||||||
apt-get install -y build-essential bsdtar curl
|
|
||||||
|
|
||||||
# Import the mpapis public key to verify downloaded releases
|
|
||||||
su -l -c 'curl -sSL https://rvm.io/mpapis.asc | gpg -q --import -' vagrant
|
|
||||||
|
|
||||||
# Install RVM
|
|
||||||
su -l -c 'curl -sL https://get.rvm.io | bash -s stable' vagrant
|
|
||||||
|
|
||||||
# Add the vagrant user to the RVM group
|
|
||||||
#usermod -a -G rvm vagrant
|
|
||||||
|
|
||||||
# Install some Rubies
|
|
||||||
su -l -c 'rvm install 2.1.1' vagrant
|
|
||||||
su -l -c 'rvm --default use 2.1.1' vagrant
|
|
||||||
|
|
||||||
# Output the Ruby version (for sanity)
|
|
||||||
su -l -c 'ruby --version' vagrant
|
|
||||||
|
|
||||||
# Install Git
|
|
||||||
apt-get install -y git
|
|
||||||
|
|
||||||
# Automatically move into the shared folder, but only add the command
|
|
||||||
# if it's not already there.
|
|
||||||
grep -q 'cd /vagrant' /home/vagrant/.bash_profile || echo 'cd /vagrant' >> /home/vagrant/.bash_profile
|
|
||||||
|
|
||||||
# Touch the marker file so we don't do this again
|
|
||||||
touch ${MARKER_FILE}
|
|
||||||
CONTENTS
|
|
||||||
|
|
|
@ -258,6 +258,7 @@ module VagrantPlugins
|
||||||
b3.use HandleForwardedPortCollisions
|
b3.use HandleForwardedPortCollisions
|
||||||
b3.use SyncedFolders
|
b3.use SyncedFolders
|
||||||
b3.use ForwardedPorts
|
b3.use ForwardedPorts
|
||||||
|
b3.use Pull
|
||||||
b3.use Create
|
b3.use Create
|
||||||
b3.use WaitForRunning
|
b3.use WaitForRunning
|
||||||
else
|
else
|
||||||
|
@ -302,6 +303,7 @@ module VagrantPlugins
|
||||||
autoload :IsBuild, action_root.join("is_build")
|
autoload :IsBuild, action_root.join("is_build")
|
||||||
autoload :IsHostMachineCreated, action_root.join("is_host_machine_created")
|
autoload :IsHostMachineCreated, action_root.join("is_host_machine_created")
|
||||||
autoload :Login, action_root.join("login")
|
autoload :Login, action_root.join("login")
|
||||||
|
autoload :Pull, action_root.join("pull")
|
||||||
autoload :PrepareSSH, action_root.join("prepare_ssh")
|
autoload :PrepareSSH, action_root.join("prepare_ssh")
|
||||||
autoload :Stop, action_root.join("stop")
|
autoload :Stop, action_root.join("stop")
|
||||||
autoload :PrepareNFSValidIds, action_root.join("prepare_nfs_valid_ids")
|
autoload :PrepareNFSValidIds, action_root.join("prepare_nfs_valid_ids")
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module DockerProvider
|
||||||
|
module Action
|
||||||
|
class Pull
|
||||||
|
def initialize(app, env)
|
||||||
|
@app = app
|
||||||
|
end
|
||||||
|
|
||||||
|
def call(env)
|
||||||
|
@env = env
|
||||||
|
@machine = env[:machine]
|
||||||
|
@provider_config = @machine.provider_config
|
||||||
|
@driver = @machine.provider.driver
|
||||||
|
|
||||||
|
image = @env[:create_image]
|
||||||
|
image ||= @provider_config.image
|
||||||
|
|
||||||
|
env[:ui].output(I18n.t("docker_provider.pull", image: image))
|
||||||
|
@driver.pull(image)
|
||||||
|
|
||||||
|
@app.call(env)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -102,6 +102,10 @@ module VagrantPlugins
|
||||||
execute(*cmd.flatten)
|
execute(*cmd.flatten)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pull(image)
|
||||||
|
execute('docker', 'pull', image)
|
||||||
|
end
|
||||||
|
|
||||||
def start(cid)
|
def start(cid)
|
||||||
if !running?(cid)
|
if !running?(cid)
|
||||||
execute('docker', 'start', cid)
|
execute('docker', 'start', cid)
|
||||||
|
|
|
@ -43,6 +43,8 @@ en:
|
||||||
Container not created. Skipping.
|
Container not created. Skipping.
|
||||||
not_docker_provider: |-
|
not_docker_provider: |-
|
||||||
Not backed by Docker provider. Skipping.
|
Not backed by Docker provider. Skipping.
|
||||||
|
pull: |-
|
||||||
|
Pulling image '%{image}'...
|
||||||
run_command_required: |-
|
run_command_required: |-
|
||||||
`vagrant docker-run` requires a command to execute. This command
|
`vagrant docker-run` requires a command to execute. This command
|
||||||
must be specified after a `--` in the command line. This is used
|
must be specified after a `--` in the command line. This is used
|
||||||
|
|
|
@ -84,6 +84,13 @@ describe VagrantPlugins::DockerProvider::Driver do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#pull' do
|
||||||
|
it 'should pull images' do
|
||||||
|
subject.should_receive(:execute).with('docker', 'pull', 'foo')
|
||||||
|
subject.pull('foo')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#running?' do
|
describe '#running?' do
|
||||||
let(:result) { subject.running?(cid) }
|
let(:result) { subject.running?(cid) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue