stx tool: Setup the minikube env for starlingx debian building
Start the minikube env for stx tool, so that we can implement the four containers then begin to execute the subtasks. Story: 2008862 Task: 43583 Change-Id: I9941395ac2853f5edcbd306941d14f690477e9e7 Signed-off-by: Zhixiong Chi <zhixiong.chi@windriver.com>
This commit is contained in:
parent
b78277a54c
commit
98b68bd82a
25
import-stx
Executable file
25
import-stx
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -z "$MINIKUBE_HOME" ];then
|
||||||
|
MINIKUBE_HOME=$HOME
|
||||||
|
else
|
||||||
|
if [ ! -d "$MINIKUBE_HOME" ]; then
|
||||||
|
echo "The directory defined by \$MINIKUBE_HOME doesn't exist"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
FSTYPE=$(stat -f -L -c %T $MINIKUBE_HOME)
|
||||||
|
if [ x"$FSTYPE" == x"nfs" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "Warning: stx minikube doesn't allow \$MINIKUBE_HOME or \$HOME directory as nfs mount point!!!"
|
||||||
|
echo " Please set non-nfs MINIKUBE_HOME with the command 'export MINIKUBE_HOME=XXX/YYY'"
|
||||||
|
echo ""
|
||||||
|
unset MINIKUBE_HOME
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export PRJDIR=$(pwd)
|
||||||
|
export PATH=$PRJDIR/stx/bin:$PATH
|
||||||
|
export MINIKUBENAME=minikube-$USER-upstream
|
||||||
|
export KUBECONFIG=$MINIKUBE_HOME/.kube/config
|
99
stx-init-env
99
stx-init-env
@ -1,25 +1,94 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ -z "$MINIKUBE_HOME" ];then
|
# Starlingx Debian Build Enviroment Setup Script
|
||||||
MINIKUBE_HOME=$HOME
|
|
||||||
|
# Normally this is called as 'source stx-init-env <sharedvolumedir>'
|
||||||
|
# Also we can execute the command 'source stx-init-env' as default
|
||||||
|
|
||||||
|
source import-stx
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
MINIKUBE=minikube
|
||||||
|
HELM=helm
|
||||||
|
DOCKER=docker
|
||||||
|
|
||||||
|
if ! command -v $MINIKUBE &> /dev/null; then
|
||||||
|
echo "Command $MINIKUBE could not be found."
|
||||||
|
echo "Please install it as https://minikube.sigs.k8s.io/docs/start/"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
if ! command -v $HELM &> /dev/null; then
|
||||||
|
echo "Command $HELM could not be found."
|
||||||
|
echo "Please install it as https://helm.sh/"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
if ! command -v $DOCKER &> /dev/null; then
|
||||||
|
echo "Command $DOCKER could not be found. Please install it."
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
MINIKUBE_EXIST=$(docker ps | grep kicbase | grep $MINIKUBENAME)
|
||||||
|
if [ x"$MINIKUBE_EXIST" == x"" ]; then
|
||||||
|
echo "Start the new minikube $MINIKUBENAME"
|
||||||
else
|
else
|
||||||
if [ ! -d "$MINIKUBE_HOME" ]; then
|
echo "The minikube $MINIKUBENAME exists, we will try to stop it..."
|
||||||
echo "The directory defined by \$MINIKUBE_HOME doesn't exist"
|
echo "Then restart it..."
|
||||||
|
echo ""
|
||||||
|
$MINIKUBE stop -p $MINIKUBENAME >> /dev/null
|
||||||
|
ret=$(docker ps | grep kicbase | grep $MINIKUBENAME)
|
||||||
|
if [ x"$ret" != x"" ]; then
|
||||||
|
echo "minikube container $MINIKUBENAME exist!"
|
||||||
|
echo "And the command 'minikube -p $MINIKUBENAME stop' failed. The reason may be"
|
||||||
|
echo "the current MINIKUBE_HOME/HOME is not the same as the $MINIKUBENAME"
|
||||||
|
echo "Please change the MINIKUBE_HOME/HOME directory to the previous value"
|
||||||
|
echo "then re-execute this script"
|
||||||
|
unset MINIKUBE_HOME
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FSTYPE=$(stat -f -L -c %T $MINIKUBE_HOME)
|
VolumePath=$1
|
||||||
if [ x"$FSTYPE" == x"nfs" ]; then
|
|
||||||
echo ""
|
if [ x"$VolumePath"==x"" ]; then
|
||||||
echo "Warning: stx minikube doesn't allow \$MINIKUBE_HOME or \$HOME directory as nfs mount point!!!"
|
|
||||||
echo " Please set non-nfs MINIKUBE_HOME with the command 'export MINIKUBE_HOME=XXX/YYY'"
|
VolumePath="/localdisk/$USER"
|
||||||
echo ""
|
|
||||||
unset MINIKUBE_HOME
|
if [ ! -d "$VolumePath" ]; then
|
||||||
|
echo "Warning: The directory $VolumePath doesn't exist, please create it with the command:"
|
||||||
|
echo ""
|
||||||
|
echo " mkdir -p $VolumePath"
|
||||||
|
echo ""
|
||||||
|
echo "or User the command 'source stx-init-env Your/Path' to redefine the shared volume"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ ! -d "$VolumePath" ]; then
|
||||||
|
echo "Warning: The directory $VolumePath doesn't exist, please create it with the command:"
|
||||||
|
echo ""
|
||||||
|
echo " mkdir -p $VolumePath"
|
||||||
|
echo ""
|
||||||
|
echo "Then execute this script again!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
$MINIKUBE start --driver=docker -p $MINIKUBENAME --mount=true --mount-string="$VolumePath:/workspace"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export PRJDIR=$(pwd)
|
# Build the container images from the dockerfiles
|
||||||
export PATH=$PRJDIR/stx/bin:$PATH
|
DOCKERNAMES="stx-builder stx-pkgbuilder stx-lat-tool stx-aptly"
|
||||||
export MINIKUBENAME=minikube-$USER-upstream
|
|
||||||
export KUBECONFIG=$MINIKUBE_HOME/.kube/config
|
eval $(minikube -p $MINIKUBENAME docker-env)
|
||||||
|
|
||||||
|
for i in $DOCKERNAMES; do
|
||||||
|
docker build -t $i:v0.1.0 -f stx/dockerfiles/$i.Dockerfile .
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
eval $(minikube -p $MINIKUBENAME docker-env -u)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user