musfi_prod / deploy.py
abubasith86
Test
cb666c5
raw
history blame
1.13 kB
import os
import shutil
import subprocess
APP_DIR = "/app"
TMP_DIR = "/tmp/repo_clone"
REPO_URL = "https://github.com/abubasith456/Node-WLA.git"
def remove_app_directory():
if os.path.exists(APP_DIR):
print("⚠️ Removing existing app directory...")
shutil.rmtree(APP_DIR, ignore_errors=True)
def clone_repository():
print("πŸ”„ Cloning repository...")
if os.path.exists(TMP_DIR):
shutil.rmtree(TMP_DIR, ignore_errors=True)
subprocess.run(["git", "clone", REPO_URL, TMP_DIR], check=True)
print("πŸ“‚ Moving repository files to app directory...")
shutil.move(TMP_DIR, APP_DIR)
def install_dependencies():
print("πŸ“¦ Installing dependencies...")
subprocess.run(["npm", "install"], cwd=APP_DIR, check=True)
def start_application():
print("πŸš€ Starting application...")
subprocess.Popen(["npm", "start"], cwd=APP_DIR)
def main():
print("πŸš€ Deployment started...")
remove_app_directory()
clone_repository()
install_dependencies()
start_application()
print("βœ… Deployment complete.")
if __name__ == "__main__":
main()