Skip to content

Commit

Permalink
feat(image): add linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Morelly committed Feb 2, 2024
1 parent 32cd106 commit 0a091db
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
steps:
- uses: actions/checkout@v4

- run: go generate -tags tools tools/tools.go

- uses: actions/setup-go@v5
with:
go-version: '1.20'
cache: false

- run: go generate -tags tools tools/tools.go

- name: go get
run: go get ./...
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: image_scan
on:
push:
branches:
- main
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.20'
cache: false

- run: go generate -tags tools tools/tools.go

- name: go get
run: go get ./...

- name: go build
run: go build -o vault-kubernetes-kms cmd/main.go

- uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile

- name: Build an image from Dockerfile
run: |
docker build -t docker.io/falcosuessgott/vault-kubernetes-kms:${{ github.sha }} .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'docker.io/falcosuessgott/vault-kubernetes-kms:${{ github.sha }}'
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
output: trivy-results.sarif

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: trivy-results.sarif
9 changes: 4 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
repos:
- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-rc.1
rev: master
hooks:
- id: go-build-mod
- id: go-test-mod
- id: go-vet-mod
- id: go-staticcheck-mod
- id: go-build-repo
- id: go-test-repo
- id: go-staticcheck-repo
- id: go-fmt
- id: go-fumpt
- id: go-imports
Expand Down
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
FROM alpine:3.19
FROM golang:1.20 as builder
WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o vault-kubernetes-kms cmd/main.go

COPY vault-kubernetes-kms /usr/bin/vault-kubernetes-kms
FROM gcr.io/distroless/static-debian12

Check failure on line 6 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build

DL3006 warning: Always tag the version of an image explicitly
WORKDIR /
COPY --from=builder /app/vault-kubernetes-kms .

ENTRYPOINT ["/usr/bin/vault-kubernetes-kms"]
ENTRYPOINT ["/vault-kubernetes-kms"]

0 comments on commit 0a091db

Please sign in to comment.