generated from ministryofjustice/analytical-platform-image-build-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
24 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,29 @@ | ||
IMAGE_NAME = ghcr.io/ministryofjustice/analytical-platform-rshiny-open-source-base:latest | ||
ARCH = $(shell uname -m) | ||
|
||
test: build | ||
container-structure-test test --config test/container-structure-test.yml --image $(IMAGE_NAME) | ||
define DOCKER_BUILD | ||
@echo "Building on $(ARCH) architecture"; | ||
@if [ "$(ARCH)" = "aarch64" ] || [ "$(ARCH)" = "arm64" ]; then \ | ||
docker build --platform linux/amd64 --file Dockerfile --tag $(IMAGE_NAME) .; \ | ||
else \ | ||
docker build --file Dockerfile --tag $(IMAGE_NAME) .; \ | ||
fi | ||
endef | ||
|
||
scan: build | ||
trivy image --vuln-type os,library --severity CRITICAL --exit-code 1 $(IMAGE_NAME) | ||
define CONTAINER_TEST | ||
@echo "Testing on $(ARCH) architecture"; | ||
@if [ "$(ARCH)" = "aarch64" ] || [ "$(ARCH)" = "arm64" ]; then \ | ||
container-structure-test test --platform linux/amd64 --config test/container-structure-test.yml --image $(IMAGE_NAME); \ | ||
else \ | ||
container-structure-test test --config test/container-structure-test.yml --image $(IMAGE_NAME); \ | ||
fi | ||
endef | ||
|
||
build: | ||
@ARCH=`uname -m`; \ | ||
case $$ARCH in \ | ||
aarch64 | arm64) \ | ||
echo "Building on $$ARCH architecture"; \ | ||
docker build --platform linux/amd64 --file Dockerfile --tag $(IMAGE_NAME) . ;; \ | ||
*) \ | ||
echo "Building on $$ARCH architecture"; \ | ||
docker build --file Dockerfile --tag $(IMAGE_NAME) . ;; \ | ||
esac | ||
$(DOCKER_BUILD) | ||
|
||
test: build | ||
$(CONTAINER_TEST) | ||
|
||
scan: build | ||
trivy image --vuln-type os,library --severity CRITICAL --exit-code 1 $(IMAGE_NAME) |