From b851b47ec0768c9159ac44d8b364827668eb1d14 Mon Sep 17 00:00:00 2001 From: Michele Chilanti Date: Wed, 23 Oct 2019 10:39:51 -0500 Subject: [PATCH] Install an Appsody Operator in preparation for deployment (#18) * Initial code drop * Added readme and .travis.yml * Made docker org an env var. * added a deploy phase * Adjusted deploy phase * Added Appsody operator install * Continues if operator already exists * Removed LATEST from var name --- Dockerfile | 6 +++++- setupAndRunExtract.sh | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2d7207f..c73647e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,8 +4,12 @@ RUN apt-get update && \ apt-get -y install sudo jq wget ARG CLI_VERSION +ENV KUBE_VERSION="v1.11.1" +RUN wget https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/amd64/kubectl +RUN mv ./kubectl /usr/local/bin +RUN chmod 755 /usr/local/bin/kubectl RUN wget https://github.com/appsody/appsody/releases/download/$CLI_VERSION/appsody_${CLI_VERSION}_amd64.deb RUN apt install -f ./appsody_${CLI_VERSION}_amd64.deb COPY setupAndRunExtract.sh . -RUN chmod +x setupAndRunExtract.sh +RUN chmod +x setupAndRunExtract.sh \ No newline at end of file diff --git a/setupAndRunExtract.sh b/setupAndRunExtract.sh index 8dfd0e9..e7d3fa0 100755 --- a/setupAndRunExtract.sh +++ b/setupAndRunExtract.sh @@ -1,15 +1,18 @@ #!/bin/bash set -e # inspecting the container to find the mounts -containerid=`docker ps|grep appsody-docker|awk '{print $1}'` +docker ps +containerid=`docker ps|grep k8s_step-build-push-step|awk '{print $1}'` +echo Container ID: ${containerid} dockerinspect=`docker inspect ${containerid}` # checking the mounts to extract the workspace mount notdone=true found=false idx=0 while [ "$notdone" = true ]; do + echo $idx dest=`echo ${dockerinspect}|jq --argjson index $idx '.[] | .Mounts[$index].Destination '` - echo $dest + echo Destination: $dest if [ "$dest" = "\"/workspace\"" ] ; then source=`echo ${dockerinspect}|jq --argjson index $idx '.[] | .Mounts[$index].Source '` found=true @@ -43,3 +46,18 @@ appsody extract -v # Copy the extracted contents to /workspace/extracted cp -rf /builder/home/.appsody/extract/$postfix/* /builder/home/.appsody/extract/$postfix/.[!.]* /workspace/extracted/ ls -latr /workspace/extracted +echo "Running appsody operator install..." +set +e +errormessage=$( appsody operator install 2>&1 > /dev/null) + +if [ ! "$?" == 0 ]; then + echo Error message: $errormessage + if [[ "$errormessage" == *"An operator already exists"* ]]; then + echo "Operator already exists - continue processing..." + else + echo "Failed to install the Appsody operator" + exit 1 + fi +fi + +echo "Done!"