diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..aee9c814d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "common"] + path = common + url = https://github.com/sclorg/container-common-scripts.git diff --git a/Makefile b/Makefile index 8421471cf..8c79691b7 100644 --- a/Makefile +++ b/Makefile @@ -3,5 +3,8 @@ BASE_IMAGE_NAME = php VERSIONS = 5.6 7.0 OPENSHIFT_NAMESPACES = 5.5 -# Include common Makefile code. -include hack/common.mk +# HACK: Ensure that 'git pull' for old clones doesn't cause confusion. +# New clones should use '--recursive'. +.PHONY: $(shell test -f common/common.mk || echo >&2 'Please do "git submodule update --init" first.') + +include common/common.mk diff --git a/README.md b/README.md index a420ce552..74313354f 100644 --- a/README.md +++ b/README.md @@ -32,14 +32,14 @@ To build a PHP image, choose either the CentOS or RHEL based image: subscribed RHEL machine. ``` - $ git clone https://github.com/sclorg/s2i-php-container.git + $ git clone --recursive https://github.com/sclorg/s2i-php-container.git $ cd s2i-php-container $ make build TARGET=rhel7 VERSION=7.0 ``` * **CentOS based image** ``` - $ git clone https://github.com/sclorg/s2i-php-container.git + $ git clone --recursive https://github.com/sclorg/s2i-php-container.git $ cd s2i-php-container $ make build TARGET=centos7 VERSION=7.0 ``` diff --git a/common b/common new file mode 160000 index 000000000..6be437562 --- /dev/null +++ b/common @@ -0,0 +1 @@ +Subproject commit 6be437562875b731c8be34470ef35c9a1eecef16 diff --git a/hack/build.sh b/hack/build.sh deleted file mode 100755 index a816a1577..000000000 --- a/hack/build.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/bash -e -# This script is used to build, test and squash the OpenShift Docker images. -# -# Name of resulting image will be: 'NAMESPACE/BASE_IMAGE_NAME-VERSION-OS'. -# -# BASE_IMAGE_NAME - Usually name of the main component within container. -# OS - Specifies distribution - "rhel7" or "centos7" -# VERSION - Specifies the image version - (must match with subdirectory in repo) -# TEST_MODE - If set, build a candidate image and test it -# TAG_ON_SUCCESS - If set, tested image will be re-tagged as a non-candidate -# image, if the tests pass. -# VERSIONS - Must be set to a list with possible versions (subdirectories) -# OPENSHIFT_NAMESPACES - Which of available versions (subdirectories) should be -# put into openshift/ namespace. - -OS=${1-$OS} -VERSION=${2-$VERSION} - -DOCKERFILE_PATH="" - -test -z "$BASE_IMAGE_NAME" && { - BASE_DIR_NAME=$(echo $(basename `pwd`) | sed -e 's/-[0-9]*$//g') - BASE_IMAGE_NAME="${BASE_DIR_NAME#s2i-}" -} - -# Cleanup the temporary Dockerfile created by docker build with version -trap "rm -f ${DOCKERFILE_PATH}.version" SIGINT SIGQUIT EXIT - -# Perform docker build but append the LABEL with GIT commit id at the end -function docker_build_with_version { - local dockerfile="$1" - # Use perl here to make this compatible with OSX - DOCKERFILE_PATH=$(perl -MCwd -e 'print Cwd::abs_path shift' $dockerfile) - cp ${DOCKERFILE_PATH} "${DOCKERFILE_PATH}.version" - git_version=$(git rev-parse HEAD) - echo "LABEL io.openshift.builder-version=\"${git_version}\"" >> "${dockerfile}.version" - if [[ "${UPDATE_BASE}" == "1" ]]; then - BUILD_OPTIONS+=" --pull=true" - fi - docker build ${BUILD_OPTIONS} -t ${IMAGE_NAME} -f "${dockerfile}.version" . - if [[ "${SKIP_SQUASH}" != "1" ]]; then - squash "${dockerfile}.version" - fi - rm -f "${DOCKERFILE_PATH}.version" -} - -# Install the docker squashing tool[1] and squash the result image -# [1] https://github.com/goldmann/docker-squash -function squash { - # FIXME: We have to use the exact versions here to avoid Docker client - # compatibility issues - easy_install -q --user docker_py==1.7.2 docker-squash==1.0.1 - base=$(awk '/^FROM/{print $2}' $1) - ${HOME}/.local/bin/docker-squash -f $base ${IMAGE_NAME} -} - -# Versions are stored in subdirectories. You can specify VERSION variable -# to build just one single version. By default we build all versions -dirs=${VERSION:-$VERSIONS} - -for dir in ${dirs}; do - case " $OPENSHIFT_NAMESPACES " in - *\ ${dir}\ *) - NAMESPACE="openshift/" - ;; - *) - if [ "${OS}" == "centos7" ]; then - NAMESPACE="centos/" - else - # we don't test rhel versions of SCL owned images - if [[ "${SKIP_RHEL_SCL}" == "1" ]]; then - echo "Skipping rhel scl image ${BASE_IMAGE_NAME}-${dir//./}-{$OS}" - continue - fi - NAMESPACE="rhscl/" - fi - esac - - IMAGE_NAME="${NAMESPACE}${BASE_IMAGE_NAME}-${dir//./}-${OS}" - - if [[ -v TEST_MODE ]]; then - IMAGE_NAME+="-candidate" - fi - - echo "-> Building ${IMAGE_NAME} ..." - - pushd ${dir} > /dev/null - if [ "$OS" == "rhel7" -o "$OS" == "rhel7-candidate" ]; then - docker_build_with_version Dockerfile.rhel7 - else - docker_build_with_version Dockerfile - fi - - if [[ -v TEST_MODE ]]; then - IMAGE_NAME=${IMAGE_NAME} test/run - - if [[ $? -eq 0 ]] && [[ "${TAG_ON_SUCCESS}" == "true" ]]; then - echo "-> Re-tagging ${IMAGE_NAME} image to ${IMAGE_NAME%"-candidate"}" - docker tag $IMAGE_NAME ${IMAGE_NAME%"-candidate"} - fi - fi - - popd > /dev/null -done diff --git a/hack/common.mk b/hack/common.mk deleted file mode 100644 index 106558a1b..000000000 --- a/hack/common.mk +++ /dev/null @@ -1,26 +0,0 @@ -SKIP_SQUASH?=0 - -build = hack/build.sh - -ifeq ($(TARGET),rhel7) - OS := rhel7 -else - OS := centos7 -endif - -script_env = \ - SKIP_SQUASH=$(SKIP_SQUASH) \ - UPDATE_BASE=$(UPDATE_BASE) \ - VERSIONS="$(VERSIONS)" \ - OS=$(OS) \ - VERSION="$(VERSION)" \ - BASE_IMAGE_NAME=$(BASE_IMAGE_NAME) \ - OPENSHIFT_NAMESPACES="$(OPENSHIFT_NAMESPACES)" - -.PHONY: build -build: - $(script_env) $(build) - -.PHONY: test -test: - $(script_env) TAG_ON_SUCCESS=$(TAG_ON_SUCCESS) TEST_MODE=true $(build)