Last active
January 20, 2020 08:37
-
-
Save metlos/85fa520d01a84c116f2acdc0e614806b to your computer and use it in GitHub Desktop.
Rebuild local che server and push the image into internal registry of CRC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This should run a level above the Eclipse Che server checkout which is assumed in a subdir called "che". | |
# CRC is assumed to be running. | |
# Che is assumed to be installed by chectl using operator. | |
# It uses podman for the images and assumes docker is aliased to podman. | |
CUR_DIR=`pwd` | |
CUR_USER=`oc whoami` | |
if [[ "$CUR_USER" == "kube:admin" ]]; then | |
CUR_USER=kubeadmin | |
fi | |
NS=${1:-che} | |
TAG=${2:-custom} | |
REGISTRY=`oc registry info` | |
INTERNAL_REGISTRY=`oc registry info --internal=true` | |
IMAGE_NAME=$NS/che-server | |
IMAGE=$IMAGE_NAME:$TAG | |
TOKEN=`oc whoami -t` | |
oc get project $NS > /dev/null || { | |
echo Project $NS doesn\'t exist. Did you install Che using chectl? | |
echo Run chectl as follows: | |
echo | |
echo chectl server:start -a operator -p crc -n $NS | |
exit 1 | |
} | |
# build the che server assembly | |
cd che/assembly | |
mvn clean install -Dskiptests | |
# rebuild the docker image | |
cd ../dockerfiles/che | |
./build.sh --dockerfile:Dockerfile | |
# push the docker image to the openshift registry | |
podman login -u $CUR_USER -p $TOKEN $REGISTRY --tls-verify=false | |
podman tag localhost/eclipse/che-server:nightly $IMAGE | |
podman push $IMAGE docker://$REGISTRY/$IMAGE --tls-verify=false | |
# deploy the self-signed-cert to make TLS work if needed without much effort | |
oc get secret router-ca -n openshift-ingress-operator -o jsonpath="{.data.tls\.crt}" | base64 -d > ca.crt | |
oc create secret generic self-signed-certificate --from-file=ca.crt -n=$NS | |
rm ca.crt | |
# update the Che CR | |
oc patch checluster/eclipse-che --patch "{\"spec\":{\"server\":{\"cheImage\": \"$INTERNAL_REGISTRY/$IMAGE_NAME\", \"cheImageTag\":\"$TAG\" }}}" --type=merge -n $NS | |
# force the operator to redeploy the server | |
oc delete deployment/che -n $NS | |
cd $CUR_DIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment