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

add static-code-analysis

parent 647d8526
Branches
No related tags found
4 merge requests!5Develop,!4Working copy,!3Static code analysis on xls branch,!1WIP: Static code analysis on xls branch
...@@ -2,29 +2,51 @@ ...@@ -2,29 +2,51 @@
# Build File for Docker Images # # Build File for Docker Images #
###################################### ######################################
.PHONY: magento2-unit-test magento2-xml-lint # All Dockerfiles
####################
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)
# 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)"
.PHONY: all clean test $(DOCKERFILES) clean_images $(IMAGES_TO_CLEAN) static-code-analysis
all: \ all: \
php-lint_5.6 \ php-lint_5.6 php-lint_7.0 php-lint_7.1 php-lint_7.2 php-lint_latest \
php-lint_7.0 \ magento2-unit-test magento2-xml-lint \
php-lint_7.1 \ static-code-analysis
php-lint_7.2 \
php-lint_latest \
magento2-unit-test \
magento2-xml-lint
# PHP Images # PHP Images
#################### ####################
php-lint_5.6: php-lint_5.6: php-lint/5.6/Dockerfile
docker build -t unl-its/php-lint:5.6 -f php-lint/5.6/Dockerfile php-lint docker build -t unl-its/php-lint:5.6 -f php-lint/5.6/Dockerfile php-lint
php-lint_7.0: php-lint_7.0: php-lint/7.0/Dockerfile
docker build -t unl-its/php-lint:7.0 -f php-lint/7.0/Dockerfile php-lint docker build -t unl-its/php-lint:7.0 -f php-lint/7.0/Dockerfile php-lint
php-lint_7.1: php-lint_7.1: php-lint/7.1/Dockerfile
docker build -t unl-its/php-lint:7.1 -f php-lint/7.1/Dockerfile php-lint docker build -t unl-its/php-lint:7.1 -f php-lint/7.1/Dockerfile php-lint
php-lint_7.2: php-lint_7.2: php-lint/7.2/Dockerfile
docker build -t unl-its/php-lint:7.2 -f php-lint/7.2/Dockerfile php-lint docker build -t unl-its/php-lint:7.2 -f php-lint/7.2/Dockerfile php-lint
php-lint_latest: php-lint_7.2 php-lint_latest: php-lint_7.2
...@@ -33,12 +55,18 @@ php-lint_latest: php-lint_7.2 ...@@ -33,12 +55,18 @@ php-lint_latest: php-lint_7.2
# Application Images # Application Images
#################### ####################
magento2-unit-test: magento2-unit-test: magento2-unit-test/latest/Dockerfile
docker build -t unl-its/magento2-unit-test:latest magento2-unit-test/latest docker build -t unl-its/magento2-unit-test:latest magento2-unit-test/latest
magento2-xml-lint: magento2-xml-lint: magento2-unit-test magento2-xml-lint/latest/Dockerfile
docker build -t unl-its/magento2-xml-lint:latest magento2-xml-lint/latest docker build -t unl-its/magento2-xml-lint:latest magento2-xml-lint/latest
# Sonarqube static-code-analysis
# #####################
static-code-analysis:
docker build $(BUILD_ARGS) -t unl-its/static-code-analysis:latest static-code-analysis/
docker build $(BUILD_ARGS) -t unl-its/static-code-analysis:php static-code-analysis/
docker build $(BUILD_ARGS) -t unl-its/static-code-analysis:python static-code-analysis/
# Cleanup # Cleanup
#################### ####################
...@@ -49,3 +77,20 @@ clean: ...@@ -49,3 +77,20 @@ clean:
docker image rm unl-its/php-lint:7.2; 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/php-lint:latest; true
docker image rm unl-its/magento2-unit-test:latest; true docker image rm unl-its/magento2-unit-test:latest; true
test: $(DOCKERFILES)
$(DOCKERFILES):
@echo "Linting and validating $(@D)..."
@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)
$(IMAGES_TO_CLEAN):
@echo "Uninstalling $@"
docker rmi $(shell docker images --format '{{.Repository}}:{{.Tag}}' | grep $@)
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"
FROM centos:7 FROM centos:7
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="Magento Unit Tester" \
org.label-schema.description="" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vendor="University of Nebraska - Lincoln" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0" \
maintainer="Alan Nelson <alan.nelson@nebraska.edu>"
# Add additional REPOs # Add additional REPOs
RUN rpm -i https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \ RUN rpm -i https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
&& rpm -i https://rhel7.iuscommunity.org/ius-release.rpm && rpm -i https://rhel7.iuscommunity.org/ius-release.rpm
......
FROM unl-its/magento2-unit-test:latest FROM unl-its/magento2-unit-test:latest
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="Magento 2 XML linter" \
org.label-schema.description="" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vendor="University of Nebraska - Lincoln" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0" \
maintainer="Alan Nelson <alan.nelson@nebraska.edu>"
# Scripts # Scripts
COPY xml-lint docker-entrypoint /usr/local/bin/ COPY xml-lint docker-entrypoint /usr/local/bin/
......
FROM php:5.6-alpine FROM php:5.6-alpine
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="PHP 5.6 linter" \
org.label-schema.description="" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vendor="University of Nebraska - Lincoln" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0" \
maintainer="Alan Nelson <alan.nelson@nebraska.edu>"
RUN apk add --no-cache bash RUN apk add --no-cache bash
COPY php-lint docker-entrypoint /usr/local/bin/ COPY php-lint docker-entrypoint /usr/local/bin/
......
FROM php:7.0-alpine FROM php:7.0-alpine
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="PHP 7.0 linter" \
org.label-schema.description="" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vendor="University of Nebraska - Lincoln" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0" \
maintainer="Alan Nelson <alan.nelson@nebraska.edu>"
RUN apk add --no-cache bash RUN apk add --no-cache bash
COPY php-lint docker-entrypoint /usr/local/bin/ COPY php-lint docker-entrypoint /usr/local/bin/
......
FROM php:7.1-alpine FROM php:7.1-alpine
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="PHP 7.1 linter" \
org.label-schema.description="" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vendor="University of Nebraska - Lincoln" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0" \
maintainer="Alan Nelson <alan.nelson@nebraska.edu>"
RUN apk add --no-cache bash RUN apk add --no-cache bash
COPY php-lint docker-entrypoint /usr/local/bin/ COPY php-lint docker-entrypoint /usr/local/bin/
......
FROM php:7.2-alpine FROM php:7.2-alpine
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="PHP 7.2 linter" \
org.label-schema.description="" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vendor="University of Nebraska - Lincoln" \
org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0" \
maintainer="Alan Nelson <alan.nelson@nebraska.edu>"
RUN apk add --no-cache bash RUN apk add --no-cache bash
COPY php-lint docker-entrypoint /usr/local/bin/ COPY php-lint docker-entrypoint /usr/local/bin/
......
FROM openjdk:8-jre-alpine
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="Sonarqube Static Code Analyzer" \
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.schema-version="1.0" \
maintainer="J.R. Barreras <barreras@unl.edu>"
ENV SONAR_SCANNER_VERSION 3.2.0.1227
WORKDIR /opt
RUN apk add --no-cache curl sed bash su-exec && \
mkdir -p /opt/src && \
curl --insecure -o ./sonarscanner.zip -L https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}.zip && \
unzip sonarscanner.zip && \
rm sonarscanner.zip
ENV SONAR_RUNNER_HOME=/opt/sonar-scanner-${SONAR_SCANNER_VERSION}
ENV PATH $PATH:/opt/sonar-scanner-${SONAR_SCANNER_VERSION}/bin
COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD /bin/bash
#!/bin/bash
# Add local user
# Either use the LOCAL_USER_ID if passed in at runtime or
# fallback
USER_ID=${LOCAL_USER_ID:-9001}
su-exec user "$@"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment