Skip to content

Commit

Permalink
Update Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary-H9 committed Apr 16, 2024
1 parent c80c5ac commit b04d719
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions Makefile
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)

0 comments on commit b04d719

Please sign in to comment.