-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
36 lines (29 loc) · 775 Bytes
/
deploy.sh
File metadata and controls
36 lines (29 loc) · 775 Bytes
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
#!/bin/bash
# 检查执行权限
if [ "$EUID" -ne 0 ]; then
echo "Please run as root or with sudo"
exit 1
fi
# 设置变量
REPO_URL="https://github.com/rapRabbit/admin.git"
PROJECT_DIR="/home/hoyiping128/admin"
NGINX_CONTAINER="admin"
# 如果目录不存在则克隆,存在则拉取最新代码
if [ ! -d "$PROJECT_DIR" ]; then
echo "Cloning repository..."
git clone $REPO_URL $PROJECT_DIR
cd $PROJECT_DIR
else
echo "Pulling latest changes..."
cd $PROJECT_DIR
git pull
fi
# 构建后端
cd $PROJECT_DIR/admin
npm install
npm run build
# 复制构建文件到 Nginx 容器
docker cp $PROJECT_DIR/admin/dist/. $NGINX_CONTAINER:/usr/share/nginx/html/admin/
# 重启 Nginx 容器
docker restart $NGINX_CONTAINER
echo "Deployment completed!"