diff --git a/api/.dockerignore b/api/.dockerignore new file mode 100644 index 000000000..b6aaccd33 --- /dev/null +++ b/api/.dockerignore @@ -0,0 +1,6 @@ +# ignore .git and .cache folders +.git +.cache +**/build.sh +**/build_*.sh +**/*deploy.sh diff --git a/api/Dockerfile b/api/Dockerfile index 0673ab2b5..f3b5e85f5 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -11,8 +11,8 @@ RUN apt update && apt install -y curl && \ curl -fsSL https://deb.nodesource.com/setup_12.x | bash - && \ apt install -y nodejs && \ apt remove --purge -y curl && \ - rm -rf /var/lib/apt/lists/* && \ - cd sourcemap-reader && \ + rm -rf /var/lib/apt/lists/* +RUN cd sourcemap-reader && \ npm install # Add Tini @@ -23,4 +23,4 @@ ENV ENTERPRISE_BUILD ${envarg} ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini RUN chmod +x /tini ENTRYPOINT ["/tini", "--"] -CMD ./entrypoint.sh \ No newline at end of file +CMD ./entrypoint.sh diff --git a/api/build.sh b/api/build.sh index cec7525f5..8c735ff3c 100644 --- a/api/build.sh +++ b/api/build.sh @@ -12,9 +12,9 @@ envarg="default-foss" check_prereq() { which docker || { echo "Docker not installed, please install docker." - exit=1 + exit 1 } - [[ exit -eq 1 ]] && exit 1 + return } function build_api(){ @@ -32,9 +32,11 @@ function build_api(){ docker push ${DOCKER_REPO:-'local'}/chalice:${git_sha1} docker tag ${DOCKER_REPO:-'local'}/chalice:${git_sha1} ${DOCKER_REPO:-'local'}/chalice:${tag}latest docker push ${DOCKER_REPO:-'local'}/chalice:${tag}latest -} + } + echo "api docker build completed" } check_prereq build_api $1 -IMAGE_TAG=$IMAGE_TAG PUSH_IMAGE=$PUSH_IMAGE DOCKER_REPO=$DOCKER_REPO bash build_alerts.sh $1 \ No newline at end of file +echo buil_complete +IMAGE_TAG=$IMAGE_TAG PUSH_IMAGE=$PUSH_IMAGE DOCKER_REPO=$DOCKER_REPO bash build_alerts.sh $1 diff --git a/api/build_alerts.sh b/api/build_alerts.sh index 1b0b96f7e..2a7d88a1e 100644 --- a/api/build_alerts.sh +++ b/api/build_alerts.sh @@ -64,7 +64,8 @@ function build_api(){ docker tag ${DOCKER_REPO:-'local'}/alerts:${git_sha1} ${DOCKER_REPO:-'local'}/alerts:${tag}latest docker push ${DOCKER_REPO:-'local'}/alerts:${tag}latest } +echo "completed alerts build" } check_prereq -build_api $1 \ No newline at end of file +build_api $1 diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 000000000..b6aaccd33 --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,6 @@ +# ignore .git and .cache folders +.git +.cache +**/build.sh +**/build_*.sh +**/*deploy.sh diff --git a/backend/build.sh b/backend/build.sh index c760c1b9b..c3c40dd33 100644 --- a/backend/build.sh +++ b/backend/build.sh @@ -13,9 +13,9 @@ ee="false" check_prereq() { which docker || { echo "Docker not installed, please install docker." - exit=1 + exit 1 } - [[ exit -eq 1 ]] && exit 1 + return } function build_api(){ @@ -30,6 +30,7 @@ function build_api(){ [[ $PUSH_IMAGE -eq 1 ]] && { docker push ${DOCKER_REPO:-'local'}/$image:${git_sha1} } + echo "build completed for http" return } for image in $(ls services); @@ -40,6 +41,7 @@ function build_api(){ } echo "::set-output name=image::${DOCKER_REPO:-'local'}/$image:${git_sha1}" done + echo "backend build completed" } check_prereq diff --git a/frontend/build.sh b/frontend/build.sh index 7b656bc8f..652be2acf 100644 --- a/frontend/build.sh +++ b/frontend/build.sh @@ -20,6 +20,7 @@ check_prereq() { function build(){ # Run docker as the same user, else we'll run in to permission issues. docker run --rm -v /etc/passwd:/etc/passwd -u `id -u`:`id -g` -v $(pwd):/home/${USER} -w /home/${USER} --name node_build node:14-stretch-slim /bin/bash -c "npm install && npm run build:oss" + echo "frotend build completed" } check_prereq diff --git a/frontend/dev-init.sh b/frontend/dev-init.sh new file mode 100644 index 000000000..e32647ff0 --- /dev/null +++ b/frontend/dev-init.sh @@ -0,0 +1,2 @@ +#!/bin/bash +npm install --legacy-peer-deps diff --git a/peers/.dockerignore b/peers/.dockerignore new file mode 100644 index 000000000..b6aaccd33 --- /dev/null +++ b/peers/.dockerignore @@ -0,0 +1,6 @@ +# ignore .git and .cache folders +.git +.cache +**/build.sh +**/build_*.sh +**/*deploy.sh diff --git a/peers/build.sh b/peers/build.sh index c15921ea8..381189927 100644 --- a/peers/build.sh +++ b/peers/build.sh @@ -10,9 +10,8 @@ git_sha1=${IMAGE_TAG:-$(git rev-parse HEAD)} check_prereq() { which docker || { echo "Docker not installed, please install docker." - exit=1 + exit 1 } - [[ exit -eq 1 ]] && exit 1 } function build_api(){ @@ -27,6 +26,7 @@ function build_api(){ docker tag ${DOCKER_REPO:-'local'}/peers:${git_sha1} ${DOCKER_REPO:-'local'}/peers:latest docker push ${DOCKER_REPO:-'local'}/peers:latest } + echo "peer docker build complted" } check_prereq diff --git a/scripts/helmcharts/build_deploy.sh b/scripts/helmcharts/build_deploy.sh new file mode 100644 index 000000000..7a75fad8b --- /dev/null +++ b/scripts/helmcharts/build_deploy.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +# This script will build and push docker image to registry + +# Usage: IMAGE_TAG=latest DOCKER_REPO=rg.fr-par.scw.cloud/foss bash build_deploy.sh + +echo $DOCKER_REPO +[[ -z DOCKER_REPO ]] && { + echo Set DOCKER_REPO="your docker registry" + exit 1 +} || { + docker login $DOCKER_REPO + cd ../../api + PUSH_IMAGE=1 bash build.sh $@ + cd ../backend + PUSH_IMAGE=1 bash build.sh $@ + cd ../utilities + PUSH_IMAGE=1 bash build.sh $@ + cd ../peers + PUSH_IMAGE=1 bash build.sh $@ +} diff --git a/scripts/helmcharts/local_deploy.sh b/scripts/helmcharts/local_deploy.sh new file mode 100644 index 000000000..c8c82ceb4 --- /dev/null +++ b/scripts/helmcharts/local_deploy.sh @@ -0,0 +1,105 @@ +#!/bin/bash +set -e + +# This script will build and push docker image to registry + +# Usage: IMAGE_TAG=latest DOCKER_REPO=rg.fr-par.scw.cloud/foss bash build_deploy.sh + +export DOCKER_REPO="rg.fr-par.scw.cloud/foss" +export IMAGE_TAG=`grep fromVersion vars.yaml | awk '{print $NF}'|xargs` + + +apps=( + api + assets + db + ender + http + integrations + sink + storage + assist + peers + all +) +help(){ + cat <> /etc/hosts && sudo sed -i "s/.*openreplay.local/${IP_ADDR} openreplay.local/g" /etc/hosts; grep openreplay.local /etc/hosts + + apt-get update + apt-get install -y git curl + curl -fsSL https://get.docker.com | sh - + usermod -aG docker vagrant + + git clone https://github.com/openreplay/openreplay infra + cd infra/scripts/helmcharts + + # changing container runtime for k3s to docker + sudo -u vagrant git checkout -- init.sh + sed -i 's/INSTALL_K3S_EXEC=\\(.*\\)\\\"/INSTALL_K3S_EXEC=\\1 --docker\\\"/g' init.sh + + DOMAIN_NAME=openreplay.local bash init.sh + cp -rf /root/.kube /home/vagrant/ + cp -rf /home/vagrant/infra/scripts/helmcharts/vars.yaml /home/vagrant/openreplay-dev/openreplay/scripts/helmcharts/vars.yaml + chown -R vagrant:vagrant /home/vagrant + + cat <> /etc/hosts && sudo sed -i "s/.*openreplay.local/${IP_ADDR} openreplay.local/g" /etc/hosts; grep openreplay.local /etc/hosts' + + ## Linux (Paste the following command in terminal) + + sudo -- sh -c 'grep -q openreplay.local /etc/hosts || echo $IP_ADDR openreplay.local >> /etc/hosts && sudo sed -i "s/.*openreplay.local/${IP_ADDR} openreplay.local/g" /etc/hosts; grep openreplay.local /etc/hosts' + + ## Windows + + Use the following instructions if you’re running Windows 10 or Windows 8: + + Press the Windows key. + Type Notepad in the search field. + In the search results, right-click Notepad and select Run as administrator. + From Notepad, open the following file: + c:\\Windows\\System32\\Drivers\\etc\\hosts + add the below line in the hosts file + $IP_ADDR openreplay.local + Select File > Save to save your changes. + + To Access Openreplay: + - Open your browser and go to "http://openreplay.local" + + EOF + SHELL +end diff --git a/utilities/.dockerignore b/utilities/.dockerignore new file mode 100644 index 000000000..b6aaccd33 --- /dev/null +++ b/utilities/.dockerignore @@ -0,0 +1,6 @@ +# ignore .git and .cache folders +.git +.cache +**/build.sh +**/build_*.sh +**/*deploy.sh diff --git a/utilities/build.sh b/utilities/build.sh index f7d003ed3..4a290768d 100644 --- a/utilities/build.sh +++ b/utilities/build.sh @@ -10,9 +10,8 @@ git_sha1=${IMAGE_TAG:-$(git rev-parse HEAD)} check_prereq() { which docker || { echo "Docker not installed, please install docker." - exit=1 + exit 1 } - [[ exit -eq 1 ]] && exit 1 } function build_api(){ @@ -26,6 +25,7 @@ function build_api(){ docker tag ${DOCKER_REPO:-'local'}/assist:${git_sha1} ${DOCKER_REPO:-'local'}/assist:latest docker push ${DOCKER_REPO:-'local'}/assist:latest } + echo "build completed for assist" } check_prereq