feat: Oracle CRM Page, Synthetic Client Data and Live Snapshot when hitting emotion hotpoint
This commit is contained in:
57
infrastructure/desineuron_ingress/deploy_velocity_site.sh
Normal file
57
infrastructure/desineuron_ingress/deploy_velocity_site.sh
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
APP_ROOT="${APP_ROOT:-/opt/desineuron-velocity-site}"
|
||||
REPO_URL="${REPO_URL:-https://git.desineuron.in/sagnik/Project_Velocity.git}"
|
||||
BRANCH="${BRANCH:-main}"
|
||||
REPO_DIR="${REPO_DIR:-$APP_ROOT/repo}"
|
||||
APP_DIR="${APP_DIR:-$REPO_DIR/app}"
|
||||
BUILD_DIR="${BUILD_DIR:-$APP_DIR/dist}"
|
||||
SERVE_ROOT="${SERVE_ROOT:-/var/www/velocity.desineuron.in}"
|
||||
CURRENT_DIR="${CURRENT_DIR:-$SERVE_ROOT/current}"
|
||||
STATE_DIR="${STATE_DIR:-$APP_ROOT/state}"
|
||||
REVISION_FILE="${REVISION_FILE:-$STATE_DIR/current_revision.txt}"
|
||||
PERSISTENT_VIDEO_DIR="${PERSISTENT_VIDEO_DIR:-$APP_ROOT/shared/videos}"
|
||||
|
||||
mkdir -p "$APP_ROOT" "$STATE_DIR" "$SERVE_ROOT" "$PERSISTENT_VIDEO_DIR"
|
||||
|
||||
if ! command -v git >/dev/null 2>&1; then
|
||||
echo "git is required" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v npm >/dev/null 2>&1; then
|
||||
echo "npm is required" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$REPO_DIR/.git" ]; then
|
||||
git clone "$REPO_URL" "$REPO_DIR"
|
||||
fi
|
||||
|
||||
git -C "$REPO_DIR" fetch --all --prune
|
||||
git -C "$REPO_DIR" checkout "$BRANCH"
|
||||
git -C "$REPO_DIR" reset --hard "origin/$BRANCH"
|
||||
|
||||
pushd "$APP_DIR" >/dev/null
|
||||
if [ -f package-lock.json ]; then
|
||||
npm ci
|
||||
else
|
||||
npm install
|
||||
fi
|
||||
npm run build
|
||||
popd >/dev/null
|
||||
|
||||
rm -rf "$CURRENT_DIR"
|
||||
mkdir -p "$CURRENT_DIR"
|
||||
cp -a "$BUILD_DIR"/. "$CURRENT_DIR"/
|
||||
|
||||
if [ -d "$PERSISTENT_VIDEO_DIR" ] && [ "$(find "$PERSISTENT_VIDEO_DIR" -maxdepth 1 -type f | wc -l)" -gt 0 ]; then
|
||||
mkdir -p "$CURRENT_DIR/videos"
|
||||
cp -a "$PERSISTENT_VIDEO_DIR"/. "$CURRENT_DIR/videos"/
|
||||
fi
|
||||
|
||||
git -C "$REPO_DIR" rev-parse HEAD > "$REVISION_FILE"
|
||||
date -u +"%Y-%m-%dT%H:%M:%SZ" > "$STATE_DIR/last_deploy_utc.txt"
|
||||
|
||||
echo "Deployed revision $(cat "$REVISION_FILE") to $CURRENT_DIR"
|
||||
@@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Deploy latest Project Velocity site build on Linux origin
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=root
|
||||
EnvironmentFile=-/etc/desineuron-velocity-site.env
|
||||
ExecStart=/usr/local/bin/deploy_velocity_site.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=Periodically refresh Project Velocity site from Gitea
|
||||
|
||||
[Timer]
|
||||
OnBootSec=2min
|
||||
OnUnitActiveSec=2min
|
||||
Unit=desineuron-velocity-site-update.service
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SERVICE_FILE=/etc/systemd/system/desineuron-velocity-site-update.service
|
||||
TIMER_FILE=/etc/systemd/system/desineuron-velocity-site-update.timer
|
||||
ENV_FILE=/etc/desineuron-velocity-site.env
|
||||
SCRIPT_PATH=/usr/local/bin/deploy_velocity_site.sh
|
||||
NGINX_PATH=/etc/nginx/conf.d/velocity.desineuron.in.conf
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y git curl rsync nginx
|
||||
|
||||
if ! command -v node >/dev/null 2>&1; then
|
||||
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
||||
sudo apt-get install -y nodejs
|
||||
fi
|
||||
|
||||
sudo install -m 0755 /tmp/desineuron_ingress/deploy_velocity_site.sh "$SCRIPT_PATH"
|
||||
sudo install -m 0644 /tmp/desineuron_ingress/desineuron-velocity-site-update.service "$SERVICE_FILE"
|
||||
sudo install -m 0644 /tmp/desineuron_ingress/desineuron-velocity-site-update.timer "$TIMER_FILE"
|
||||
sudo install -m 0644 /tmp/desineuron_ingress/velocity.desineuron.in.nginx.conf "$NGINX_PATH"
|
||||
|
||||
sudo tee "$ENV_FILE" >/dev/null <<'EOF'
|
||||
APP_ROOT=/opt/desineuron-velocity-site
|
||||
REPO_URL=https://git.desineuron.in/sagnik/Project_Velocity.git
|
||||
BRANCH=main
|
||||
REPO_DIR=/opt/desineuron-velocity-site/repo
|
||||
APP_DIR=/opt/desineuron-velocity-site/repo/app
|
||||
BUILD_DIR=/opt/desineuron-velocity-site/repo/app/dist
|
||||
SERVE_ROOT=/var/www/velocity.desineuron.in
|
||||
CURRENT_DIR=/var/www/velocity.desineuron.in/current
|
||||
STATE_DIR=/opt/desineuron-velocity-site/state
|
||||
REVISION_FILE=/opt/desineuron-velocity-site/state/current_revision.txt
|
||||
EOF
|
||||
|
||||
sudo chmod 0640 "$ENV_FILE"
|
||||
sudo mkdir -p /var/www/velocity.desineuron.in /opt/desineuron-velocity-site/state
|
||||
sudo nginx -t
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now desineuron-velocity-site-update.timer
|
||||
sudo systemctl start desineuron-velocity-site-update.service
|
||||
sudo systemctl reload nginx
|
||||
sudo systemctl --no-pager --full status desineuron-velocity-site-update.service desineuron-velocity-site-update.timer
|
||||
@@ -0,0 +1,17 @@
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name velocity.desineuron.in;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/desineuron-infra/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/desineuron-infra/privkey.pem;
|
||||
|
||||
root /var/www/velocity.desineuron.in/current;
|
||||
index index.html;
|
||||
|
||||
access_log /var/log/nginx/velocity.desineuron.in.access.log;
|
||||
error_log /var/log/nginx/velocity.desineuron.in.error.log;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user