Files
falah-os-ce/ummah-wordpress/deploy.sh
T
Antigravity AI ff09a84060 fix: use Traefik labels instead of Caddy — update deploy stack for Contabo
- docker-compose.yml: Traefik routers/services labels, TLS via letsencrypt certresolver
- deploy.sh: auto-detects Traefik network, installs plugins from GitHub raw URLs
- Containers: ummah2-db, ummah2-wp (apache variant for simpler setup), ummah2-wpcli
2026-07-06 18:36:54 +08:00

115 lines
5.7 KiB
Bash

#!/usr/bin/env bash
# deploy.sh — spin up ummah2.falahos.my on Contabo via Traefik
set -euo pipefail
DEPLOY_DIR="/opt/ummah-wordpress"
SITE_URL="https://ummah2.falahos.my"
REPO="https://github.com/maifors/falah-os.git"
BRANCH="community-edition"
echo "▶ Deploying ummah2.falahos.my"
# ── Clone / update repo ───────────────────────────────────────────────────────
if [ -d "$DEPLOY_DIR/.git" ]; then
git -C "$DEPLOY_DIR" fetch origin
git -C "$DEPLOY_DIR" reset --hard origin/$BRANCH
else
git clone --branch "$BRANCH" --depth 1 "$REPO" "$DEPLOY_DIR"
fi
cd "$DEPLOY_DIR/ummah-wordpress"
# ── .env setup ────────────────────────────────────────────────────────────────
if [ ! -f .env ]; then
cp .env.example .env
echo ""
echo "⚠️ Fill .env before continuing:"
echo " nano $DEPLOY_DIR/ummah-wordpress/.env"
echo ""
echo " DB_ROOT_PASSWORD — strong random password"
echo " DB_PASSWORD — strong random password"
echo " WP_ADMIN_PASSWORD — strong password for /wp-admin"
exit 0
fi
source .env
# ── Detect Traefik network name ───────────────────────────────────────────────
TRAEFIK_NETWORK=$(docker network ls --format '{{.Name}}' | grep -iE "traefik|proxy|public" | head -1 || echo "traefik-public")
export TRAEFIK_NETWORK
echo " Using Traefik network: $TRAEFIK_NETWORK"
# ── Check https-redirect middleware exists ────────────────────────────────────
# If not, add it (some Traefik setups define it globally, some don't)
if ! docker inspect traefik 2>/dev/null | grep -q "https-redirect"; then
echo " Note: https-redirect middleware may need to be pre-defined in Traefik config"
fi
# ── Start stack ───────────────────────────────────────────────────────────────
echo "── Starting DB ──"
docker compose up -d db
echo " Waiting for MariaDB…"
until docker compose exec -T db mysqladmin ping -u root -p"$DB_ROOT_PASSWORD" --silent 2>/dev/null; do
sleep 2
done
echo " DB ready ✅"
echo "── Starting WordPress ──"
docker compose up -d wordpress
echo " Waiting for WordPress files…"
for i in $(seq 1 40); do
if docker compose exec -T wordpress test -f /var/www/html/wp-includes/version.php 2>/dev/null; then
break
fi
sleep 3
done
# ── WP-CLI install ────────────────────────────────────────────────────────────
echo "── Running WP install via WP-CLI ──"
docker compose run --rm wpcli core install \
--url="$SITE_URL" \
--title="${WP_SITE_TITLE:-Ummah FalahOS}" \
--admin_user="${WP_ADMIN_USER:-admin}" \
--admin_password="$WP_ADMIN_PASSWORD" \
--admin_email="${WP_ADMIN_EMAIL:-wanjauhari@gmail.com}" \
--skip-email 2>/dev/null || echo " Already installed."
# ── Set permalink ─────────────────────────────────────────────────────────────
docker compose run --rm wpcli rewrite structure '/%postname%/' --hard 2>/dev/null
# ── Install plugins ───────────────────────────────────────────────────────────
echo "── Installing Falah plugins ──"
# Falah Shortcodes from GitHub raw
docker compose run --rm wpcli plugin install \
"https://github.com/maifors/falah-os/raw/community-edition/wordpress-plugins/falah-shortcodes.zip" \
--activate --force 2>/dev/null && echo " falah-shortcodes ✅" || echo " falah-shortcodes: upload manually"
# Hermes AI Bridge from GitHub raw
docker compose run --rm wpcli plugin install \
"https://github.com/maifors/falah-os/raw/community-edition/wordpress-plugins/hermes-ai-bridge.zip" \
--activate --force 2>/dev/null && echo " hermes-ai-bridge ✅" || echo " hermes-ai-bridge: upload manually"
# Essential WP.org plugins
echo "── Installing WP.org plugins ──"
for plugin in astra tutor-lms mailpoet woocommerce easy-digital-downloads litespeed-cache; do
docker compose run --rm wpcli plugin install "$plugin" --activate 2>/dev/null \
&& echo " $plugin ✅" || echo " $plugin ⚠️"
done
# ── Astra theme ───────────────────────────────────────────────────────────────
docker compose run --rm wpcli theme install astra --activate 2>/dev/null || true
# ── WP performance settings ───────────────────────────────────────────────────
docker compose run --rm wpcli option update blogdescription "Learn, Discuss, and Grow Together" 2>/dev/null || true
docker compose run --rm wpcli option update timezone_string "Asia/Kuala_Lumpur" 2>/dev/null || true
docker compose run --rm wpcli option update date_format "d F Y" 2>/dev/null || true
echo ""
echo "✅ ummah2.falahos.my is live!"
echo " WP Admin: $SITE_URL/wp-admin"
echo " User: ${WP_ADMIN_USER:-admin}"
echo ""
echo "── DNS (add in Cloudflare) ──"
echo " ummah2.falahos.my A 13.140.161.244 (proxied)"