# Frontend Updates & Deployment

**Quick Reference for MapleFile Frontend**

## Overview

The frontend runs on Worker Node 9 as a static site built with Vite/React. Updates are deployed by pulling the latest code and rebuilding.

## Prerequisites

- SSH access to worker-9 as `dockeradmin`
- Node.js and npm installed on the server

## Quick Deploy

```bash
# SSH to worker-9 and run deploy script
ssh dockeradmin@<WORKER_9_IP>
~/deploy-frontend.sh
```

## Manual Deploy

```bash
# 1. SSH to worker-9
ssh dockeradmin@<WORKER_9_IP>

# 2. Navigate to monorepo
cd /var/www/monorepo

# 3. Pull latest changes (includes .env.production from git)
git pull origin main

# 4. Navigate to frontend
cd web/maplefile-frontend

# 5. Install dependencies (if package.json changed)
npm install

# 6. Build production bundle
npm run build
```

## Verify Deployment

```bash
# Check build output exists
ls -la /var/www/monorepo/web/maplefile-frontend/dist/

# Check build timestamp
stat /var/www/monorepo/web/maplefile-frontend/dist/index.html
```

## Rollback

```bash
# SSH to worker-9
ssh dockeradmin@<WORKER_9_IP>

# Navigate to monorepo
cd /var/www/monorepo

# Reset to previous commit
git log --oneline -10  # Find the commit to rollback to
git checkout <COMMIT_SHA>

# Rebuild
cd web/maplefile-frontend
npm install
npm run build
```

## Troubleshooting

### Build Fails

```bash
# Clear node_modules and rebuild
cd /var/www/monorepo/web/maplefile-frontend
rm -rf node_modules
npm install
npm run build
```

### Check Node.js Version

```bash
node --version
npm --version

# If outdated, update Node.js
```

### Permission Issues

```bash
# Ensure correct ownership
sudo chown -R dockeradmin:dockeradmin /var/www/monorepo
```

## Standard Deployment Workflow

```bash
# 1. Local: Commit and push your changes
cd ~/go/src/codeberg.org/mapleopentech/monorepo/web/maplefile-frontend
git add .
git commit -m "feat: your changes"
git push origin main

# 2. Deploy to production
ssh dockeradmin@<WORKER_9_IP>
cd /var/www/monorepo
git pull origin main
cd web/maplefile-frontend
npm install
npm run build

# 3. Verify by visiting the site
# https://maplefile.app (or your domain)
```

---

**Last Updated**: November 2025
