DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Testcontainers: From Zero To Hero [Video]
  • Java CI/CD: From Local Build to Jenkins Continuous Integration
  • Jenkins in the Age of Kubernetes: Strengths, Weaknesses, and Its Future in CI/CD
  • Cloud Build Unleashed: Expert Techniques for CI/CD Optimization

Trending

  • Build a Simple REST API Using Python Flask and SQLite (With Tests)
  • Efficient API Communication With Spring WebClient
  • Introducing Graph Concepts in Java With Eclipse JNoSQL
  • How To Introduce a New API Quickly Using Quarkus and ChatGPT
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Why Lint DockerFile in Continuous Integration?

Why Lint DockerFile in Continuous Integration?

Dockerfile Linter Inspects the commands mentioned in Dockerfiles to build an optimized image. Docker Linter should be given equal weightage as code linter.

By 
Ritresh Girdhar user avatar
Ritresh Girdhar
·
Jun. 29, 20 · Opinion
Likes (4)
Comment
Save
Tweet
Share
8.6K Views

Join the DZone community and get the full member experience.

Join For Free

What Is Linter?

Lint or Linter is a tool that analyses source code to flag programming errors, bugs, stylistic errors, and suspicious constructs.

We often talk about the best practices or syntax to follow while writing source code for the application but we usually skip the code which helps us in generating deployable containers like for docker image we have Dockerfile.


Why We Need Linter?

In the era of Microservices where the concept of Continuous Integration has become a necessity so as to keep application code changes in production-quality state.

Continuous Inspection is another important aspect which ensures the quality of software/application by continuously validating all the changes and identifying the risks before moving the change to production.

Irrespective of the development practice being followed it is always important to integrate Continuous Inspection tool to build cycle.


Common Lint Tools

There are multiple continuous inspection tools available which support more than one programming languages and have multiple features like below:

Sonar Qube— Continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells, and security vulnerabilities on 20+ programming languages.

 copied from — sonarqube.org



Why We Need Linter for Docker?

There are many linters available which inspect code of different programming languages. But how we should make sure that the docker image generated for our application is in optimised form.

That’s why we need some linter which will inspect and apply all the quality checks on the Dockerfile.

Dockerfile — is a text document that contains all the commands a user could call on the command line to assemble a deployable docker image.


Available Docker Linters

There are many open source docker linters available :

  • Haskell Linter
  • Atom Linter

Here I am using Haskell Docker Linter.

Haskell Docker Linter will inspect the Dockerfile into an AST and performs rules on top of the AST. It additionally is using the famous Shellcheck to lint the Bash code inside RUN instructions.


Integrate Docker Linter — CI Pipeline

Here, I have used Declarative Pipeline for Continuous Integration (CI).

The below code is adding a stage i.e “Quality gate - Dockerfile” before building docker image. It will then inspect the application Dockerfile and archive the result as a text file.

Java
 




x
22


 
1
stages {....
2
stage ("Quality Gate") { 
3

           
4
   parallel {     
5

           
6
      stage ("Dockerfile") {
7
         agent {
8
            docker {
9
               image 'hadolint/hadolint:latest-debian'
10
            }
11
         }
12
         steps {
13
            sh 'hadolint microservice1/dockerfile | tee -a      ms1_docker_lint.txt'
14
         }
15
         post {
16
          always {
17
            archiveArtifacts 'ms1_docker_lint.txt'
18
          }
19
      }
20
  }
21
}
22
....}



Continuous Integration Pipeline

Continuous Integration Pipeline




Thanks for reading!

I hope you have enjoyed reading the article.

Continuous Integration/Deployment Docker (software) Integration Lint (software)

Published at DZone with permission of Ritresh Girdhar. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Testcontainers: From Zero To Hero [Video]
  • Java CI/CD: From Local Build to Jenkins Continuous Integration
  • Jenkins in the Age of Kubernetes: Strengths, Weaknesses, and Its Future in CI/CD
  • Cloud Build Unleashed: Expert Techniques for CI/CD Optimization

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!