-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·50 lines (42 loc) · 1.43 KB
/
deploy.sh
File metadata and controls
executable file
·50 lines (42 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -e
# Check if HOST is provided
if [ -z "$1" ]; then
echo "Usage: $0 <host> [user] [deploy-path]"
echo "Example: $0 192.168.1.50 myuser /opt/hubstack"
exit 1
fi
HOST=$1
USER=${2:-$USER}
DEPLOY_PATH=${3:-/opt/hubstack}
echo "==> Deploying to $USER@$HOST:$DEPLOY_PATH"
# Create remote directory and set ownership
echo "==> Creating remote directory..."
ssh -t "$USER@$HOST" "sudo mkdir -p $DEPLOY_PATH && sudo chown -R $USER:$USER $DEPLOY_PATH"
# Copy files to remote host
echo "==> Copying files to remote host..."
rsync -avz --delete \
--exclude='.git' \
--exclude='bin/hubstack' \
--exclude='*.md' \
--exclude='go.mod' \
--exclude='go.sum' \
--exclude='cmd/' \
--exclude='internal/' \
./bin \
./templates \
./docker-compose.yml \
./.dockerignore \
./config.yml \
"$USER@$HOST:$DEPLOY_PATH/"
# Set proper permissions for Docker container access
echo "==> Setting permissions..."
ssh "$USER@$HOST" "chmod 666 $DEPLOY_PATH/config.yml"
# Deploy with docker-compose on remote host
echo "==> Building and starting Docker container on remote host..."
ssh -t "$USER@$HOST" "cd $DEPLOY_PATH && sudo docker compose up -d --build"
echo "==> Deployment complete!"
echo "==> View logs with: make remote-logs HOST=$HOST"
echo "==> Check status with: make remote-status HOST=$HOST"
echo "==> Restart with: make remote-restart HOST=$HOST"
echo "==> Stop with: make remote-stop HOST=$HOST"