Initial commit for iiEasy: all files included
This commit is contained in:
65
deploy-nomad.sh
Executable file
65
deploy-nomad.sh
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
# Deploy iiEasy to Nomad
|
||||
# Usage:
|
||||
# export NOMAD_ADDR=http://192.168.1.16:4646
|
||||
# export NOMAD_HOST=192.168.1.16
|
||||
# export NOMAD_USER=its
|
||||
# ./deploy-nomad.sh
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
NOMAD_HOST="${NOMAD_HOST:-192.168.1.16}"
|
||||
NOMAD_USER="${NOMAD_USER:-its}"
|
||||
NOMAD_ADDR="${NOMAD_ADDR:-http://${NOMAD_HOST}:4646}"
|
||||
STRAPI_PUBLIC_URL="${STRAPI_PUBLIC_URL:-http://${NOMAD_HOST}:1337}"
|
||||
|
||||
echo "=== iiEasy Nomad Deploy ==="
|
||||
echo "Nomad: $NOMAD_ADDR"
|
||||
echo "Strapi URL (for frontend): $STRAPI_PUBLIC_URL"
|
||||
echo ""
|
||||
|
||||
# 1. Build Docker images
|
||||
echo "Building frontend..."
|
||||
docker build --build-arg VITE_STRAPI_URL="$STRAPI_PUBLIC_URL" -t iieasy-frontend:latest .
|
||||
|
||||
echo "Building Strapi..."
|
||||
docker build -t iieasy-strapi:latest ./iiEasy
|
||||
|
||||
# 2. Save images and copy to Nomad node
|
||||
echo "Saving images..."
|
||||
docker save iieasy-frontend:latest iieasy-strapi:latest -o /tmp/iieasy-images.tar
|
||||
|
||||
echo "Copying to $NOMAD_USER@$NOMAD_HOST..."
|
||||
scp /tmp/iieasy-images.tar "$NOMAD_USER@$NOMAD_HOST:/tmp/"
|
||||
|
||||
# 3. On remote: load images, create dirs, run job
|
||||
echo "Loading images and deploying on Nomad node..."
|
||||
ssh "$NOMAD_USER@$NOMAD_HOST" bash -s << REMOTE
|
||||
set -e
|
||||
docker load -i /tmp/iieasy-images.tar
|
||||
rm -f /tmp/iieasy-images.tar
|
||||
|
||||
# Create host volume dirs (if using client-host-volumes.hcl.example)
|
||||
sudo mkdir -p /opt/nomad/iieasy/postgres-data /opt/nomad/iieasy/uploads
|
||||
sudo chown -R 999:999 /opt/nomad/iieasy/postgres-data 2>/dev/null || true
|
||||
sudo chmod -R 755 /opt/nomad/iieasy/postgres-data /opt/nomad/iieasy/uploads
|
||||
|
||||
echo "Images loaded. Run 'nomad job run' from a machine with Nomad CLI."
|
||||
REMOTE
|
||||
|
||||
# 4. Run Nomad job (from local machine if nomad CLI and NOMAD_ADDR are set)
|
||||
if command -v nomad &>/dev/null; then
|
||||
echo ""
|
||||
echo "Submitting Nomad job..."
|
||||
export NOMAD_ADDR
|
||||
nomad job run nomad/iieasy.nomad.hcl
|
||||
echo ""
|
||||
echo "Done. Check: nomad job status iieasy"
|
||||
else
|
||||
echo ""
|
||||
echo "Nomad CLI not found. Copy nomad/ to the server and run:"
|
||||
echo " NOMAD_ADDR=http://127.0.0.1:4646 nomad job run iieasy.nomad.hcl"
|
||||
fi
|
||||
Reference in New Issue
Block a user