Skip to content
Snippets Groups Projects
Commit 7752d46c authored by Alan Nelson's avatar Alan Nelson
Browse files

Merge branch 'gitlab-ci-examples' into 'develop'

Remove the non UNL registry

See merge request !14
parents a719af80 8297094c
Branches
No related tags found
2 merge requests!15Merge Develop into Master,!14Remove the non UNL registry
...@@ -32,7 +32,7 @@ test: ...@@ -32,7 +32,7 @@ test:
tags: tags:
- dockerd - dockerd
script: script:
- docker run --rm unl-its/static-code-analysis sonar-scanner -v - docker run --rm its-registry.unl.edu/unl-its/docker-ci/static-code-analysis sonar-scanner -v
Push to Container Registry: Push to Container Registry:
after_script: after_script:
......
...@@ -10,11 +10,6 @@ REPO_ORG = its-registry.unl.edu/unl-its/docker-ci ...@@ -10,11 +10,6 @@ REPO_ORG = its-registry.unl.edu/unl-its/docker-ci
#################### ####################
DOCKERFILES := $(shell find ./ -name "Dockerfile") 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 := $(addprefix unl-its/, $(shell find ./ -maxdepth 1 -type d -not -name ".*" -printf '%f\n'))
# Get the latest commit # Get the latest commit
#################### ####################
GIT_COMMIT = $(strip $(shell git rev-parse --short HEAD)) GIT_COMMIT = $(strip $(shell git rev-parse --short HEAD))
...@@ -23,7 +18,7 @@ GIT_COMMIT = $(strip $(shell git rev-parse --short HEAD)) ...@@ -23,7 +18,7 @@ GIT_COMMIT = $(strip $(shell git rev-parse --short HEAD))
#################### ####################
BUILD_ARGS := --build-arg VCS_REF=$(GIT_COMMIT) BUILD_ARGS := --build-arg VCS_REF=$(GIT_COMMIT)
.PHONY: all clean test $(DOCKERFILES) clean_images $(IMAGES_TO_CLEAN) static-code-analysis mobile delete_dangling_images security publish .PHONY: all clean test $(DOCKERFILES) static-code-analysis mobile delete_dangling_images security publish
all: php-lint php-unit-test magento2 mobile static-code-analysis all: php-lint php-unit-test magento2 mobile static-code-analysis
...@@ -39,83 +34,62 @@ static-code-analysis: static-code-analysis_latest static-code-analysys_php stati ...@@ -39,83 +34,62 @@ static-code-analysis: static-code-analysis_latest static-code-analysys_php stati
#################### ####################
php-lint_5.6: php-lint/5.6/Dockerfile php-lint_5.6: php-lint/5.6/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:5.6 -f php-lint/5.6/Dockerfile php-lint docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:5.6 -f php-lint/5.6/Dockerfile php-lint
docker tag ${REPO_ORG}/php-lint:5.6 unl-its/php-lint:5.6
php-lint_7.0: php-lint/7.0/Dockerfile php-lint_7.0: php-lint/7.0/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:7.0 -f php-lint/7.0/Dockerfile php-lint docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:7.0 -f php-lint/7.0/Dockerfile php-lint
docker tag ${REPO_ORG}/php-lint:7.0 unl-its/php-lint:7.0
php-lint_7.1: php-lint/7.1/Dockerfile php-lint_7.1: php-lint/7.1/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:7.1 -f php-lint/7.1/Dockerfile php-lint docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:7.1 -f php-lint/7.1/Dockerfile php-lint
docker tag ${REPO_ORG}/php-lint:7.1 unl-its/php-lint:7.1
php-lint_7.2: php-lint/7.2/Dockerfile php-lint_7.2: php-lint/7.2/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:7.2 -f php-lint/7.2/Dockerfile php-lint docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:7.2 -f php-lint/7.2/Dockerfile php-lint
docker tag ${REPO_ORG}/php-lint:7.2 unl-its/php-lint:7.2
php-lint_latest: php-lint_7.2 php-lint_latest: php-lint_7.2
docker tag unl-its/php-lint:7.2 ${REPO_ORG}/php-lint:latest docker tag ${REPO_ORG}/php-lint:7.2 ${REPO_ORG}/php-lint:latest
docker tag ${REPO_ORG}/php-lint:latest unl-its/php-lint:latest
# PHP Unit Test Images # PHP Unit Test Images
#################### ####################
php-unit-test_5.6: php-unit-test/5.6/Dockerfile php-unit-test_5.6: php-unit-test/5.6/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:5.6 -f php-unit-test/5.6/Dockerfile php-unit-test docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:5.6 -f php-unit-test/5.6/Dockerfile php-unit-test
docker tag ${REPO_ORG}/php-unit-test:5.6 unl-its/php-unit-test:5.6
php-unit-test_7.0: php-unit-test/7.0/Dockerfile php-unit-test_7.0: php-unit-test/7.0/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:7.0 -f php-unit-test/7.0/Dockerfile php-unit-test docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:7.0 -f php-unit-test/7.0/Dockerfile php-unit-test
docker tag ${REPO_ORG}/php-unit-test:7.0 unl-its/php-unit-test:7.0
php-unit-test_7.1: php-unit-test/7.1/Dockerfile php-unit-test_7.1: php-unit-test/7.1/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:7.1 -f php-unit-test/7.1/Dockerfile php-unit-test docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:7.1 -f php-unit-test/7.1/Dockerfile php-unit-test
docker tag ${REPO_ORG}/php-unit-test:7.1 unl-its/php-unit-test:7.1
php-unit-test_7.2: php-unit-test/7.2/Dockerfile php-unit-test_7.2: php-unit-test/7.2/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:7.2 -f php-unit-test/7.2/Dockerfile php-unit-test docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:7.2 -f php-unit-test/7.2/Dockerfile php-unit-test
docker tag ${REPO_ORG}/php-unit-test:7.2 unl-its/php-unit-test:7.2
php-unit-test_latest: php-unit-test_7.2 php-unit-test_latest: php-unit-test_7.2
docker tag ${REPO_ORG}/php-unit-test:7.2 ${REPO_ORG}/php-unit-test:latest docker tag ${REPO_ORG}/php-unit-test:7.2 ${REPO_ORG}/php-unit-test:latest
docker tag ${REPO_ORG}/php-unit-test:7.2 unl-its/php-unit-test:latest
# Application Images # Application Images
#################### ####################
magento2-unit-test: magento2-unit-test/latest/Dockerfile magento2-unit-test: magento2-unit-test/latest/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/magento2-unit-test:latest magento2-unit-test/latest docker build $(BUILD_ARGS) -t ${REPO_ORG}/magento2-unit-test:latest magento2-unit-test/latest
docker tag ${REPO_ORG}/magento2-unit-test:latest unl-its/magento2-unit-test:latest
magento2-xml-lint: magento2-unit-test magento2-xml-lint/latest/Dockerfile magento2-xml-lint: magento2-unit-test magento2-xml-lint/latest/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/magento2-xml-lint:latest magento2-xml-lint/latest docker build $(BUILD_ARGS) -t ${REPO_ORG}/magento2-xml-lint:latest magento2-xml-lint/latest
docker tag ${REPO_ORG}/magento2-xml-lint:latest unl-its/magento2-xml-lint:latest
# Mobile Applications # Mobile Applications
#################### ####################
android-build-server: android-build-server/Dockerfile android-build-server: android-build-server/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/android-build-server:latest android-build-server docker build $(BUILD_ARGS) -t ${REPO_ORG}/android-build-server:latest android-build-server
docker tag ${REPO_ORG}/android-build-server:latest unl-its/android-build-server:latest
# Sonarqube static-code-analysis # Sonarqube static-code-analysis
# ##################### # #####################
static-code-analysis_latest: static-code-analysis/Dockerfile static-code-analysis_latest: static-code-analysis/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/static-code-analysis:latest static-code-analysis/ docker build $(BUILD_ARGS) -t ${REPO_ORG}/static-code-analysis:latest static-code-analysis/
docker tag ${REPO_ORG}/static-code-analysis:latest unl-its/static-code-analysis:latest
static-code-analysys_php: static-code-analysis/Dockerfile static-code-analysys_php: static-code-analysis/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/static-code-analysis:php static-code-analysis/ docker build $(BUILD_ARGS) -t ${REPO_ORG}/static-code-analysis:php static-code-analysis/
docker tag ${REPO_ORG}/static-code-analysis:php unl-its/static-code-analysis:php
static-code-analysys_python: static-code-analysis/Dockerfile static-code-analysys_python: static-code-analysis/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/static-code-analysis:python static-code-analysis/ docker build $(BUILD_ARGS) -t ${REPO_ORG}/static-code-analysis:python static-code-analysis/
docker tag ${REPO_ORG}/static-code-analysis:python unl-its/static-code-analysis:python
static-code-analysys_android: android-build-server static-code-analysis/android/Dockerfile static-code-analysys_android: android-build-server static-code-analysis/android/Dockerfile
docker build $(BUILD_ARGS) -t ${REPO_ORG}/static-code-analysis:android static-code-analysis/android/ docker build $(BUILD_ARGS) -t ${REPO_ORG}/static-code-analysis:android static-code-analysis/android/
docker tag ${REPO_ORG}/static-code-analysis:android unl-its/static-code-analysis:android
# Cleanup
####################
clean: clean_images
test: $(DOCKERFILES) test: $(DOCKERFILES)
$(DOCKERFILES): $(DOCKERFILES):
...@@ -123,18 +97,13 @@ $(DOCKERFILES): ...@@ -123,18 +97,13 @@ $(DOCKERFILES):
@docker run --rm -i nimmis/label-inspector lint < $(@D)/Dockerfile @docker run --rm -i nimmis/label-inspector lint < $(@D)/Dockerfile
@docker run --rm -i nimmis/label-inspector validate < $(@D)/Dockerfile @docker run --rm -i nimmis/label-inspector validate < $(@D)/Dockerfile
clean_images: $(IMAGES_TO_CLEAN) delete_dangling_images #IMAGES_TO_SCAN = $(shell docker images --format '{{.Repository}}:{{.Tag}}' | grep unl-its )
$(IMAGES_TO_CLEAN): #security:
@echo "Uninstalling $@" # @docker login -u ${TENABLE_IO_ACCESS_KEY} -p ${TENABLE_IO_SECRET_KEY} registry.cloud.tenable.com
@docker rmi $(shell docker images --format '{{.Repository}}:{{.Tag}}' --filter reference=$@) # @for image in $(IMAGES_TO_SCAN); do \
# docker tag $$image registry.cloud.tenable.com/`echo $$image | cut -d "/" -f 2`; \
IMAGES_TO_SCAN = $(shell docker images --format '{{.Repository}}:{{.Tag}}' | grep unl-its ) # docker push registry.cloud.tenable.com/`echo $$image | cut -d "/" -f 2`; \
security: # done
@docker login -u ${TENABLE_IO_ACCESS_KEY} -p ${TENABLE_IO_SECRET_KEY} registry.cloud.tenable.com
@for image in $(IMAGES_TO_SCAN); do \
docker tag $$image registry.cloud.tenable.com/`echo $$image | cut -d "/" -f 2`; \
docker push registry.cloud.tenable.com/`echo $$image | cut -d "/" -f 2`; \
done
IMAGES_TO_PUBLISH = $(shell docker images --format '{{.Repository}}:{{.Tag}}' --filter 'dangling=false' | grep $(REPO_ORG) | grep -v ':<none>$$' ) IMAGES_TO_PUBLISH = $(shell docker images --format '{{.Repository}}:{{.Tag}}' --filter 'dangling=false' | grep $(REPO_ORG) | grep -v ':<none>$$' )
publish: publish:
...@@ -149,12 +118,10 @@ delete_dangling_images: ...@@ -149,12 +118,10 @@ delete_dangling_images:
help: help:
@echo -e "make [all] \n\t # Creates all the images" @echo -e "make [all] \n\t # Creates all the images"
@echo -e "make <TARGET> \n\t # Creates an specific image" @echo -e "make <TARGET> \n\t # Creates an specific image"
@echo -e "make clean \n\t # Cleanup"
@echo -e "make publish \n\t # Push the images to the UNL registry" @echo -e "make publish \n\t # Push the images to the UNL registry"
@echo -e "make security \n\t # Send the images to Tenable. Use env variables TENABLE_IO_ACCESS_KEY and TENABLE_IO_SECRET_KEY" # @echo -e "make security \n\t # Send the images to Tenable. Use env variables TENABLE_IO_ACCESS_KEY and TENABLE_IO_SECRET_KEY"
debug: debug:
@echo -e "DOCKERFILES: \t $(DOCKERFILES)" @echo -e "DOCKERFILES: \t $(DOCKERFILES)"
@echo -e "IMAGES_TO_CLEAN:\t $(IMAGES_TO_CLEAN)" # @echo -e "IMAGES_TO_SCAN:\t $(IMAGES_TO_SCAN)"
@echo -e "IMAGES_TO_SCAN:\t $(IMAGES_TO_SCAN)"
@echo -e "IMAGES_TO_PUBLISH:\t $(IMAGES_TO_PUBLISH)" @echo -e "IMAGES_TO_PUBLISH:\t $(IMAGES_TO_PUBLISH)"
# docker-ci [![pipeline status](https://git.unl.edu/unl-its/docker-ci/badges/develop/pipeline.svg)](https://git.unl.edu/unl-its/docker-ci/commits/develop)
# Docker-ci
Containers used on CI Containers used on CI
## Building Images ## Building Images
......
# Android example of .gitlab-ci.yml
## Standard Android app with SonarQube analysis
- One 'Analysis' stage with one job.
- The job SonarQube is executed only in the branch `develop`.
``` yml
stages:
- Analysis
variables:
GRADLE_USER_HOME: ${CI_PROJECT_DIR}/gradle_home
before_script:
- ./gradlew dependencies
- for d in /opt/android-sdk-linux/build-tools/*; do PATH="$PATH:$d"; done
SonarQube:
stage: Analysis
image: its-registry.unl.edu/unl-its/docker-ci/static-code-analysis:android
tags:
- docker
only:
- develop
cache:
paths:
- gradle_home
script:
- ./gradlew sonarqube -Dsonar.host.url=$SONAR_URL -Dsonar.projectKey=$CI_PROJECT_PATH_SLUG -Dsonar.login=$SONAR_TOKEN
```
# PHP examples of .gitlab-ci.yml
## Standard PHP app with lint and SonarQube analysis
- One 'test' stage with two jobs.
- The jobs needs a runner with docker-host capabilities.
- The job SonarQube is executed only in the branch `develop`.
``` yml
# To use this script, you must have the following variables defined
# You can define them at the project or the group level
#
# SONAR_URL: Full URL to the SonarQube server
# SONAR_TOKEN: API token for SonarQube
variables:
GITLAB_CI: 1
stages:
- test
PHP Lint:
stage: test
image: its-registry.unl.edu/unl-its/docker-ci/php-lint:7.0
tags:
- docker
script:
- php-lint -d ./
SonarQube:
stage: test
image: its-registry.unl.edu/unl-its/docker-ci/static-code-analysis:php
tags:
- docker
only:
- develop
script:
- sonar-scanner -Dsonar.host.url=$SONAR_URL -Dsonar.projectKey=$CI_PROJECT_PATH_SLUG -Dsonar.sources=. -Dsonar.login=$SONAR_TOKEN
```
FROM unl-its/magento2-unit-test:latest FROM its-registry.unl.edu/unl-its/docker-ci/magento2-unit-test:latest
ARG BUILD_DATE ARG BUILD_DATE
ARG VCS_REF ARG VCS_REF
...@@ -9,7 +9,7 @@ LABEL org.label-schema.build-date=$BUILD_DATE \ ...@@ -9,7 +9,7 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vendor="University of Nebraska - Lincoln" \ org.label-schema.vendor="University of Nebraska - Lincoln" \
org.label-schema.version=$VERSION \ org.label-schema.version=$VERSION \
org.label-schema.schema-version="1.0" \ org.label-schema.schema-version="1.1" \
maintainer="Alan Nelson <alan.nelson@nebraska.edu>" maintainer="Alan Nelson <alan.nelson@nebraska.edu>"
# Scripts # Scripts
......
FROM unl-its/android-build-server FROM its-registry.unl.edu/unl-its/docker-ci/android-build-server
ARG BUILD_DATE ARG BUILD_DATE
ARG VCS_REF ARG VCS_REF
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment