diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..6313b56c57848efce05faa7aa7e901ccfc2886ea --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..2f8805e7220a5f14295edb8056fe2dfdefcdccb2 --- /dev/null +++ b/Makefile @@ -0,0 +1,47 @@ +###################################### +# Build File for Docker Images # +###################################### + +.PHONY: magento2-unit-test + +all: \ + php-lint_5.6 \ + php-lint_7.0 \ + php-lint_7.1 \ + php-lint_7.2 \ + php-lint_latest \ + magento2-unit-test + +# PHP Images +#################### +php-lint_5.6: + docker build -t unl-its/php-lint:5.6 php-lint/5.6 + +php-lint_7.0: + docker build -t unl-its/php-lint:7.0 php-lint/7.0 + +php-lint_7.1: + docker build -t unl-its/php-lint:7.1 php-lint/7.1 + +php-lint_7.2: + docker build -t unl-its/php-lint:7.2 php-lint/7.2 + +php-lint_latest: php-lint_7.2 + docker tag unl-its/php-lint:7.2 unl-its/php-lint:latest + + +# Application Images +#################### +magento2-unit-test: + docker build -t unl-its/magento2-unit-test:latest magento2-unit-test/latest + + +# 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 diff --git a/README.md b/README.md index 9415342bda6dfc1d81f3aad5989dbe6aa0bc19ed..995a52e832bc53cdca5c6e566c1ef646defbcea2 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # docker-ci +Containers used on CI -Containers used on CI \ No newline at end of file +## Building Images +To build these images, clone this repository onto a machine with docker and make installed. Run `make` and all of the images will be built and installed as local docker images. diff --git a/magento2-unit-test/latest/Dockerfile b/magento2-unit-test/latest/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..acee521df24e6139740afd73ff8cbdebdd19aedb --- /dev/null +++ b/magento2-unit-test/latest/Dockerfile @@ -0,0 +1,39 @@ +FROM centos:7 + +# Add additional REPOs +RUN rpm -i https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \ + && rpm -i https://rhel7.iuscommunity.org/ius-release.rpm + +# Update system and install required packages +RUN yum update -y \ + && yum install -y \ + unzip \ + php71u-cli \ + php71u-json \ + php71u-pdo \ + php71u-mysqlnd \ + php71u-opcache \ + php71u-xml \ + php71u-mcrypt \ + php71u-gd \ + php71u-devel \ + php71u-intl \ + php71u-mbstring \ + php71u-bcmath \ + php71u-json \ + php71u-soap \ + && yum clean all \ + && rm -rf /var/cache/yum + +# Install composer +RUN curl -o /usr/local/bin/composer https://getcomposer.org/composer.phar \ + && chmod 755 /usr/local/bin/composer + +# PHP Config file +COPY php.ini /etc/php.d/mg2.ini + +# Custom Scrips +COPY set-mg2-credentials /usr/local/bin/set-mg2-credentials +RUN chmod 755 /usr/local/bin/set-mg2-credentials + +CMD ["bash"] diff --git a/magento2-unit-test/latest/php.ini b/magento2-unit-test/latest/php.ini new file mode 100644 index 0000000000000000000000000000000000000000..c8a7ade396fe6860154ef560364bc74abf4384c3 --- /dev/null +++ b/magento2-unit-test/latest/php.ini @@ -0,0 +1,5 @@ +memory_limit = 2G + +session.auto_start = off; + +date.timezone="America/Chicago" diff --git a/magento2-unit-test/latest/set-mg2-credentials b/magento2-unit-test/latest/set-mg2-credentials new file mode 100644 index 0000000000000000000000000000000000000000..1431c530c2c3d272bad895639c7916a0747c3bb5 --- /dev/null +++ b/magento2-unit-test/latest/set-mg2-credentials @@ -0,0 +1,18 @@ +#!/bin/bash + +if [[ "$#" -ne 2 ]]; then + echo "Please provide both the username and password" + exit 1 +fi + +mkdir -p /root/.composer +cat > /root/.composer/auth.json <<EOF +{ + "http-basic": { + "repo.magento.com": { + "username": "$1", + "password": "$2" + } + } +} +EOF diff --git a/php-lint/5.6/Dockerfile b/php-lint/5.6/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4bdddf4073a47151dfe6da94f408932aea46257d --- /dev/null +++ b/php-lint/5.6/Dockerfile @@ -0,0 +1,9 @@ +FROM php:5.6-alpine + +RUN apk add --no-cache bash + +COPY php-lint docker-entrypoint /usr/local/bin/ +RUN chmod 755 /usr/local/bin/docker-entrypoint /usr/local/bin/php-lint + +ENTRYPOINT ["docker-entrypoint"] +CMD ["--help"] diff --git a/php-lint/5.6/docker-entrypoint b/php-lint/5.6/docker-entrypoint new file mode 100644 index 0000000000000000000000000000000000000000..131b834a0cec520bad3f490a0b746409685ad973 --- /dev/null +++ b/php-lint/5.6/docker-entrypoint @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +if [ "${1#-}" != "$1" ]; then + set -- php-lint "$@" +fi + +exec "$@" diff --git a/php-lint/5.6/php-lint b/php-lint/5.6/php-lint new file mode 100644 index 0000000000000000000000000000000000000000..afb52f2337d64b0c7e1b97b4daf665909e744329 --- /dev/null +++ b/php-lint/5.6/php-lint @@ -0,0 +1,66 @@ +#!/bin/bash + +# Read CLI options +LINT_DIRS=() +LINT_EXTS=() +QUIET=false +while [[ $# -gt 0 ]]; do + case $1 in + -e|--ext) + LINT_EXTS+=("$2") + shift + shift + ;; + -d|--dir) + LINT_DIRS+=("$2") + shift + shift + ;; + -q|--quiet) + QUIET=true + shift + ;; + -h|--help) + printf 'Usage: %s <options>\n' "$0" + printf '\t%s\n' "-e,--ext: Required argument: extensions to lint" + printf '\t%s\n' "-d,--dir: Required argument: directories to lint" + printf '\t%s\n' "-q,--quiet: Optional argument: Quiet mode, only print errors" + printf '\t%s\n' "-h,--help: Prints this help message" + exit 0 + ;; + *) + echo "Unrecognized option ${1}" + shift + ;; + esac +done + +# If no dirs were provided, use CWD +if [[ -z "$LINT_DIRS" ]]; then + LINT_DIRS=($(pwd)) +fi + +# If no extenions were provided, use reasonable defaults +if [[ -z "$LINT_EXTS" ]]; then + LINT_EXTS=(".php" ".phtml") +fi + +# Run PHP Lint on all provided files and directories +for dir in "${LINT_DIRS[@]}"; do + for ext in "${LINT_EXTS[@]}"; do + echo "Scanning directory ${dir} for extension ${ext}" + + # Scan current dir and ext and lint them + for f in $(find "${dir}" -type f -name "*${ext}"); do + OUTPUT=$(php -l $f 2>&1) + rc=$? + + if [[ $rc != 0 ]]; then # Non-zero exit code, print error and exit + >&2 echo "$OUTPUT" + exit $rc + elif [[ $rc == 0 ]] && [[ $QUIET == false ]]; then # all ok + echo "$OUTPUT" + fi + done + done +done diff --git a/php-lint/7.0/Dockerfile b/php-lint/7.0/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c14b10d09f3845a4fe216a00a1b20b9e3507b56d --- /dev/null +++ b/php-lint/7.0/Dockerfile @@ -0,0 +1,9 @@ +FROM php:7.0-alpine + +RUN apk add --no-cache bash + +COPY php-lint docker-entrypoint /usr/local/bin/ +RUN chmod 755 /usr/local/bin/docker-entrypoint /usr/local/bin/php-lint + +ENTRYPOINT ["docker-entrypoint"] +CMD ["--help"] diff --git a/php-lint/7.0/docker-entrypoint b/php-lint/7.0/docker-entrypoint new file mode 100644 index 0000000000000000000000000000000000000000..131b834a0cec520bad3f490a0b746409685ad973 --- /dev/null +++ b/php-lint/7.0/docker-entrypoint @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +if [ "${1#-}" != "$1" ]; then + set -- php-lint "$@" +fi + +exec "$@" diff --git a/php-lint/7.0/php-lint b/php-lint/7.0/php-lint new file mode 100644 index 0000000000000000000000000000000000000000..afb52f2337d64b0c7e1b97b4daf665909e744329 --- /dev/null +++ b/php-lint/7.0/php-lint @@ -0,0 +1,66 @@ +#!/bin/bash + +# Read CLI options +LINT_DIRS=() +LINT_EXTS=() +QUIET=false +while [[ $# -gt 0 ]]; do + case $1 in + -e|--ext) + LINT_EXTS+=("$2") + shift + shift + ;; + -d|--dir) + LINT_DIRS+=("$2") + shift + shift + ;; + -q|--quiet) + QUIET=true + shift + ;; + -h|--help) + printf 'Usage: %s <options>\n' "$0" + printf '\t%s\n' "-e,--ext: Required argument: extensions to lint" + printf '\t%s\n' "-d,--dir: Required argument: directories to lint" + printf '\t%s\n' "-q,--quiet: Optional argument: Quiet mode, only print errors" + printf '\t%s\n' "-h,--help: Prints this help message" + exit 0 + ;; + *) + echo "Unrecognized option ${1}" + shift + ;; + esac +done + +# If no dirs were provided, use CWD +if [[ -z "$LINT_DIRS" ]]; then + LINT_DIRS=($(pwd)) +fi + +# If no extenions were provided, use reasonable defaults +if [[ -z "$LINT_EXTS" ]]; then + LINT_EXTS=(".php" ".phtml") +fi + +# Run PHP Lint on all provided files and directories +for dir in "${LINT_DIRS[@]}"; do + for ext in "${LINT_EXTS[@]}"; do + echo "Scanning directory ${dir} for extension ${ext}" + + # Scan current dir and ext and lint them + for f in $(find "${dir}" -type f -name "*${ext}"); do + OUTPUT=$(php -l $f 2>&1) + rc=$? + + if [[ $rc != 0 ]]; then # Non-zero exit code, print error and exit + >&2 echo "$OUTPUT" + exit $rc + elif [[ $rc == 0 ]] && [[ $QUIET == false ]]; then # all ok + echo "$OUTPUT" + fi + done + done +done diff --git a/php-lint/7.1/Dockerfile b/php-lint/7.1/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2942326ce01876d02357c895a71506f4fae2d120 --- /dev/null +++ b/php-lint/7.1/Dockerfile @@ -0,0 +1,9 @@ +FROM php:7.1-alpine + +RUN apk add --no-cache bash + +COPY php-lint docker-entrypoint /usr/local/bin/ +RUN chmod 755 /usr/local/bin/docker-entrypoint /usr/local/bin/php-lint + +ENTRYPOINT ["docker-entrypoint"] +CMD ["--help"] diff --git a/php-lint/7.1/docker-entrypoint b/php-lint/7.1/docker-entrypoint new file mode 100644 index 0000000000000000000000000000000000000000..131b834a0cec520bad3f490a0b746409685ad973 --- /dev/null +++ b/php-lint/7.1/docker-entrypoint @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +if [ "${1#-}" != "$1" ]; then + set -- php-lint "$@" +fi + +exec "$@" diff --git a/php-lint/7.1/php-lint b/php-lint/7.1/php-lint new file mode 100644 index 0000000000000000000000000000000000000000..afb52f2337d64b0c7e1b97b4daf665909e744329 --- /dev/null +++ b/php-lint/7.1/php-lint @@ -0,0 +1,66 @@ +#!/bin/bash + +# Read CLI options +LINT_DIRS=() +LINT_EXTS=() +QUIET=false +while [[ $# -gt 0 ]]; do + case $1 in + -e|--ext) + LINT_EXTS+=("$2") + shift + shift + ;; + -d|--dir) + LINT_DIRS+=("$2") + shift + shift + ;; + -q|--quiet) + QUIET=true + shift + ;; + -h|--help) + printf 'Usage: %s <options>\n' "$0" + printf '\t%s\n' "-e,--ext: Required argument: extensions to lint" + printf '\t%s\n' "-d,--dir: Required argument: directories to lint" + printf '\t%s\n' "-q,--quiet: Optional argument: Quiet mode, only print errors" + printf '\t%s\n' "-h,--help: Prints this help message" + exit 0 + ;; + *) + echo "Unrecognized option ${1}" + shift + ;; + esac +done + +# If no dirs were provided, use CWD +if [[ -z "$LINT_DIRS" ]]; then + LINT_DIRS=($(pwd)) +fi + +# If no extenions were provided, use reasonable defaults +if [[ -z "$LINT_EXTS" ]]; then + LINT_EXTS=(".php" ".phtml") +fi + +# Run PHP Lint on all provided files and directories +for dir in "${LINT_DIRS[@]}"; do + for ext in "${LINT_EXTS[@]}"; do + echo "Scanning directory ${dir} for extension ${ext}" + + # Scan current dir and ext and lint them + for f in $(find "${dir}" -type f -name "*${ext}"); do + OUTPUT=$(php -l $f 2>&1) + rc=$? + + if [[ $rc != 0 ]]; then # Non-zero exit code, print error and exit + >&2 echo "$OUTPUT" + exit $rc + elif [[ $rc == 0 ]] && [[ $QUIET == false ]]; then # all ok + echo "$OUTPUT" + fi + done + done +done diff --git a/php-lint/7.2/Dockerfile b/php-lint/7.2/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..90e9800b722d340742e6a45fe6fa821896c2bbe6 --- /dev/null +++ b/php-lint/7.2/Dockerfile @@ -0,0 +1,9 @@ +FROM php:7.2-alpine + +RUN apk add --no-cache bash + +COPY php-lint docker-entrypoint /usr/local/bin/ +RUN chmod 755 /usr/local/bin/docker-entrypoint /usr/local/bin/php-lint + +ENTRYPOINT ["docker-entrypoint"] +CMD ["--help"] diff --git a/php-lint/7.2/docker-entrypoint b/php-lint/7.2/docker-entrypoint new file mode 100644 index 0000000000000000000000000000000000000000..131b834a0cec520bad3f490a0b746409685ad973 --- /dev/null +++ b/php-lint/7.2/docker-entrypoint @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +if [ "${1#-}" != "$1" ]; then + set -- php-lint "$@" +fi + +exec "$@" diff --git a/php-lint/7.2/php-lint b/php-lint/7.2/php-lint new file mode 100644 index 0000000000000000000000000000000000000000..afb52f2337d64b0c7e1b97b4daf665909e744329 --- /dev/null +++ b/php-lint/7.2/php-lint @@ -0,0 +1,66 @@ +#!/bin/bash + +# Read CLI options +LINT_DIRS=() +LINT_EXTS=() +QUIET=false +while [[ $# -gt 0 ]]; do + case $1 in + -e|--ext) + LINT_EXTS+=("$2") + shift + shift + ;; + -d|--dir) + LINT_DIRS+=("$2") + shift + shift + ;; + -q|--quiet) + QUIET=true + shift + ;; + -h|--help) + printf 'Usage: %s <options>\n' "$0" + printf '\t%s\n' "-e,--ext: Required argument: extensions to lint" + printf '\t%s\n' "-d,--dir: Required argument: directories to lint" + printf '\t%s\n' "-q,--quiet: Optional argument: Quiet mode, only print errors" + printf '\t%s\n' "-h,--help: Prints this help message" + exit 0 + ;; + *) + echo "Unrecognized option ${1}" + shift + ;; + esac +done + +# If no dirs were provided, use CWD +if [[ -z "$LINT_DIRS" ]]; then + LINT_DIRS=($(pwd)) +fi + +# If no extenions were provided, use reasonable defaults +if [[ -z "$LINT_EXTS" ]]; then + LINT_EXTS=(".php" ".phtml") +fi + +# Run PHP Lint on all provided files and directories +for dir in "${LINT_DIRS[@]}"; do + for ext in "${LINT_EXTS[@]}"; do + echo "Scanning directory ${dir} for extension ${ext}" + + # Scan current dir and ext and lint them + for f in $(find "${dir}" -type f -name "*${ext}"); do + OUTPUT=$(php -l $f 2>&1) + rc=$? + + if [[ $rc != 0 ]]; then # Non-zero exit code, print error and exit + >&2 echo "$OUTPUT" + exit $rc + elif [[ $rc == 0 ]] && [[ $QUIET == false ]]; then # all ok + echo "$OUTPUT" + fi + done + done +done