Repository: cekit/cekit

Issue:
Remove documentation by default
When installing packages, in order to reduce the size of the images, they could be installed with the `--setopt=tsflags=nodocs` by default.

Suggestion taken from [Container Best Practices](http://docs.projectatomic.io/container-best-practices/#_removing_documentation)

E.g.
```
packages:
  repositories:
    - name: base
      id: rhel-7-server-rpms
  install:
    - java-1.8.0-openjdk
```
Would lead to
```
RUN yum install -y --setopt=tsflags=nodocs java-1.8.0-openjdk \
    && yum clean all && rm -rf /var/cache/yum && \
    rpm -q  java-1.8.0-openjdk
```

Comments:

Patch:
diff --git a/cekit/templates/template.jinja b/cekit/templates/template.jinja
index 1f8a5c9..1da28a0 100644
--- a/cekit/templates/template.jinja
+++ b/cekit/templates/template.jinja
@@ -13,12 +13,12 @@ rm{% for repo in repositories %} /etc/yum.repos.d/{{ repo.filename }}{% endfor %
 {%- endmacro %}
 {% macro repo_install(pkg_manager, rpm) -%}
     {% if pkg_manager in ['microdnf', 'yum'] %}
-{{ pkg_manager }} install -y {{ rpm }}
+{{ pkg_manager }} --setopt=tsflags=nodocs install -y {{ rpm }}
     {% endif %}
 {%- endmacro %}
 {% macro pkg_install(pkg_manager, packages) -%}
     {% if pkg_manager in ['microdnf', 'yum'] %}
-{{ pkg_manager }} install -y {%- for package in packages %} {{ package }}{% endfor %} \
+{{ pkg_manager }} --setopt=tsflags=nodocs install -y {%- for package in packages %} {{ package }}{% endfor %} \
     && rpm -q{% for package in packages %} {{ package }}{% endfor %}
     {% endif %}
 {%- endmacro %}


Test patch:
diff --git a/tests/test_dockerfile.py b/tests/test_dockerfile.py
index bb902c4..16b37a8 100644
--- a/tests/test_dockerfile.py
+++ b/tests/test_dockerfile.py
@@ -17,6 +17,7 @@ basic_config = {'release': 1,
 config = Config()
 config.cfg['common'] = {'redhat': True}
 
+
 def print_test_name(value):
     if str(value).startswith('test'):
         return value
@@ -86,7 +87,7 @@ odcs_fake_resp = b"""Result:
     ('test_cekit_label_version',
      {},
      r'.*io.cekit.version="%s".*' % cekit_version)],
-                         ids=print_test_name)
+    ids=print_test_name)
 def test_dockerfile_rendering(tmpdir, name, desc_part, exp_regex):
 
     target = str(tmpdir.mkdir('target'))
@@ -104,7 +105,7 @@ def test_dockerfile_rendering(tmpdir, name, desc_part, exp_regex):
      {}, r'JBOSS_IMAGE_NAME=\"testimage-tech-preview\"'),
     ('test_with_family',
         {'name': 'testimage/test'}, r'JBOSS_IMAGE_NAME=\"testimage-tech-preview/test\"')],
-                         ids=print_test_name)
+    ids=print_test_name)
 def test_dockerfile_rendering_tech_preview(tmpdir, name, desc_part, exp_regex):
     target = str(tmpdir.mkdir('target'))
     params = {'redhat': True, 'tech_preview': True}
@@ -121,7 +122,7 @@ def test_dockerfile_docker_odcs_pulp(tmpdir, mocker):
     target = str(tmpdir.mkdir('target'))
     desc_part = {'packages': {'content_sets': {
         'x86_64': 'foo'},
-                 'install': ['a']}}
+        'install': ['a']}}
 
     generator = prepare_generator(target, desc_part, 'image')
     generator.init()
@@ -140,7 +141,8 @@ def test_dockerfile_docker_odcs_rpm(tmpdir, mocker):
     generator = prepare_generator(target, desc_part, 'image')
     generator.init()
     generator.generate()
-    regex_dockerfile(target, 'RUN yum install -y foo-repo.rpm')
+    regex_dockerfile(target, 'RUN yum --setopt=tsflags=nodocs install -y foo-repo.rpm')
+
 
 def test_dockerfile_docker_odcs_rpm_microdnf(tmpdir, mocker):
     mocker.patch.object(subprocess, 'check_output', return_value=odcs_fake_resp)
@@ -154,10 +156,11 @@ def test_dockerfile_docker_odcs_rpm_microdnf(tmpdir, mocker):
     generator = prepare_generator(target, desc_part, 'image', 'docker', [], params)
     generator.init()
     generator.generate()
-    regex_dockerfile(target, 'RUN microdnf install -y foo-repo.rpm')
-    regex_dockerfile(target, 'RUN microdnf install -y a b')
+    regex_dockerfile(target, 'RUN microdnf --setopt=tsflags=nodocs install -y foo-repo.rpm')
+    regex_dockerfile(target, 'RUN microdnf --setopt=tsflags=nodocs install -y a b')
     regex_dockerfile(target, 'rpm -q a b')
 
+
 def test_dockerfile_osbs_odcs_pulp(tmpdir, mocker):
     mocker.patch.object(subprocess, 'check_output', return_value=odcs_fake_resp)
     mocker.patch.object(Repository, 'fetch')
@@ -166,8 +169,8 @@ def test_dockerfile_osbs_odcs_pulp(tmpdir, mocker):
     target = str(tmpdir.mkdir('target'))
     os.makedirs(os.path.join(target, 'image'))
     desc_part = {'packages': {'content_sets': {
-                                 'x86_64': 'foo'},
-                              'install': ['a']}}
+        'x86_64': 'foo'},
+        'install': ['a']}}
 
     generator = prepare_generator(target, desc_part, 'image', 'osbs')
     generator.init()
@@ -187,7 +190,7 @@ def test_dockerfile_osbs_odcs_pulp_no_redhat(tmpdir, mocker):
     target = str(tmpdir.mkdir('target'))
     desc_part = {'packages': {'repositories': [{'name': 'foo',
                                                 'odcs': {
-                                                   'pulp': 'rhel-7-server-rpms'
+                                                    'pulp': 'rhel-7-server-rpms'
                                                 }},
                                                ],
                               'install': ['a']}}
@@ -220,7 +223,7 @@ def test_dockerfile_osbs_url_only(tmpdir, mocker):
     target = str(tmpdir.mkdir('target'))
     desc_part = {'packages': {'repositories': [{'name': 'foo',
                                                 'url': {
-                                                   'repository': 'foo'
+                                                    'repository': 'foo'
                                                 }},
                                                ],
                               'install': ['a']}}
@@ -243,7 +246,7 @@ def test_dockerfile_osbs_odcs_rpm(tmpdir, mocker):
     generator = prepare_generator(target, desc_part, 'image', 'osbs')
     generator.init()
     generator.generate()
-    regex_dockerfile(target, 'RUN yum install -y foo-repo.rpm')
+    regex_dockerfile(target, 'RUN yum --setopt=tsflags=nodocs install -y foo-repo.rpm')
 
 
 def test_dockerfile_osbs_odcs_rpm_microdnf(tmpdir, mocker):
@@ -258,8 +261,8 @@ def test_dockerfile_osbs_odcs_rpm_microdnf(tmpdir, mocker):
     generator = prepare_generator(target, desc_part, 'image', 'osbs', [], params)
     generator.init()
     generator.generate()
-    regex_dockerfile(target, 'RUN microdnf install -y foo-repo.rpm')
-    regex_dockerfile(target, 'RUN microdnf install -y a')
+    regex_dockerfile(target, 'RUN microdnf --setopt=tsflags=nodocs install -y foo-repo.rpm')
+    regex_dockerfile(target, 'RUN microdnf --setopt=tsflags=nodocs install -y a')
     regex_dockerfile(target, 'rpm -q a')