Skip to content

joao-pedro-rdo/SentinelCI

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

🐳 Automated Detection and Remediation of Dockerfile Issues in CI/CD Pipelines

Build index.js for GitHub Action

TypeScript LangChain GitHub Actions

A GitHub Action that scans Dockerfiles in your repository and suggests best practices for container security, optimization, and maintainability.

⚠️ Status: This action is in Development. Please report any issues or suggestions.

✨ Features

  • 🔍 Comprehensive Dockerfile Analysis - Scans all Dockerfiles in your repository
  • 🛡️ Security Best Practices - Identifies potential security vulnerabilities
  • 📝 Detailed Reports - Provides actionable feedback with explanations
  • 💬 GitHub Integration - Comments directly on PRs and Issues with suggestions

🚀 Quick Start

✅ Basic Usage ✅

name: Dockerfile Scanner
on: [push, pull_request]

jobs:
  scan:
   permissions:
      contents: read
      issues: write
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: joao-pedro-rdo/SentinelCI@v0.1.0
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          API_TOKEN: ${{ secrets.API_TOKEN }}

📋 Inputs

Input Description Required Default
github-token GitHub token for API access -
API_TOKEN API token for external service access -

📤 Outputs

Output Description
issues-found Number of issues found and link

🔍 What We Check

  • ✅ Use .dockerignore

  • ✅ Set WORKDIR to simplify the copy of nested files

  • ✅ Avoid pip upgrade

  • ✅ Declare ports usage

  • ✅Join non-consecutive RUN instructions

  • 🔜 Copy dependencies before sources

  • 🔜 Copy only the necessary files from the build context

  • 🔜 Extract stage in a separate Dockerfile

  • 🔜 Use VOLUME for Configuration Files

  • 🔜 Use VOLUME for Dependencies Cache

  • 🔜 Use VOLUME for App Data

  • 🔜 Avoid silencing exit signals

  • 🔜 Prefer a binary executable for ENTRYPOINT

  • 🔜 Avoid hard-coded app-related configuration

  • 🔜 Prefer popular base images (official/community)

  • 🔜 Avoid hard-coded package versions

  • 🔜 Prefer up-to-date packages and sources

  • 🔜 Avoid hard-coded base image tag

Best Practices

  • 🔜 Proper LABEL usage
  • 🔜 HEALTHCHECK instructions
  • 🔜 Signal handling
  • 🔜 File permissions
  • 🔜 Documentation completeness

📊 Example Output

❌ TODO: Add example output here

🛠️ Development

Prerequisites

  • TypeScript
  • Node.js 20+
  • npm

Setup

# Clone the repository
git clone https://github.com/joao-pedro-rdo/scan-dockerfile.git
cd scan-dockerfile

# Install dependencies
npm install

🗂️ Project Structure

├── src/
│ ├── index.ts # Main entry point
│ ├── linterRules/ # Linter rules
│ ├── refactor/ # Refactoring logic
│ ├── reporters/ # Reporting logic
│ └── adapters/ # GitHub API interactions
│ └── contracts/ # TypeScript interfaces
│ └── utils.ts # Utility functions
├── dist/ # Compiled JavaScript
├── action.yml # Action metadata
└── README.md

Building

# Build TypeScript to JavaScript
npm run build

Note

The pipeline will automatically build the project on push.

🚧 Testing 🚧

I am using repository dispatch events to trigger tests in another repository, you can check it out (workflows/build.yml)


## 📚 Examples

### 🚧 Basic PR Comment 🚧

```yaml
name: Dockerfile Review
on:
  pull_request:
    paths:
      - "**/Dockerfile*"

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: joao-pedro-rdo/scan-dockerfile@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          create-issue: false

🔗 Related Actions

🙏 Acknowledgments

This project uses the following open-source libraries:

  • dockerfile-ast by Remy Suen - A comprehensive TypeScript library for parsing and analyzing Dockerfiles. Licensed under MIT.
  • LangChain - Framework for developing applications with language models.

📄 License

This project is licensed under the Apache 2.0 - see the LICENSE file for details.


Made by João Pedro

About

A GitHub Action built with TypeScript to statically analyze your Dockerfiles and suggest best practices.

Topics

Resources

License

Stars

Watchers

Forks