Skip to content

Rule-based refactoring tool for fixing Dockerfile smells detected by hadolint.

License

Notifications You must be signed in to change notification settings

grosa1/dockleaner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dockleaner

Rule-based refactoring tool for fixing Dockerfile smells detected by hadolint.

A detailed description of the tool and its evaluation can be found in the preprint of the source article.

Setup

The first step is to install hadolint. Next, clone the repository and install the requirements:

conda create -n dockleaner python=3.7
conda activate dockleaner

pip install -r requirements.txt

Dockleaner was tested on macOS and Arch Linux using Python 3.7.

Usage

Run python3 dockleaner.py --help to see the following help message:

optional arguments:
  -h, --help            show this help message and exit
  --cache, -c           If selected, clears the cache of pulled image
  --overwrite, -o       Set TRUE to overwrite the target Dockerfile after the
                        fix
  --ignore rules_to_ignore [rules_to_ignore ...], -i rules_to_ignore [rules_to_ignore ...]
                        The rules that the solver must ignore
  --rule rules_to_fix [rules_to_fix ...]
                        Specify one or more specific rules to fix

required arguments:
  --path filepath, -p filepath
                        The path of the Dockerfile
  --last-edit dockerfile_date, -d dockerfile_date
                        Last edit date of the given Dockerfile. Format "YYYY-
                        MM-DD".

Thus, the command:

python3 -u dockleaner.py -p Dockerfile -d "2023-04-12" --rule "DL3008" --overwrite

will fix the Dockerfile Dockerfile by pinning versions for apt packages and overwriting the file.

Supported Smells

Legend:

  • ✅ Supported
  • 🆗 Supported, but not validated via pull requests
  • 📌 To be implemented
  • 📆 For future implementation

License

The project is licensed under the MIT License. See LICENSE for details.

Acknowledgements

The first prototype of Dockleaner was developed by Alessandro Giagnorio. Withouth his work, this project would not have been possible. The prototype has been extended and improved by Simone Scalabrino and Giovanni Rosa which is currently the maintainer of the project.

How to Cite

The proposal of the study, which includes the tool and its evaulation, was first presented at ICSME'22 - Registered Reports Track.

@article{rosa2022fixing,
  title={Fixing dockerfile smells: An empirical study},
  author={Rosa, Giovanni and Scalabrino, Simone and Oliveto, Rocco},
  journal={arXiv preprint arXiv:2208.09097},
  year={2022}
}

Next, the complete study has been accepted at Empirical Software Engineering (EMSE).

@article{rosa2024fixingsmells,
  author    = {Giovanni Rosa and
              Federico Zappone and
              Simone Scalabrino and
              Rocco Oliveto},
  title     = {Fixing Dockerfile Smells: An Empirical Study},
  journal   = {Empirical Software Engineering},
  year      = {2024},
  note      = {To appear}
}

About

Rule-based refactoring tool for fixing Dockerfile smells detected by hadolint.

Resources

License

Stars

Watchers

Forks

Packages

No packages published