From f3baaba2f20fed5d733142f8c23e7ddfe5a8096f Mon Sep 17 00:00:00 2001 From: Roman Iuvshyn Date: Thu, 9 Aug 2018 13:35:28 +0300 Subject: [PATCH 1/3] add cico script and rhel dockerfile --- Dockerfile.rhel | 2 ++ cico_build.sh | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 Dockerfile.rhel create mode 100755 cico_build.sh diff --git a/Dockerfile.rhel b/Dockerfile.rhel new file mode 100644 index 000000000..f2527201c --- /dev/null +++ b/Dockerfile.rhel @@ -0,0 +1,2 @@ +FROM quay.io/openshiftio/rhel-base-httpd:latest +COPY /plugins /var/www/html/plugins \ No newline at end of file diff --git a/cico_build.sh b/cico_build.sh new file mode 100755 index 000000000..9b407f817 --- /dev/null +++ b/cico_build.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +# Output command before executing +set -x + +# Exit on error +set -e + +# Source environment variables of the jenkins slave +# that might interest this worker. +function load_jenkins_vars() { + if [ -e "jenkins-env.json" ]; then + eval "$(./env-toolkit load -f jenkins-env.json \ + DEVSHIFT_TAG_LEN \ + QUAY_USERNAME \ + QUAY_PASSWORD \ + JENKINS_URL \ + GIT_BRANCH \ + GIT_COMMIT \ + BUILD_NUMBER \ + ghprbSourceBranch \ + ghprbActualCommit \ + BUILD_URL \ + ghprbPullId)" + fi +} + +function install_deps() { + # We need to disable selinux for now, XXX + /usr/sbin/setenforce 0 || true + + # Get all the deps in + yum -y install \ + docker \ + git + + service docker start + + echo 'CICO: Dependencies installed' +} + +function tag_push() { + local TARGET=$1 + docker tag che-plugin-registry $TARGET + docker push $TARGET +} + +function deploy() { + TARGET=${TARGET:-"centos"} + REGISTRY="quay.io" + + if [ $TARGET == "rhel" ]; then + DOCKERFILE="Dockerfile.rhel" + IMAGE="rhel-che-plugin-registry" + else + DOCKERFILE="Dockerfile" + IMAGE="che-plugin-registry" + fi + + if [ -n "${QUAY_USERNAME}" -a -n "${QUAY_PASSWORD}" ]; then + docker login -u ${QUAY_USERNAME} -p ${QUAY_PASSWORD} ${REGISTRY} + else + echo "Could not login, missing credentials for the registry" + fi + + # Let's deploy + docker build -t ${IMAGE} -f ${DOCKERFILE} . + + TAG=$(echo $GIT_COMMIT | cut -c1-${DEVSHIFT_TAG_LEN}) + + tag_push ${REGISTRY}/openshiftio/$IMAGE:$TAG + tag_push ${REGISTRY}/openshiftio/$IMAGE:latest + echo 'CICO: Image pushed, ready to update deployed app' +} + +function cico_setup() { + load_jenkins_vars; + install_deps; +} +cico_setup +deploy \ No newline at end of file From b25fb8982c52f1081c255d37ea1b552737cb5b80 Mon Sep 17 00:00:00 2001 From: Roman Iuvshyn Date: Thu, 9 Aug 2018 13:40:14 +0300 Subject: [PATCH 2/3] Update Dockerfile.rhel --- Dockerfile.rhel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.rhel b/Dockerfile.rhel index f2527201c..b3e190d3f 100644 --- a/Dockerfile.rhel +++ b/Dockerfile.rhel @@ -1,2 +1,2 @@ FROM quay.io/openshiftio/rhel-base-httpd:latest -COPY /plugins /var/www/html/plugins \ No newline at end of file +COPY /plugins /var/www/html/plugins From e7a7907a48c8682456e97808bd96d49f47ad3bbd Mon Sep 17 00:00:00 2001 From: Roman Iuvshyn Date: Thu, 9 Aug 2018 13:40:34 +0300 Subject: [PATCH 3/3] Update cico_build.sh --- cico_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cico_build.sh b/cico_build.sh index 9b407f817..e8896b1b2 100755 --- a/cico_build.sh +++ b/cico_build.sh @@ -78,4 +78,4 @@ function cico_setup() { install_deps; } cico_setup -deploy \ No newline at end of file +deploy