Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Commit

Permalink
Add Docker workflows (#114)
Browse files Browse the repository at this point in the history
* CI workflow to test that dockerfile will build when changes are made
* CI workflow to build and scan the resulting image when changes to main happen so that we can see any HIGH or CRITICAL CVEs
  • Loading branch information
DrizzlyOwl authored Sep 2, 2024
1 parent 6339e1c commit 7f4171b
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Docker build

on:
pull_request:
paths:
- docker/Dockerfile
types: [opened, synchronize]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build docker image
uses: docker/build-push-action@v6
with:
file: './docker/Dockerfile'
secrets: github_token=${{ secrets.GITHUB_TOKEN }}
cache-from: type=gha
cache-to: type=gha
push: false
48 changes: 48 additions & 0 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Scan Docker image

on:
push:
branches: main

jobs:
scan:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.build.outputs.imageid }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build docker image
uses: docker/build-push-action@v6
id: build
with:
file: './docker/Dockerfile'
secrets: github_token=${{ secrets.GITHUB_TOKEN }}
load: true
cache-from: type=gha
cache-to: type=gha
push: false

- name: Export docker image as tar
run: docker save -o Dockerfile.tar ${{ steps.build.outputs.imageid }}

- name: Scan Docker image for CVEs
uses: aquasecurity/[email protected]
with:
input: Dockerfile.tar
format: 'sarif'
output: 'trivy-results.sarif'
limit-severities-for-sarif: true
ignore-unfixed: true
severity: 'CRITICAL,HIGH'
github-pat: ${{ secrets.GITHUB_TOKEN }}

- name: Upload scan results to GitHub Security
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: 'trivy-results.sarif'

0 comments on commit 7f4171b

Please sign in to comment.