Skip to content

Commit 9904b03

Browse files
committed
Merge branch 'release/1.1.0'
2 parents 6f7360b + 7352f1a commit 9904b03

File tree

612 files changed

+4035
-3645
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

612 files changed

+4035
-3645
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [WebDevOps.io Dockerfile](https://github.com/webdevops/Dockerfile).
44

5+
## [1.1.0] - 2016-12-14
6+
- Fixed dnsmasq startup
7+
- Removed all logfiles inside containers (using stdout)
8+
- Fixed syslog-ng setup (was complaining about version)
9+
- Fixed some php/hhvm tests
10+
- Improve bin/console
11+
- Add cleanup after container installation
12+
- Add multiple vhost support for dns lookup (VIRTUAL_HOST)
13+
514
## [1.0.0] - 2016-11-28
615
- Introduced python based processing script
716
- Introduced testinfra test suite

bin/command/docker_build_command.py

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class DockerBuildCommand(DoitCommand):
2828
Build images
2929
3030
docker:build
31+
{docker images?* : Docker images (whitelist)}
3132
{--dry-run : show only which images will be build}
3233
{--no-cache : build without caching}
3334
{--t|threads=0 : threads}

bin/command/docker_exec_command.py

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env/python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# (c) 2016 WebDevOps.io
5+
#
6+
# This file is part of Dockerfile Repository.
7+
#
8+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
9+
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation
10+
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
11+
# to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions
14+
# of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
17+
# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
18+
# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
21+
from cleo import Output
22+
from termcolor import colored
23+
from webdevops.command import DoitCommand
24+
from webdevops.taskloader import DockerPushTaskLoader
25+
from webdevops import Command, DockerfileUtility
26+
27+
class DockerExecCommand(DoitCommand):
28+
"""
29+
Push images to registry/hub
30+
31+
docker:exec
32+
{docker command* : Command}
33+
{--dry-run : show only which images will be build}
34+
{--whitelist=?* : image/tag whitelist }
35+
{--blacklist=?* : image/tag blacklist }
36+
"""
37+
38+
def run_task(self, configuration):
39+
dockerfile_list = DockerfileUtility.find_dockerfiles_in_path(
40+
base_path=configuration.get('dockerPath'),
41+
path_regex=configuration.get('docker.pathRegex'),
42+
image_prefix=configuration.get('docker.imagePrefix'),
43+
whitelist=configuration.get('whitelist'),
44+
blacklist=configuration.get('blacklist'),
45+
)
46+
47+
image_fail_list = []
48+
49+
docker_command = self.argument('docker command')
50+
51+
for dockerfile in dockerfile_list:
52+
title = dockerfile['image']['fullname']
53+
54+
print title
55+
print '~' * len(title)
56+
57+
if configuration['dryRun']:
58+
print ' exec: %s' % (docker_command)
59+
else:
60+
61+
cmd = [
62+
'docker',
63+
'run',
64+
'-t',
65+
'--rm',
66+
dockerfile['image']['fullname'],
67+
'sh -c "%s"' % (' '.join(docker_command))
68+
]
69+
70+
status = Command.execute(cmd)
71+
72+
if status:
73+
print colored(' -> successfull', 'green')
74+
else:
75+
print colored(' -> failed', 'red')
76+
image_fail_list.append(dockerfile['image']['fullname'])
77+
print ''
78+
print ''
79+
80+
if len(image_fail_list) >= 1:
81+
print ''
82+
print colored(' => failed images (%s):' % (str(len(image_fail_list))), 'red')
83+
for image in image_fail_list:
84+
print ' - %s ' % image
85+
print ''
86+
87+
return False
88+
else:
89+
return True
90+
91+
92+
93+

bin/command/docker_pull_command.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class DockerPullCommand(DoitCommand):
2727
Pull all built images from registry/hub
2828
2929
docker:pull
30+
{docker images?* : Docker images (whitelist)}
3031
{--dry-run : show only which images will be build}
3132
{--t|threads=0 : threads}
3233
{--r|retry=0 : retry}

bin/command/docker_push_command.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class DockerPushCommand(DoitCommand):
2727
Push images to registry/hub
2828
2929
docker:push
30+
{docker images?* : Docker images (whitelist)}
3031
{--dry-run : show only which images will be build}
3132
{--t|threads=0 : threads}
3233
{--r|retry=0 : retry}

bin/command/generate_dockerfile_command.py

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class GenerateDockerfileCommand(BaseCommand):
2929
Build Dockerfile containers
3030
3131
generate:dockerfile
32+
{docker images?* : Docker images (whitelist)}
3233
{--whitelist=?* : image/tag whitelist }
3334
{--blacklist=?* : image/tag blacklist }
3435
"""

bin/command/test_serverspec_command.py

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class TestServerspecCommand(DoitCommand):
2929
Test docker images with Serverspec
3030
3131
test:serverspec
32+
{docker images?* : Docker images (whitelist)}
3233
{--dry-run : show only which images will be build}
3334
{--t|threads=0 : threads}
3435
{--r|retry=0 : retry}

bin/command/test_testinfra_command.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class TestTestinfraCommand(DoitCommand):
2727
Test docker images with Testinfra
2828
2929
test:testinfra
30+
{docker images?* : Docker images (whitelist)}
3031
{--dry-run : show only which images will be build}
3132
{--t|threads=0 : threads}
3233
{--whitelist=?* : image/tag whitelist }

bin/console

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ from webdevops.docker.DockerCliClient import DockerCliClient
2020
from command.docker_build_command import DockerBuildCommand
2121
from command.docker_push_command import DockerPushCommand
2222
from command.docker_pull_command import DockerPullCommand
23+
from command.docker_exec_command import DockerExecCommand
2324
from command.test_testinfra_command import TestTestinfraCommand
2425
from command.test_serverspec_command import TestServerspecCommand
2526
from command.generate_dockerfile_command import GenerateDockerfileCommand
@@ -88,6 +89,7 @@ if __name__ == '__main__':
8889
application.add(DockerBuildCommand(configuration=configuration))
8990
application.add(DockerPushCommand(configuration=configuration))
9091
application.add(DockerPullCommand(configuration=configuration))
92+
application.add(DockerExecCommand(configuration=configuration))
9193
application.add(TestTestinfraCommand(configuration=configuration))
9294
application.add(TestServerspecCommand(configuration=configuration))
9395
application.add(GenerateDockerfileCommand(configuration=configuration))

bin/webdevops/DockerfileUtility.py

+19-10
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ def find_file_in_path(dockerfile_path, filename="Dockerfile", whitelist=False, b
5353

5454
# filter by whitelist
5555
if whitelist:
56-
for term in whitelist:
57-
file_list = filter(lambda x: term in x, file_list)
56+
tmp = []
57+
for file in file_list:
58+
for term in whitelist:
59+
if term in file:
60+
tmp.append(file)
61+
break
62+
file_list = tmp
5863

5964
if blacklist:
6065
for term in blacklist:
@@ -108,12 +113,11 @@ def parse_docker_info_from_path(path):
108113
}
109114
ret.append(dockerfile)
110115

111-
if whitelist or blacklist:
112-
ret = filter_dockerfile(
113-
dockerfile_list=ret,
114-
whitelist=whitelist,
115-
blacklist = blacklist
116-
)
116+
ret = filter_dockerfile(
117+
dockerfile_list=ret,
118+
whitelist=whitelist,
119+
blacklist = blacklist
120+
)
117121

118122
return ret
119123

@@ -123,8 +127,13 @@ def filter_dockerfile(dockerfile_list, whitelist=False, blacklist=False):
123127
Filter Dockerfiles by white- and blacklist
124128
"""
125129
if whitelist:
126-
for term in whitelist:
127-
dockerfile_list = filter(lambda x: term in x['image']['fullname'], dockerfile_list)
130+
tmp = []
131+
for dockerfile in dockerfile_list:
132+
for term in whitelist:
133+
if term in dockerfile['image']['fullname']:
134+
tmp.append(dockerfile)
135+
break
136+
dockerfile_list = tmp
128137

129138
if blacklist:
130139
for term in blacklist:

bin/webdevops/command/BaseCommand.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,17 @@ def get_whitelist(self):
183183
"""
184184
Get whitelist
185185
"""
186-
return list(self.option('whitelist'))
186+
187+
# add whitelist from --whitelist
188+
ret = list(self.option('whitelist'))
189+
190+
# add whitelist from argument list
191+
try:
192+
ret.extend(self.argument('docker images'))
193+
except (Exception):
194+
pass
195+
196+
return ret
187197

188198
def get_blacklist(self):
189199
"""
@@ -211,13 +221,13 @@ def get_threads(self):
211221
# use configuration value
212222
threads = self.configuration.get('threads')
213223

214-
match = re.match('auto(([-*+/])([0-9]+))?', str(threads))
224+
match = re.match('auto(([-*+/])([0-9]+\.?[0-9]?))?', str(threads))
215225
if match is not None:
216226
ret = multiprocessing.cpu_count()
217227

218228
if match.group(2) and match.group(3):
219229
math_sign = match.group(2)
220-
math_value = int(match.group(3))
230+
math_value = float(match.group(3))
221231

222232
if math_sign == "*":
223233
ret = int(ret * math_value)

bin/webdevops/docker/DockerCliClient.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@
1818
# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1919
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020

21-
import subprocess
22-
import os
23-
import tempfile
21+
import os, subprocess, tempfile
2422
from .DockerBaseClient import DockerBaseClient
2523
from webdevops import Command
2624

27-
2825
class DockerCliClient(DockerBaseClient):
2926

3027
def pull_image(self, name, tag):

bin/webdevops/docker/DockerPyClient.py

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1919
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020

21-
2221
import os
2322
from .DockerBaseClient import DockerBaseClient
2423

bin/webdevops/doit/DoitReporter.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@
1818
# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1919
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020

21-
import sys
22-
import os
23-
import time
24-
import datetime
25-
import StringIO
21+
import os, sys, time, datetime, StringIO
2622
import termcolor
2723
from termcolor import colored
24+
from ..taskloader.BaseTaskLoader import BaseTaskLoader
2825

2926
class TaskResult(object):
3027
"""
@@ -141,7 +138,7 @@ def add_failure(self, task, exception):
141138

142139
if task.actions and (task.name[0] != '_'):
143140
duration = self.duration(self.t_results[task.name].elapsed)
144-
self.write(colored('. %s FAILED (%s)\n' % (task.title(), duration), 'red'))
141+
self.writeln(colored('. %s FAILED (%s)' % (BaseTaskLoader.human_task_name(task.title()), duration), 'red'))
145142
self.failures.append({'task': task, 'exception': exception})
146143

147144
def add_success(self, task):
@@ -152,7 +149,7 @@ def add_success(self, task):
152149

153150
if task.actions and (task.name[0] != '_'):
154151
duration = self.duration(self.t_results[task.name].elapsed)
155-
self.write(colored('. %s finished (%s)\n' % (task.title(), duration), 'green'))
152+
self.writeln(colored('. %s finished (%s)' % (BaseTaskLoader.human_task_name(task.title()), duration), 'green'))
156153

157154
def skip_uptodate(self, task):
158155
"""
@@ -252,7 +249,7 @@ def task_stdout(self, title, duration=False, stdout=False, stderr=False, error=F
252249
if duration:
253250
text_duration = ' (%s)' % self.duration(duration)
254251

255-
title_full = 'Task %s%s:' % (title, text_duration)
252+
title_full = 'Task %s%s:' % (BaseTaskLoader.human_task_name(title), text_duration)
256253

257254
self.writeln(title_full)
258255
self.writeln('~' * len(title_full))
@@ -277,7 +274,7 @@ def task_stdout(self, title, duration=False, stdout=False, stderr=False, error=F
277274
self.write('%s' % exception.get_msg())
278275

279276
self.writeln()
280-
self.writeln(':: end of output "%s"' % title)
277+
self.writeln(':: end of output "%s"' % (BaseTaskLoader.human_task_name(title)))
281278
self.writeln()
282279

283280
def duration(self, duration):

bin/webdevops/taskloader/BaseDockerTaskLoader.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1919
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020

21-
import os
22-
import sys
23-
import re
24-
import copy
21+
import os, sys, re, copy
2522
from .BaseTaskLoader import BaseTaskLoader
2623
from webdevops import DockerfileUtility
2724
from doit.task import dict_to_task

bin/webdevops/taskloader/BaseTaskLoader.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1919
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020

21-
import sys
22-
import re
23-
import time
24-
import StringIO
21+
import sys, re, time, StringIO
2522
from webdevops import DockerfileUtility
2623
from doit.cmd_base import TaskLoader
2724
from doit.task import dict_to_task
@@ -44,6 +41,9 @@ def process_tasklist(self, tasklist):
4441
ret = []
4542
for task in tasklist:
4643
ret.append(dict_to_task(task))
44+
45+
print 'Starting execution of %s tasks...' % (len(ret))
46+
4747
return ret
4848

4949

@@ -52,7 +52,12 @@ def human_task_name(name):
5252
"""
5353
Translate internal task name to human readable name
5454
"""
55-
return re.search('^.*\|(.*)', name).group(1)
55+
res = re.search('^.*\|(.*)', name)
56+
57+
if res:
58+
return re.search('^.*\|(.*)', name).group(1)
59+
else:
60+
return name
5661

5762

5863
@staticmethod

bin/webdevops/taskloader/DockerBuildTaskLoader.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818
# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1919
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020

21-
import os
22-
import sys
23-
import re
24-
import copy
25-
import time
21+
import os, sys, re, copy, time
2622
from .BaseTaskLoader import BaseTaskLoader
2723
from .BaseDockerTaskLoader import BaseDockerTaskLoader
2824
from webdevops import DockerfileUtility

0 commit comments

Comments
 (0)