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

Lines changed: 9 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 93 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 19 additions & 10 deletions
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:

0 commit comments

Comments
 (0)