diff --git a/docs/ops/current/deployment.md b/docs/ops/current/deployment.md new file mode 100644 index 0000000..4749bab --- /dev/null +++ b/docs/ops/current/deployment.md @@ -0,0 +1,166 @@ +# Deployment Guide for Mycelium Society Website + +This guide provides a deployment approach for the Mycelium Society website, adapted from the ThreeFold Marketplace setup. This is a React + Vite frontend application that builds to static files served via Caddy. + +> **Note:** For automated deployment, consider integrating with CI/CD pipelines. + +We show steps for the main branch; for development, adjust accordingly (e.g., use `development` branch and dev-specific paths). + +## Prerequisites + +- Linux server with: + - Git installed + - Node.js (version 18+) and npm installed + - Caddy web server installed + - zinit service manager installed (optional, for automation) + - Root or sudo access + +## Step 1: Clone the Repository + +Create the directory structure and clone the repository: + +```bash +# Create directory structure +mkdir -p /root/code/git.ourworld.tf/mycelium/ +cd /root/code/git.ourworld.tf/mycelium/ + +# Clone the repository +git clone https://git.ourworld.tf/mycelium/www_mycelium_society +cd www_mycelium_society +git checkout main +``` + +## Step 2: Build the Application + +Install dependencies and build the production version: + +```bash +# Install Node.js dependencies +npm install + +# Build for production +npm run build +``` + +This generates optimized static files in the `dist/` folder. + +## Step 3: Create a zinit Service (Optional for Build Automation) + +For automated builds and updates, create a zinit service: + +1. Create the service script: + +```bash +mkdir -p /etc/zinit/cmds +nano /etc/zinit/cmds/mycelium-society.sh +``` + +Add the following content (adjust branch as needed): + +```bash +#!/bin/bash +cd /root/code/git.ourworld.tf/mycelium/www_mycelium_society +git checkout main +npm install +npm run build +# Static files are ready; Caddy serves them +``` + +Make the script executable: + +```bash +chmod +x /etc/zinit/cmds/mycelium-society.sh +``` + +2. Create the zinit service definition: + +```bash +nano /etc/zinit/mycelium-society.yaml +``` + +Add: + +```yaml +exec: "/bin/bash -c /etc/zinit/cmds/mycelium-society.sh" +``` + +## Step 4: Configure Caddy + +Update your Caddyfile to serve the static files: + +```bash +# Edit the Caddyfile (adjust path to your Caddyfile location) +nano /root/code/github/despiegk/env_web/ourworld/ovh1_web_current/caddy/Caddyfile +``` + +Add or update: + +``` +import mycelium_society.caddy +``` + +Create `mycelium_society.caddy`: + +``` +society.mycelium.tf { + root * /root/code/git.ourworld.tf/mycelium/www_mycelium_society/dist + try_files {path} {path}/ /index.html + file_server +} +``` + +For a development environment (separate setup): + +``` +dev.society.mycelium.tf { + root * /root/code/git.ourworld.tf/mycelium/dev/www_mycelium_society/dist + try_files {path} {path}/ /index.html + file_server +} +``` + +## Step 5: Start Services + +```bash +# If using zinit for build automation +zinit start mycelium-society-prod + +# Restart Caddy to load configuration +zinit restart caddy +``` + +## Environment Separation (Dev/Prod) + +For clean separation: + +- **Prod:** `/root/code/git.ourworld.tf/mycelium/prod/www_mycelium_society/` +- **Dev:** `/root/code/git.ourworld.tf/mycelium/dev/www_mycelium_society/` + +Clone and build separately for each. + +## Updating the Application + +To update after changes: + +```bash +cd /root/code/git.ourworld.tf/mycelium/www_mycelium_society +git pull +npm install +npm run build +# Reload Caddy +zinit restart caddy +``` + +## Monitoring + +- Check Caddy status: `zinit list` +- View logs: `zinit log caddy` +- Access the site at `http://your-domain` (ensure DNS points to VM public IP) + +## Local Development + +For local builds: + +- `npm install` +- `npm run dev` (development server) +- `npm run build` (production build) \ No newline at end of file