1
0
mirror of https://github.com/cmur2/dyndnsd.git synced 2024-12-22 00:54:22 +01:00

ci: use rake to build Docker image

This commit is contained in:
cn 2021-12-11 22:02:10 +01:00 committed by Christian Nicolai
parent 507e6a36fd
commit e622ab292a
3 changed files with 25 additions and 16 deletions

View File

@ -31,13 +31,3 @@ jobs:
- name: Lint and Test - name: Lint and Test
run: | run: |
bundle exec rake ci bundle exec rake ci
# https://github.com/marketplace/actions/build-and-push-docker-images
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Test building Docker image for dyndnsd
uses: docker/build-push-action@v2
with:
context: .
file: docker/ci/Dockerfile

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
pkg/* pkg/*
.yardoc .yardoc
hadolint hadolint
trivy

View File

@ -24,14 +24,32 @@ end
# renovate: datasource=github-tags depName=hadolint/hadolint # renovate: datasource=github-tags depName=hadolint/hadolint
hadolint_version = 'v2.8.0' hadolint_version = 'v2.8.0'
desc 'Run hadolint for Dockerfile linting' # renovate: datasource=github-tags depName=aquasecurity/trivy
task :hadolint do trivy_version = 'v0.21.2'
sh "wget -q -O ./hadolint https://github.com/hadolint/hadolint/releases/download/#{hadolint_version}/hadolint-Linux-x86_64"
sh 'chmod a+x ./hadolint' namespace :docker do
sh './hadolint --ignore DL3018 docker/Dockerfile' desc 'Lint Dockerfile'
task :lint do
sh "if [ ! -e ./hadolint ]; then wget -q -O ./hadolint https://github.com/hadolint/hadolint/releases/download/#{hadolint_version}/hadolint-Linux-x86_64; fi"
sh 'chmod a+x ./hadolint'
sh './hadolint --ignore DL3018 docker/Dockerfile'
sh './hadolint --ignore DL3018 --ignore DL3028 docker/ci/Dockerfile'
end
desc 'Build CI Docker image'
task :build do
sh 'docker build -t cmur2/dyndnsd:ci -f docker/ci/Dockerfile .'
end
desc 'Scan CI Docker image for vulnerabilities'
task :scan do
ver = trivy_version.gsub('v', '')
sh "if [ ! -e ./trivy ]; then wget -q -O - https://github.com/aquasecurity/trivy/releases/download/v#{ver}/trivy_#{ver}_Linux-64bit.tar.gz | tar -xzf - trivy; fi"
sh './trivy cmur2/dyndnsd:ci'
end
end end
task default: [:rubocop, :spec, 'bundle:audit', :solargraph] task default: [:rubocop, :spec, 'bundle:audit', :solargraph]
desc 'Run all tasks desired for CI' desc 'Run all tasks desired for CI'
task ci: ['solargraph:init', :default, :hadolint, :build] task ci: ['solargraph:init', :default, 'docker:lint', :build, 'docker:build']