Puppet Class: docker::baseimages

Defined in:
modules/docker/manifests/baseimages.pp

Overview

Classs: docker::baseimages

Helper class that builds standard base images

Parameters

*docker_registry

The url of the docker registry where images should be uploaded

proxy_address

The address of the proxy for downloading packages. Undefined by default

proxy_port

The port of said proxy, if present. Undefined by default.

distributions

List of distributions to build. Defaults to both jessie and trusty.

Parameters:

  • docker_registry (Any)
  • proxy_address (Any) (defaults to: undef)
  • proxy_port (Any) (defaults to: undef)
  • distributions (Any) (defaults to: ['jessie', 'trusty'])


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'modules/docker/manifests/baseimages.pp', line 18

class docker::baseimages(
    $docker_registry,
    $proxy_address=undef,
    $proxy_port=undef,
    $distributions=['jessie', 'trusty'],
) {
    # We need docker running
    Service[docker] -> Class[docker::baseimages]

    require_package('bootstrap-vz')

    file { '/srv/images':
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
    }

    file { '/srv/images/base':
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
    }

    file { '/srv/images/base/jessie.yaml':
        content => template('docker/images/jessie.yaml.erb'),
        owner   => 'root',
        group   => 'root',
        mode    => '0544',
    }

    ## Stretch
    $stretch_keyring = '/srv/images/base/wikimedia-stretch.pub.gpg'
    file { '/srv/images/base/stretch.yaml':
        content => template('docker/images/stretch.yaml.erb'),
        owner   => 'root',
        group   => 'root',
        mode    => '0544',
    }

    file { $stretch_keyring:
        ensure => present,
        source => 'puppet:///modules/docker/wikimedia-stretch.pub.gpg',
        owner  => 'root',
        group  => 'root',
        mode   => '0444',
    }
    ## end stretch

    if 'alpine' in $distributions {
        if $proxy_address {
            $env = ["https_proxy=http://${proxy_address}:${proxy_port}"]
        }
        else {
            $env = undef
        }

        exec { 'git clone alpine linux':
            command     => '/usr/bin/git clone https://github.com/gliderlabs/docker-alpine.git alpine',
            creates     => '/srv/images/alpine',
            cwd         => '/srv/images',
            environment => $env,
            require     => File['/srv/images'],
        }

        file { '/usr/local/bin/build-alpine':
            content => template('docker/images/build-alpine.erb'),
            owner   => 'root',
            group   => 'root',
            mode    => '0544',
        }
    }

    file { '/usr/local/bin/build-base-images':
        content => template('docker/images/build-base-images.erb'),
        owner   => 'root',
        group   => 'root',
        mode    => '0544',
    }
}