Skip to content

Commit b875b6b

Browse files
committed
Refactoring and cleanup
- Remove full path for docker-image-cleanup - Add webdevops/dockerfile-build-env (build environment for Dockerfile repository) - Add new docker-image-info command to gather information of current image - Restore default locale - Remove editors (moved to -dev images) - Replace php:5.6, php:7.0 and php:7.1 with symlink (automatic duplication detection, avoid duplicate test running) - Improve duplication checks for images (skip duplicate serverspec tests, but in build fail if source is not available) - Remove provision.sh test - Remove logwatch.sh - Remove logwatch - Improve service provisioning - Remove sudo - Remove syslog (provision on demand with 'docker-service-enable syslog') - Cleanup entrypoint and scripts - Only run entrypoint provision if roles are available (skip python task)
1 parent 7e1efc3 commit b875b6b

File tree

733 files changed

+2879
-3211
lines changed

Some content is hidden

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

733 files changed

+2879
-3211
lines changed

baselayout/usr/local/bin/docker-image-cleanup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
44
set -o errexit ## set -e : exit the script if any statement returns a non-true return value
55

6-
LSB_FAMILY=$(cat /etc/dockerimage_distribution_family)
6+
LSB_FAMILY=$(docker-image-info family)
77

88
case "$LSB_FAMILY" in
99
Debian)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/sh
2+
3+
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
4+
set -o errexit ## set -e : exit the script if any statement returns a non-true return value
5+
6+
help() {
7+
if [ -n "$1" ]; then
8+
echo "$1"
9+
echo ""
10+
fi
11+
12+
echo "Usage: $0 <argument>"
13+
echo ""
14+
echo " Application arguments:"
15+
echo " family Get distribution family"
16+
echo " dist Get distribution name"
17+
echo " dist-version Get distribution version"
18+
echo " dist-release Get distribution release"
19+
echo " dist-codename Get distribution codename"
20+
echo " lsb Get lsb informations (if available)"
21+
echo " lsb-desc Get lsb description (if available)"
22+
echo " buildtime Get buildtime of docker image"
23+
echo ""
24+
25+
exit $2
26+
27+
}
28+
29+
if [ "$#" -ne 1 ]; then
30+
help "[ERROR] Invalid argument" 1
31+
fi
32+
33+
INFO_FILE=""
34+
35+
case "$1" in
36+
dist-family|distribution-family|family)
37+
INFO_FILE=/opt/docker/etc/.registry/image_info_distribution_family
38+
;;
39+
40+
dist|distribution)
41+
INFO_FILE=/opt/docker/etc/.registry/image_info_distribution
42+
;;
43+
44+
dist-version|distribution-version)
45+
INFO_FILE=/opt/docker/etc/.registry/image_info_distribution_version
46+
;;
47+
48+
dist-release|distribution-release)
49+
INFO_FILE=/opt/docker/etc/.registry/image_info_lsb_release
50+
;;
51+
52+
dist-codename|distribution-codename)
53+
INFO_FILE=/opt/docker/etc/.registry/image_info_lsb_codename
54+
;;
55+
56+
lsb)
57+
INFO_FILE=/opt/docker/etc/.registry/image_info_lsb
58+
;;
59+
60+
lsb-desc|lsb-description)
61+
INFO_FILE=/opt/docker/etc/.registry/image_info_lsb_description
62+
;;
63+
64+
buildtime)
65+
INFO_FILE=/opt/docker/etc/.registry/image_info_buildtime
66+
;;
67+
68+
help)
69+
help "" 0
70+
;;
71+
72+
*)
73+
help "[ERROR] Invalid argument" 1
74+
;;
75+
esac
76+
77+
if [ -n "$INFO_FILE" ]; then
78+
if [ -f "$INFO_FILE" ]; then
79+
cat -- "$INFO_FILE"
80+
else
81+
echo "[ERROR] Infomation file $INFO_FILE not found!"
82+
echo " Please run generate-dockerimage-info on docker image creation!"
83+
exit 2
84+
fi
85+
else
86+
help "" 1
87+
fi

baselayout/usr/local/bin/generate-dockerimage-info

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,32 @@ esac
5050
#############################
5151

5252
echo "Detected $LSB_FAMILY"
53-
echo "$LSB_FAMILY" > /etc/dockerimage_distribution_family
54-
echo "$LSB_FAMILY" > /etc/dockerimage_distribution
53+
54+
mkdir -p /opt/docker/etc/.registry/
55+
echo "$LSB_FAMILY" > /opt/docker/etc/.registry/image_info_distribution_family
56+
echo "$LSB_FAMILY" > /opt/docker/etc/.registry/image_info_distribution
57+
date +%s >/opt/docker/etc/.registry/image_info_buildtime
5558

5659
# Create all files
57-
touch /etc/dockerimage_distribution_version
58-
touch /etc/dockerimage_lsb
59-
touch /etc/dockerimage_lsb_id
60-
touch /etc/dockerimage_lsb_id
61-
touch /etc/dockerimage_lsb_release
62-
touch /etc/dockerimage_lsb_codename
60+
touch /opt/docker/etc/.registry/image_info_distribution_version
61+
touch /opt/docker/etc/.registry/image_info_lsb
62+
touch /opt/docker/etc/.registry/image_info_lsb_description
63+
touch /opt/docker/etc/.registry/image_info_lsb_release
64+
touch /opt/docker/etc/.registry/image_info_lsb_codename
6365

6466
# Collect distribution specific informations
6567
case "$LSB_FAMILY" in
6668
Debian|RedHat)
67-
lsb_release -i -s > /etc/dockerimage_distribution
68-
lsb_release -r -s > /etc/dockerimage_distribution_version
69-
lsb_release -a > /etc/dockerimage_lsb
70-
lsb_release -i -s > /etc/dockerimage_lsb_id
71-
lsb_release -d -s > /etc/dockerimage_lsb_id
72-
lsb_release -r -s > /etc/dockerimage_lsb_release
73-
lsb_release -c -s > /etc/dockerimage_lsb_codename
69+
lsb_release -i -s > /opt/docker/etc/.registry/image_info_distribution
70+
lsb_release -r -s > /opt/docker/etc/.registry/image_info_distribution_version
71+
lsb_release -a > /opt/docker/etc/.registry/image_info_lsb
72+
lsb_release -d -s > /opt/docker/etc/.registry/image_info_lsb_description
73+
lsb_release -r -s > /opt/docker/etc/.registry/image_info_lsb_release
74+
lsb_release -c -s > /opt/docker/etc/.registry/image_info_lsb_codename
7475
;;
7576

7677
Alpine)
77-
cat /etc/alpine-release > /etc/dockerimage_distribution_version
78+
cat /etc/alpine-release > /opt/docker/etc/.registry/image_info_distribution_version
7879
;;
7980
esac
8081

baselayout/usr/local/bin/generate-locales

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@ set -o errtrace ## trace ERR through 'time command' and other functions
55
set -o nounset ## set -u : exit the script if you try to use an uninitialised variable
66
set -o errexit ## set -e : exit the script if any statement returns a non-true return value
77

8-
LSB_DISTRIBUTION=$(cat /etc/dockerimage_distribution)
9-
LSB_DISTRIBUTION_VERSION=$(cat /etc/dockerimage_distribution_version)
8+
IMAGE_DISTRIBUTION_FAMILY=$(docker-image-info family)
9+
IMAGE_DISTRIBUTION=$(docker-image-info distribution)
10+
IMAGE_DISTRIBUTION_VERSION=$(docker-image-info distribution-version)
1011

1112
#######################################
1213
## Debian
1314
#######################################
1415

15-
if [[ "$LSB_DISTRIBUTION" == "Debian" ]]; then
16+
if [[ "$IMAGE_DISTRIBUTION" == "Debian" ]]; then
1617
/usr/local/bin/apt-install locales-all
1718
fi
1819

1920
#######################################
2021
## Ubuntu
2122
#######################################
2223

23-
if [[ "$LSB_DISTRIBUTION" == "Ubuntu" ]]; then
24-
if [[ "$(echo $LSB_DISTRIBUTION_VERSION| cut -f 1 -d .)" -ge "16" ]]; then
24+
if [[ "$IMAGE_DISTRIBUTION" == "Ubuntu" ]]; then
25+
if [[ "$(echo $IMAGE_DISTRIBUTION_VERSION| cut -f 1 -d .)" -ge "16" ]]; then
2526
# Ubuntu 16.04 or later
2627
/usr/local/bin/apt-install locales-all
2728
else
@@ -35,12 +36,12 @@ fi
3536
## RedHat family
3637
#######################################
3738

38-
function localedefdebug() {
39-
echo $*
40-
localedef "$@"
41-
}
39+
if [[ "$IMAGE_DISTRIBUTION_FAMILY" == "RedHat" ]]; then
4240

43-
if [[ -f /etc/redhat-release ]]; then
41+
function localedefdebug() {
42+
echo $*
43+
localedef "$@"
44+
}
4445

4546
# Failing locales
4647
## && localedefdebug -c -i bo_CN -f UTF-8 bo_CN.utf8 \

bin/webdevops/DockerfileUtility.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def parse_docker_info_from_path(path):
7979
image_name = (image_name_info['image'] if 'image' in image_name_info else '')
8080
image_tag = (image_name_info['tag'] if 'tag' in image_name_info else '')
8181

82+
image_is_duplicate = False
83+
8284
# check if path is linked
8385
if os.path.islink(os.path.dirname(path)):
8486
linked_image_name_info = ([m.groupdict() for m in path_regex.finditer(os.path.realpath(path))])[0]
@@ -88,6 +90,7 @@ def parse_docker_info_from_path(path):
8890
linked_image_tag = (linked_image_name_info['tag'] if 'tag' in linked_image_name_info else '')
8991

9092
image_from = image_prefix + linked_image_repository + '/' + linked_image_name + ':' + linked_image_tag
93+
image_is_duplicate = True
9194
else:
9295
image_from = parse_dockerfile_from_statement(path)
9396

@@ -97,7 +100,8 @@ def parse_docker_info_from_path(path):
97100
'tag': image_tag,
98101
'repository': image_prefix + image_repository,
99102
'imageName': image_name,
100-
'from': image_from
103+
'from': image_from,
104+
'duplicate': image_is_duplicate
101105
}
102106
return imageInfo
103107

bin/webdevops/doit/DoitReporter.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,14 @@ def complete_run(self):
237237
if 'FinishChain|' in task['name']:
238238
continue
239239

240-
self.task_stdout(
241-
title=task['name'],
242-
duration=task['elapsed'],
243-
stdout=task['out'],
244-
stderr=task['err'],
245-
error=task['error']
246-
)
240+
if task['result'] != 'fail':
241+
self.task_stdout(
242+
title=task['name'],
243+
duration=task['elapsed'],
244+
stdout=task['out'],
245+
stderr=task['err'],
246+
error=task['error']
247+
)
247248

248249
# show failed tasks (at the end)
249250
for task in task_result_list:

bin/webdevops/taskloader/DockerBuildTaskLoader.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ def task_run(docker_client, dockerfile, configuration, task):
5959
Build one Dockerfile
6060
"""
6161

62+
# check if dockerfile is symlink, skipping tests if just a duplicate image
63+
# image is using the same hashes
64+
if dockerfile['image']['duplicate'] and not task.task_dep:
65+
print ' Docker image %s is build from symlink but not included in build chain, please include %s' % (dockerfile['image']['fullname'], dockerfile['image']['from'])
66+
print ' -> failing build'
67+
return False
68+
6269
pull_parent_image = DockerfileUtility.check_if_base_image_needs_pull(dockerfile, configuration)
6370

6471
if configuration.get('dryRun'):

bin/webdevops/taskloader/DockerTestServerspecTaskLoader.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ def task_run(dockerfile, configuration, task):
6161
"""
6262
Run test
6363
"""
64+
65+
# check if dockerfile is symlink, skipping tests if just a duplicate image
66+
# image is using the same hashes
67+
if dockerfile['image']['duplicate']:
68+
print ' Docker image %s is build from symlink and duplicate of %s' % (dockerfile['image']['fullname'], dockerfile['image']['from'])
69+
print ' -> skipping tests'
70+
return True
71+
6472
# Check if current image is a toolimage (no daemon)
6573
is_toolimage = False
6674
for term in configuration.get('dockerTest.toolImages', {}):

docker/ansible/alpine/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ RUN /usr/local/bin/apk-install \
2525
&& chmod 750 /usr/bin/ansible* \
2626
# Cleanup
2727
&& apk del python-dev \
28-
&& /usr/local/bin/docker-image-cleanup
28+
&& docker-image-cleanup

docker/ansible/centos-7/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ RUN /usr/local/bin/yum-install \
2525
&& chmod 750 /usr/bin/ansible* \
2626
# Cleanup
2727
&& yum erase -y python-devel \
28-
&& /usr/local/bin/docker-image-cleanup
28+
&& docker-image-cleanup

0 commit comments

Comments
 (0)