diff --git a/README.md b/README.md index a2bf99edbbfb6d28182f49dbaf348ee628d95aa8..54bacefdaf977b5f69bff5641bb1b0db072a31a0 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,27 @@ with environment variables which will be injected in its container. ## Setup Workspace -TODO +* create directory: + ``` + mkdir -p $GOPATH/src/code.vereign.com/gaiax/tsa/ + ``` +* move in the previously created directory: + ``` + cd $GOPATH/src/code.vereign.com/gaiax/tsa/ + ``` +* clone the repository: + ``` + git clone git@code.vereign.com:gaiax/tsa/workspace.git + ``` +* run the setup.sh script: + ``` + ./setup.sh + ``` +* set the services you would like to use in the docker-compose.yml file, defaults is **infohub** +* run docker compose: + ``` + docker-compose up + ``` ## 3rd Party Services diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000000000000000000000000000000000000..3a1cf7b17b0284478f0e7a6f77854b30052509c5 --- /dev/null +++ b/setup.sh @@ -0,0 +1,68 @@ +#! /bin/bash + +# ------------ +# IMPORTANT! +# +# This script uses an environment variable named 'email' to properly +# configure git repos upon checkout. If you don't have it set in your +# environment, the email of the git repos will be set to an empty value. +# For best experience, set the variable in your .bashrc, .zshrc, etc. +# +# export email="lyuben.penkovski@vereign.com" +# ------------ + +# pull the master branch of a given git repository. +# User will be prompted for manual action if another branch is checked out or a problem occurs. +# $1 - name of the repo to pull. +function pull() { + local repo=$1 + + pushd "${repo}" + + local branch=`git rev-parse --abbrev-ref HEAD` + if [ $branch == "master" ]; then + echo "Pulling ${repo}/master..." + git pull origin master || read -p "Could not pull ${repo}/master. Fix the issue and press ENTER to continue:" + else + echo "${repo}/${branch} is checked out" + read -p "Pull ${repo} manually now or press ENTER to skip:" + fi + + popd +} + +# getServices clones or pulls the services with separate repos +# in ${GOPATH}/src/code.vereign.com/gaiax/tsa +function getServices() { + local GAIAX_TSA_DIR="${GOPATH}/src/code.vereign.com/gaiax/tsa" + mkdir -p "${GAIAX_TSA_DIR}" && cd "$_" + + local services=( + "infohub" + ) + + for repo in ${services[@]}; do + echo + + if [ -d "${repo}" ]; then + pull $repo + continue + fi + + mkdir -p "$GAIAX_TSA_DIR/$repo" && pushd "$GAIAX_TSA_DIR/$repo" + + echo "Cloning $repo repository to $GAIAX_TSA_DIR/$repo" + git clone "ssh://git@code.vereign.com/gaiax/tsa/${repo}.git" . + if [ ! -d "./vendor" ]; then + go mod tidy && go mod vendor # download dependencies to vendor + fi + + + git config user.email $EMAIL && popd + done +} + +getServices + +echo +echo "All repos are updated successfully."