648b325a59
Prerequisites: Linux host with Docker installed. Usage: ./docker/env_build - script removes previous container if eny and builds an updated `refstack-client` image ./docker/env_up - script setups environment in container if is the first run and joins to shell in this container Basic usage example: 1) Checkout repository 2) Run ./docker/env_build.sh 3) Run ./docker/env_up.sh ... You will get Bash console in the prepared dockerized environment. 4) Run ./docker/env_up.sh to get back to shell in the env 5) Run ./docker/env_build.sh to rebuild image and spin a new env container. NOTE: These scripts are safe to run locally. Change-Id: I51e34a5d130d9595ead948f7ddb0db840527a797
36 lines
976 B
Bash
Executable File
36 lines
976 B
Bash
Executable File
#!/bin/bash -x
|
|
|
|
if [ "$EUID" -eq 0 ]
|
|
then echo "This script should not be runned with sudo!"
|
|
exit
|
|
fi
|
|
|
|
docker ps &> /dev/null; (( $? != 0 )) && echo 'Docker should be accessible without sudo '
|
|
|
|
CONTAINER_NAME=refstack_client
|
|
|
|
if [ ! $( docker ps -q --filter name=${CONTAINER_NAME} ) ]; then
|
|
ENV_CONTAINER=$( docker ps -a -q --filter name=${CONTAINER_NAME} )
|
|
if [ ${ENV_CONTAINER} ]; then
|
|
docker start -a -i $ENV_CONTAINER
|
|
exit 0
|
|
fi
|
|
|
|
docker run \
|
|
--dns=8.8.8.8 \
|
|
-i -t \
|
|
--name ${CONTAINER_NAME}\
|
|
-v $( git rev-parse --show-toplevel ):/home/ubuntu/refstack-client \
|
|
-e REFSTACK_CLIENT_TEMPEST_DIR=/home/ubuntu/tempest \
|
|
${CONTAINER_NAME} bash -c '~/refstack-client/setup_env -q && bash'
|
|
fi
|
|
|
|
ENV_CONTAINER=$( docker ps -q --filter name=${CONTAINER_NAME} )
|
|
[[ ! ${ENV_CONTAINER} ]] && exit 1
|
|
|
|
[[ $* ]] && {
|
|
docker exec ${ENV_CONTAINER} $*
|
|
} || {
|
|
docker exec -i -t ${ENV_CONTAINER} bash
|
|
}
|