Vagrant for local contribution (#434)
* chore(vagrant): initial vagrantfile * chore(vagrant): adding instructions after installation * chore(vagrant): Adding vagrant user to docker group * chore(vagrant): use local docker daemon for k3s * chore(vagrant): fix comment * chore(vagrant): adding hostname in /etc/hosts * chore(vagrant): fix doc * chore(vagrant): limiting cpu * chore(frontend): initialize dev env * chore(docker): adding dockerignore * chore(dockerfile): using cache for fasten build * chore(dockerignore): update * chore(docker): build optimizations * chore(build): all components build option * chore(build): utilities build fix * chore(scrpt): remove debug message * chore(vagrant): provision using stable branch always Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
This commit is contained in:
parent
55b504cc22
commit
f3b6bda163
15 changed files with 302 additions and 14 deletions
6
api/.dockerignore
Normal file
6
api/.dockerignore
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# ignore .git and .cache folders
|
||||
.git
|
||||
.cache
|
||||
**/build.sh
|
||||
**/build_*.sh
|
||||
**/*deploy.sh
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
echo buil_complete
|
||||
IMAGE_TAG=$IMAGE_TAG PUSH_IMAGE=$PUSH_IMAGE DOCKER_REPO=$DOCKER_REPO bash build_alerts.sh $1
|
||||
|
|
@ -64,6 +64,7 @@ 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
|
||||
|
|
|
|||
6
backend/.dockerignore
Normal file
6
backend/.dockerignore
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# ignore .git and .cache folders
|
||||
.git
|
||||
.cache
|
||||
**/build.sh
|
||||
**/build_*.sh
|
||||
**/*deploy.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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
2
frontend/dev-init.sh
Normal file
2
frontend/dev-init.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
npm install --legacy-peer-deps
|
||||
6
peers/.dockerignore
Normal file
6
peers/.dockerignore
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# ignore .git and .cache folders
|
||||
.git
|
||||
.cache
|
||||
**/build.sh
|
||||
**/build_*.sh
|
||||
**/*deploy.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
|
||||
|
|
|
|||
22
scripts/helmcharts/build_deploy.sh
Normal file
22
scripts/helmcharts/build_deploy.sh
Normal file
|
|
@ -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 $@
|
||||
}
|
||||
105
scripts/helmcharts/local_deploy.sh
Normal file
105
scripts/helmcharts/local_deploy.sh
Normal file
|
|
@ -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 <<EOF
|
||||
Valid options are
|
||||
echo ${apps[*]}
|
||||
EOF
|
||||
}
|
||||
|
||||
restart(){
|
||||
kubectl rollout restart deployment -n app "$1-openreplay"
|
||||
kubectl rollout status deployment -n app "$1-openreplay"
|
||||
}
|
||||
|
||||
[[ -z DOCKER_REPO ]] && {
|
||||
echo Set DOCKER_REPO="your docker registry"
|
||||
exit 1
|
||||
} || {
|
||||
case "$1" in
|
||||
api)
|
||||
echo $IMAGE_TAG
|
||||
cd ../../api
|
||||
source build.sh $@
|
||||
restart chalice
|
||||
;;
|
||||
assets)
|
||||
cd ../../backend
|
||||
source build.sh nil assets
|
||||
restart assets
|
||||
;;
|
||||
db)
|
||||
cd ../../backend
|
||||
source build.sh nil db
|
||||
restart db
|
||||
;;
|
||||
ender)
|
||||
cd ../../backend
|
||||
source build.sh nil ender
|
||||
restart ender
|
||||
;;
|
||||
http)
|
||||
cd ../../backend
|
||||
source build.sh nil http
|
||||
restart http
|
||||
;;
|
||||
integrations)
|
||||
cd ../../backend
|
||||
source build.sh nil integrations
|
||||
restart integrations
|
||||
;;
|
||||
sink)
|
||||
cd ../../backend
|
||||
source build.sh nil sink
|
||||
restart sink
|
||||
;;
|
||||
storage)
|
||||
cd ../../backend
|
||||
source build.sh nil storage
|
||||
restart storage
|
||||
;;
|
||||
assist)
|
||||
cd ../../utilities
|
||||
source build.sh $@
|
||||
restart assist
|
||||
;;
|
||||
peers)
|
||||
cd ../../peers
|
||||
source build.sh $@
|
||||
restart peers
|
||||
;;
|
||||
all)
|
||||
for app in ${apps[*]}
|
||||
do
|
||||
bash local_deploy.sh $app
|
||||
done
|
||||
;;
|
||||
*)
|
||||
echo "unknown option;"
|
||||
help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
129
scripts/vagrant/Vagrantfile
vendored
Normal file
129
scripts/vagrant/Vagrantfile
vendored
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
||||
# configures the configuration version (we support older styles for
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure("2") do |config|
|
||||
# The most common configuration options are documented and commented below.
|
||||
# For a complete reference, please see the online documentation at
|
||||
# https://docs.vagrantup.com.
|
||||
|
||||
# Every Vagrant development environment requires a box. You can search for
|
||||
# boxes at https://vagrantcloud.com/search.
|
||||
config.vm.box = "peru/ubuntu-20.04-server-amd64"
|
||||
config.vm.define "openreplay-dev"
|
||||
|
||||
# Disable automatic box update checking. If you disable this, then
|
||||
# boxes will only be checked for updates when the user runs
|
||||
# `vagrant box outdated`. This is not recommended.
|
||||
# config.vm.box_check_update = false
|
||||
|
||||
# Create a forwarded port mapping which allows access to a specific port
|
||||
# within the machine from a port on the host machine. In the example below,
|
||||
# accessing "localhost:8080" will access port 80 on the guest machine.
|
||||
# NOTE: This will enable public access to the opened port
|
||||
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
||||
|
||||
# Create a forwarded port mapping which allows access to a specific port
|
||||
# within the machine from a port on the host machine and only allow access
|
||||
# via 127.0.0.1 to disable public access
|
||||
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
|
||||
|
||||
# Create a private network, which allows host-only access to the machine
|
||||
# using a specific IP.
|
||||
config.vm.network "private_network", type: "dhcp"
|
||||
|
||||
# Create a public network, which generally matched to bridged network.
|
||||
# Bridged networks make the machine appear as another physical device on
|
||||
# your network.
|
||||
# config.vm.network "public_network"
|
||||
|
||||
# Share an additional folder to the guest VM. The first argument is
|
||||
# the path on the host to the actual folder. The second argument is
|
||||
# the path on the guest to mount the folder. And the optional third
|
||||
# argument is a set of non-required options.
|
||||
config.vm.synced_folder "./", "/home/vagrant/openreplay-dev/"
|
||||
|
||||
# Provider-specific configuration so you can fine-tune various
|
||||
# backing providers for Vagrant. These expose provider-specific options.
|
||||
# Example for VirtualBox:
|
||||
#
|
||||
config.vm.provider "virtualbox" do |vb|
|
||||
# Display the VirtualBox GUI when booting the machine
|
||||
vb.gui = false
|
||||
|
||||
# Customize the amount of memory on the VM:
|
||||
vb.cpus = "2"
|
||||
vb.memory = "4096"
|
||||
end
|
||||
#
|
||||
# View the documentation for the provider you are using for more
|
||||
# information on available options.
|
||||
|
||||
# Enable provisioning with a shell script. Additional provisioners such as
|
||||
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
|
||||
# documentation for more information about their specific syntax and use.
|
||||
config.vm.provision "shell", inline: <<-SHELL
|
||||
set -x
|
||||
|
||||
IP_ADDR=`ip r | tail -n1 | awk '{print $NF}'`
|
||||
|
||||
# Updating host domainName
|
||||
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
|
||||
|
||||
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 <<EOF
|
||||
|
||||
################################################
|
||||
Openreplay Dev environment preparation completed.
|
||||
################################################
|
||||
|
||||
Steps to do:
|
||||
|
||||
Add ip address from about output to your local resolver
|
||||
|
||||
## Mac (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'
|
||||
|
||||
## 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
|
||||
6
utilities/.dockerignore
Normal file
6
utilities/.dockerignore
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# ignore .git and .cache folders
|
||||
.git
|
||||
.cache
|
||||
**/build.sh
|
||||
**/build_*.sh
|
||||
**/*deploy.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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue