diff --git a/Vagrantfile b/Vagrantfile index c823a39581..31b6bf5b32 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -34,7 +34,7 @@ Vagrant::Config.run do |config| # Share an additional folder to the guest VM. The first argument is # an identifier, the second is the path on the guest to mount the # folder, and the third is the path on the host to the actual folder. - # config.vm.share_folder "v-data", "/vagrant_data", "../data" + config.vm.share_folder "v-data", "~/docker", "~/docker" # Enable provisioning with Puppet stand alone. Puppet manifests # are contained in a directory path relative to this Vagrantfile. diff --git a/fs/store.go b/fs/store.go index 2e84aa5791..596d1ab62c 100644 --- a/fs/store.go +++ b/fs/store.go @@ -172,42 +172,35 @@ func (store *Store) Create(layerData Archive, parent *Image, pth, comment string if parent != nil { img.Parent = parent.Id } - // FIXME: we shouldn't have to pass os.Stderr to AddLayer()... // FIXME: Archive should contain compression info. For now we only support uncompressed. + err := store.Register(layerData, img, pth) + return img, err +} + +func (store *Store) Register(layerData Archive, img *Image, pth string) error { + img.store = store _, err := store.layers.AddLayer(img.Id, layerData) if err != nil { - return nil, fmt.Errorf("Could not add layer: %s", err) + return fmt.Errorf("Could not add layer: %s", err) } - path := &Path{ + pathObj := &Path{ Path: path.Clean(pth), Image: img.Id, } trans, err := store.orm.Begin() if err != nil { - return nil, fmt.Errorf("Could not begin transaction: %s", err) + return fmt.Errorf("Could not begin transaction: %s", err) } if err := trans.Insert(img); err != nil { - return nil, fmt.Errorf("Could not insert image info: %s", err) + return fmt.Errorf("Could not insert image info: %s", err) } - if err := trans.Insert(path); err != nil { - return nil, fmt.Errorf("Could not insert path info: %s", err) + if err := trans.Insert(pathObj); err != nil { + return fmt.Errorf("Could not insert path info: %s", err) } if err := trans.Commit(); err != nil { - return nil, fmt.Errorf("Could not commit transaction: %s", err) + return fmt.Errorf("Could not commit transaction: %s", err) } - return img, nil -} - -func (store *Store) Register(image *Image, pth string) error { - image.store = store - // FIXME: import layer - trans, err := store.orm.Begin() - if err != nil { - return err - } - trans.Insert(image) - trans.Insert(&Path{Path: pth, Image: image.Id}) - return trans.Commit() + return nil } func (store *Store) Layers() []string { diff --git a/fs/store_test.go b/fs/store_test.go index f2cc065342..b8b2516700 100644 --- a/fs/store_test.go +++ b/fs/store_test.go @@ -4,9 +4,11 @@ import ( "errors" "fmt" "github.com/dotcloud/docker/fake" + "github.com/dotcloud/docker/future" "io/ioutil" "os" "testing" + "time" ) func TestInit(t *testing.T) { @@ -52,6 +54,40 @@ func TestCreate(t *testing.T) { } } +func TestRegister(t *testing.T) { + store, err := TempStore("testregister") + if err != nil { + t.Fatal(err) + } + defer nuke(store) + archive, err := fake.FakeTar() + if err != nil { + t.Fatal(err) + } + image := &Image{ + Id: future.RandomId(), + Comment: "testing", + Created: time.Now().Unix(), + store: store, + } + err = store.Register(archive, image, "foo") + if err != nil { + t.Fatal(err) + } + if images, err := store.Images(); err != nil { + t.Fatal(err) + } else if l := len(images); l != 1 { + t.Fatalf("Wrong number of images. Should be %d, not %d", 1, l) + } + if images, err := store.List("foo"); err != nil { + t.Fatal(err) + } else if l := len(images); l != 1 { + t.Fatalf("Path foo has wrong number of images (should be %d, not %d)", 1, l) + } else if images[0].Id != image.Id { + t.Fatalf("Imported image should be listed at path foo (%s != %s)", images[0], image) + } +} + func TestTag(t *testing.T) { store, err := TempStore("testtag") if err != nil { diff --git a/puppet/modules/docker/manifests/init.pp b/puppet/modules/docker/manifests/init.pp index 38b40a8e39..d2816907ca 100644 --- a/puppet/modules/docker/manifests/init.pp +++ b/puppet/modules/docker/manifests/init.pp @@ -8,6 +8,7 @@ class docker { Package { ensure => "installed" } package { ["lxc", "debootstrap", "wget", "bsdtar", "git", + "pkg-config", "libsqlite3-dev", "linux-image-3.5.0-25-generic", "linux-image-extra-3.5.0-25-generic", "virtualbox-guest-utils", @@ -42,18 +43,19 @@ class docker { require => [Exec["fetch-docker"], Exec["debootstrap"]] } + file { "/home/vagrant/.profile": + mode => 644, + owner => "vagrant", + group => "vagrant", + content => template("docker/profile"), + } + exec { "copy-docker-bin" : require => Exec["fetch-docker"], command => "/bin/cp /home/vagrant/docker-master/docker /usr/local/bin", creates => "/usr/local/bin/docker" } - exec { "copy-dockerd-bin" : - require => Exec["fetch-docker"], - command => "/bin/cp /home/vagrant/docker-master/dockerd /usr/local/bin", - creates => "/usr/local/bin/dockerd" - } - exec { "vbox-add" : require => Package["linux-headers-3.5.0-25-generic"], command => "/etc/init.d/vboxadd setup", diff --git a/puppet/modules/docker/templates/dockerd.conf b/puppet/modules/docker/templates/dockerd.conf index c05f606391..2d77c301f0 100644 --- a/puppet/modules/docker/templates/dockerd.conf +++ b/puppet/modules/docker/templates/dockerd.conf @@ -8,5 +8,5 @@ respawn script test -f /etc/default/locale && . /etc/default/locale || true - LANG=$LANG LC_ALL=$LANG /usr/local/bin/dockerd + LANG=$LANG LC_ALL=$LANG /usr/local/bin/docker -d end script diff --git a/puppet/modules/docker/templates/profile b/puppet/modules/docker/templates/profile new file mode 100644 index 0000000000..c52d87387c --- /dev/null +++ b/puppet/modules/docker/templates/profile @@ -0,0 +1,27 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set ~/docker as the go path +export GOPATH=~/docker +# add go to the PATH +export PATH=$PATH:/usr/local/go/bin \ No newline at end of file