From 047bb0917fe04e9e2d5b1064defec67c9f52e333 Mon Sep 17 00:00:00 2001 From: vviveksharma Date: Sat, 23 May 2026 20:20:50 +0530 Subject: [PATCH] updated the fixes Signed-off-by: vviveksharma --- .dockerignore | 13 ++++++++++++ .github/workflows/layerlint.yml | 35 +++++++++++++++++++++++++++++++++ Dockerfile | 7 ++++++- internal/report/formatter.go | 2 +- internal/scan/results.go | 2 +- 5 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/layerlint.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6fba469 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +.git +.github +.gitignore +*.md +testFiles +frontend +guides +docs +layerlint +*.tar.gz +*.zip +.DS_Store +node_modules diff --git a/.github/workflows/layerlint.yml b/.github/workflows/layerlint.yml new file mode 100644 index 0000000..5b845b8 --- /dev/null +++ b/.github/workflows/layerlint.yml @@ -0,0 +1,35 @@ +name: LayerLint Scan + +on: + pull_request: + paths: + - 'Dockerfile' + - '**.go' + - '.github/workflows/layerlint.yml' + push: + branches: + - main + paths: + - 'Dockerfile' + - '**.go' + - '.github/workflows/layerlint.yml' + +jobs: + lint-dockerfiles: + runs-on: ubuntu-latest + name: Scan Dockerfiles with LayerLint + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.26.3' + + - name: Build LayerLint + run: go build -o layerlint ./cmd/layerlint + + - name: Scan Dockerfile + run: ./layerlint scan --dockerfile ./Dockerfile --fail-on-severity medium diff --git a/Dockerfile b/Dockerfile index 88041dd..6dd64ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,11 @@ WORKDIR /app COPY go.mod ./ COPY . . -RUN go build -o layerlint ./cmd/layerlint +RUN --mount=type=cache,target=/go/pkg/mod \ + --mount=type=cache,target=/root/.cache/go-build \ + go build -o layerlint ./cmd/layerlint + +RUN addgroup -S appgroup && adduser -S appuser -G appgroup +USER appuser ENTRYPOINT ["/app/layerlint"] diff --git a/internal/report/formatter.go b/internal/report/formatter.go index b14fa5e..b6a103f 100644 --- a/internal/report/formatter.go +++ b/internal/report/formatter.go @@ -49,7 +49,7 @@ func ParseFormat(s string) (Format, error) { func PrintText(findings []models.Finding) { if len(findings) == 0 { - fmt.Println("LayerLint found no cache issues") + fmt.Println("LayerLint found no issues") return } diff --git a/internal/scan/results.go b/internal/scan/results.go index ad51b36..0105f61 100644 --- a/internal/scan/results.go +++ b/internal/scan/results.go @@ -9,7 +9,7 @@ import ( func PrintText(findings []models.Finding) { if len(findings) == 0 { - fmt.Println("LayerLint found no cache issues") + fmt.Println("LayerLint found no issues") return }