初始化
This commit is contained in:
32
deploy/deploy.py
Normal file
32
deploy/deploy.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""MoKeeText 部署脚本 — 上传构建产物并重建前端容器"""
|
||||
import paramiko, os
|
||||
|
||||
key_path = os.path.expanduser('~/.ssh/id_rsa')
|
||||
key = paramiko.RSAKey.from_private_key_file(key_path)
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect('101.132.183.138', username='root', pkey=key, timeout=15)
|
||||
|
||||
# 清理旧文件
|
||||
c.exec_command('rm -f /data/mokee/mokeetext/frontend/static/dist/assets/index-*.js /data/mokee/mokeetext/frontend/static/dist/assets/index-*.css 2>/dev/null')
|
||||
|
||||
# 上传新文件
|
||||
dist = 'E:/AI/claude/new/mokeeText/frontend/static/dist'
|
||||
sftp = c.open_sftp()
|
||||
sftp.put(f'{dist}/index.html', '/data/mokee/mokeetext/frontend/static/dist/index.html')
|
||||
for f in os.listdir(f'{dist}/assets'):
|
||||
sftp.put(f'{dist}/assets/{f}', f'/data/mokee/mokeetext/frontend/static/dist/assets/{f}')
|
||||
print(f'✅ {f}')
|
||||
sftp.close()
|
||||
|
||||
# 重建容器
|
||||
_, stdout, stderr = c.exec_command('cd /data/mokee/mokeetext && docker compose up -d --build frontend 2>&1')
|
||||
out = stdout.read().decode()
|
||||
err = stderr.read().decode()
|
||||
print(out)
|
||||
if err:
|
||||
print(err)
|
||||
|
||||
c.close()
|
||||
print('部署完成')
|
||||
Reference in New Issue
Block a user