From f2791a56f6b4d5f510ae86c7044eea33c58ea7e5 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Fri, 27 Apr 2018 18:13:08 +0200 Subject: [PATCH] Build on RHEL (#68) Related to openshiftio/openshift.io#3321 --- .make/docker.mk | 8 +++++++- Dockerfile.deploy.rhel | 22 ++++++++++++++++++++++ cico_setup.sh | 26 ++++++++++++++++---------- openshift/OpenShiftTemplate.yml | 6 ++++-- 4 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 Dockerfile.deploy.rhel diff --git a/.make/docker.mk b/.make/docker.mk index 84f52a7..889ef86 100644 --- a/.make/docker.mk +++ b/.make/docker.mk @@ -1,6 +1,12 @@ DOCKER_IMAGE_CORE := $(PROJECT_NAME) DOCKER_IMAGE_DEPLOY := $(PROJECT_NAME)-deploy +ifeq ($(TARGET),rhel) + DOCKERFILE_DEPLOY := Dockerfile.deploy.rhel +else + DOCKERFILE_DEPLOY := Dockerfile.deploy +endif + # If running in Jenkins we don't allow for interactively running the container ifneq ($(BUILD_TAG),) DOCKER_RUN_INTERACTIVE_SWITCH := @@ -30,7 +36,7 @@ docker-image-builder: .PHONY: docker-image-deploy ## Creates a runnable image using the artifacts from the bin directory. docker-image-deploy: - docker build -t $(DOCKER_IMAGE_DEPLOY) -f $(CUR_DIR)/Dockerfile.deploy $(CUR_DIR) + docker build -t $(DOCKER_IMAGE_DEPLOY) -f $(CUR_DIR)/$(DOCKERFILE_DEPLOY) $(CUR_DIR) .PHONY: docker-publish-deploy ## Tags the runnable image and pushes it to the docker hub. diff --git a/Dockerfile.deploy.rhel b/Dockerfile.deploy.rhel new file mode 100644 index 0000000..f06e228 --- /dev/null +++ b/Dockerfile.deploy.rhel @@ -0,0 +1,22 @@ +FROM prod.registry.devshift.net/osio-prod/base/pcp:latest +LABEL maintainer "Devtools " +LABEL author "Devtools " +ENV LANG=en_US.utf8 +ENV INSTALL_PREFIX=/usr/local/f8 + +# Create a non-root user and a group with the same name: "f8" +ENV USER_NAME=f8 +RUN useradd --no-create-home -s /bin/bash ${USER_NAME} + +COPY bin/fabric8-notification ${INSTALL_PREFIX}/bin/fabric8-notification + +COPY ./notification+pmcd.sh /notification+pmcd.sh +EXPOSE 44321 + +# From here onwards, any RUN, CMD, or ENTRYPOINT will be run under the following user +USER ${USER_NAME} + +WORKDIR ${INSTALL_PREFIX} +ENTRYPOINT [ "/notification+pmcd.sh" ] + +EXPOSE 8080 diff --git a/cico_setup.sh b/cico_setup.sh index 9fe3aaa..803be1c 100644 --- a/cico_setup.sh +++ b/cico_setup.sh @@ -20,7 +20,7 @@ function load_jenkins_vars() { function install_deps() { # We need to disable selinux for now, XXX - /usr/sbin/setenforce 0 + /usr/sbin/setenforce 0 || : # Get all the deps in yum -y install \ @@ -102,26 +102,32 @@ function run_tests_with_coverage() { } function tag_push() { - TARGET=$1 - docker tag fabric8-notification-deploy $TARGET - docker push $TARGET + local tag=$1 + + docker tag fabric8-notification-deploy $tag + docker push $tag } function deploy() { + if [ -n "${DEVSHIFT_USERNAME}" -a -n "${DEVSHIFT_PASSWORD}" ]; then + docker login -u ${DEVSHIFT_USERNAME} -p ${DEVSHIFT_PASSWORD} ${REGISTRY} + else + echo "Could not login, missing credentials for the registry" + fi + # Let's deploy make docker-image-deploy TAG=$(echo $GIT_COMMIT | cut -c1-${DEVSHIFT_TAG_LEN}) REGISTRY="push.registry.devshift.net" - if [ -n "${DEVSHIFT_USERNAME}" -a -n "${DEVSHIFT_PASSWORD}" ]; then - docker login -u ${DEVSHIFT_USERNAME} -p ${DEVSHIFT_PASSWORD} ${REGISTRY} + if [ "$TARGET" = "rhel" ]; then + tag_push ${REGISTRY}/osio-prod/fabric8-services/fabric8-notification:$TAG + tag_push ${REGISTRY}/osio-prod/fabric8-services/fabric8-notification:latest else - echo "Could not login, missing credentials for the registry" + tag_push ${REGISTRY}/fabric8-services/fabric8-notification:$TAG + tag_push ${REGISTRY}/fabric8-services/fabric8-notification:latest fi - - tag_push ${REGISTRY}/fabric8-services/fabric8-notification:$TAG - tag_push ${REGISTRY}/fabric8-services/fabric8-notification:latest echo 'CICO: Image pushed, ready to update deployed app' } diff --git a/openshift/OpenShiftTemplate.yml b/openshift/OpenShiftTemplate.yml index a0f344c..ed8a345 100644 --- a/openshift/OpenShiftTemplate.yml +++ b/openshift/OpenShiftTemplate.yml @@ -67,7 +67,7 @@ objects: secretKeyRef: name: f8notification key: service.account.secret - image: registry.devshift.net/fabric8-services/fabric8-notification:${IMAGE_TAG} + image: ${IMAGE}:${IMAGE_TAG} imagePullPolicy: Always name: f8notification ports: @@ -95,7 +95,7 @@ objects: timeoutSeconds: 1 resources: limits: - memory: 1Gi + memory: 1Gi triggers: - type: ConfigChange - apiVersion: v1 @@ -110,5 +110,7 @@ objects: selector: deploymentconfig: f8notification parameters: +- name: IMAGE + value: registry.devshift.net/fabric8-services/fabric8-notification - name: IMAGE_TAG value: latest