Skip to content
Snippets Groups Projects
Commit e3a0cfb5 authored by Jose Raul Barreras's avatar Jose Raul Barreras
Browse files

feat: add clean_images make's target

parent 155c22f2
No related branches found
No related tags found
4 merge requests!5Develop,!4Working copy,!3Static code analysis on xls branch,!1WIP: Static code analysis on xls branch
......@@ -8,27 +8,18 @@ DOCKERFILES := $(shell find ./ -name "Dockerfile")
# List of images to clean
####################
IMAGES_TO_CLEAN := $(shell echo $(shell echo $(shell grep -h LABEL $(DOCKERFILES)) | sed -e 's/LABEL name=//g') | tr [:space:] ' \n' | sort -u)
#IMAGES_TO_CLEAN := $(shell echo $(shell echo $(shell grep -h LABEL $(DOCKERFILES)) | sed -e 's/LABEL name=//g') | tr [:space:] ' \n' | sort -u)
IMAGES_TO_CLEAN := $(addprefix unl-its/, $(shell find ./ -maxdepth 1 -type d -not -name ".*" -printf '%f\n'))
# Get the latest commit
####################
GIT_COMMIT = $(strip $(shell git rev-parse --short HEAD))
# Get the version number from the code
####################
CODE_VERSION = $(strip $(shell cat VERSION))
# Build date
####################
BUILD_DATE := `date -u +"%Y-%m-%dT%H:%M:%SZ"`
# Docker build arguments
####################
BUILD_ARGS := --build-arg BUILD_DATE=$(BUILD_DATE)
docker_build := "docker build $(BUILD_ARGS)"
BUILD_ARGS := --build-arg VCS_REF=$(GIT_COMMIT)
.PHONY: all clean test $(DOCKERFILES) clean_images $(IMAGES_TO_CLEAN) static-code-analysis
.PHONY: all clean test $(DOCKERFILES) clean_images $(IMAGES_TO_CLEAN) static-code-analysis delete_danglig_images
all: \
php-lint_5.6 php-lint_7.0 php-lint_7.1 php-lint_7.2 php-lint_latest \
......@@ -70,13 +61,7 @@ static-code-analysis:
# Cleanup
####################
clean:
docker image rm unl-its/php-lint:5.6; true
docker image rm unl-its/php-lint:7.0; true
docker image rm unl-its/php-lint:7.1; true
docker image rm unl-its/php-lint:7.2; true
docker image rm unl-its/php-lint:latest; true
docker image rm unl-its/magento2-unit-test:latest; true
clean: clean_images
test: $(DOCKERFILES)
$(DOCKERFILES):
......@@ -84,13 +69,19 @@ $(DOCKERFILES):
@docker run --rm -i nimmis/label-inspector lint < $(@D)/Dockerfile
@docker run --rm -i nimmis/label-inspector validate < $(@D)/Dockerfile
clean_images: $(IMAGES_TO_CLEAN)
clean_images: $(IMAGES_TO_CLEAN) delete_danglig_images
$(IMAGES_TO_CLEAN):
@echo "Uninstalling $@"
docker rmi $(shell docker images --format '{{.Repository}}:{{.Tag}}' | grep $@)
@docker rmi $(shell docker images --format '{{.Repository}}:{{.Tag}}' --filter reference=$@)
delete_danglig_images:
@echo "Removing dangling images"
@docker image prune -f
help:
@echo -e "make [all] \t # Creates all the images"
@echo -e "make <TARGET> \t # Creates an specific image"
@echo -e "make clean \t # Cleanup"
debug:
@echo -e "DOCKERFILES: \t $(DOCKERFILES)"
@echo -e "IMAGES_TO_CLEAN:\t $(IMAGES_TO_CLEAN)"
......@@ -8,7 +8,7 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.description="Docker image for static code analysis using a Sonarqube server" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vendor="University of Nebraska - Lincoln" \
org.label-schema.version=$VERSION \
org.label-schema.version="0.1.0" \
org.label-schema.schema-version="1.0" \
maintainer="J.R. Barreras <barreras@unl.edu>"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment