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
This commit is contained in:
+75
-78
@@ -1,117 +1,114 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# deploy.sh — spin up ummah2.falahos.my WordPress on Contabo
|
# deploy.sh — spin up ummah2.falahos.my on Contabo via Traefik
|
||||||
# Run on Contabo: bash deploy.sh
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
DEPLOY_DIR="/opt/ummah-wordpress"
|
DEPLOY_DIR="/opt/ummah-wordpress"
|
||||||
SITE_URL="https://ummah2.falahos.my"
|
SITE_URL="https://ummah2.falahos.my"
|
||||||
WP_PLUGINS_DIR="$DEPLOY_DIR/wp-data/wp-content/plugins"
|
REPO="https://github.com/maifors/falah-os.git"
|
||||||
|
BRANCH="community-edition"
|
||||||
|
|
||||||
echo "▶ Deploying ummah2.falahos.my WordPress on Contabo"
|
echo "▶ Deploying ummah2.falahos.my"
|
||||||
|
|
||||||
# ── Prerequisites ────────────────────────────────────────────────────────────
|
# ── Clone / update repo ───────────────────────────────────────────────────────
|
||||||
command -v docker >/dev/null || { echo "❌ docker not found"; exit 1; }
|
if [ -d "$DEPLOY_DIR/.git" ]; then
|
||||||
docker compose version >/dev/null 2>&1 || { echo "❌ docker compose plugin not found"; exit 1; }
|
git -C "$DEPLOY_DIR" fetch origin
|
||||||
|
git -C "$DEPLOY_DIR" reset --hard origin/$BRANCH
|
||||||
# ── Setup deploy dir ─────────────────────────────────────────────────────────
|
else
|
||||||
mkdir -p "$DEPLOY_DIR"
|
git clone --branch "$BRANCH" --depth 1 "$REPO" "$DEPLOY_DIR"
|
||||||
cd "$DEPLOY_DIR"
|
fi
|
||||||
|
cd "$DEPLOY_DIR/ummah-wordpress"
|
||||||
|
|
||||||
|
# ── .env setup ────────────────────────────────────────────────────────────────
|
||||||
if [ ! -f .env ]; then
|
if [ ! -f .env ]; then
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
echo ""
|
echo ""
|
||||||
echo "⚠️ Fill in .env before continuing:"
|
echo "⚠️ Fill .env before continuing:"
|
||||||
echo " DB_ROOT_PASSWORD, DB_PASSWORD, WP_ADMIN_PASSWORD"
|
echo " nano $DEPLOY_DIR/ummah-wordpress/.env"
|
||||||
echo " nano $DEPLOY_DIR/.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
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source .env
|
source .env
|
||||||
|
|
||||||
# ── Start stack ───────────────────────────────────────────────────────────────
|
# ── Detect Traefik network name ───────────────────────────────────────────────
|
||||||
echo "── Starting MariaDB + WordPress + Nginx ──"
|
TRAEFIK_NETWORK=$(docker network ls --format '{{.Name}}' | grep -iE "traefik|proxy|public" | head -1 || echo "traefik-public")
|
||||||
docker compose up -d db
|
export TRAEFIK_NETWORK
|
||||||
echo " Waiting for DB to be ready…"
|
echo " Using Traefik network: $TRAEFIK_NETWORK"
|
||||||
sleep 10
|
|
||||||
docker compose up -d
|
|
||||||
|
|
||||||
# ── Wait for WordPress to be ready ───────────────────────────────────────────
|
# ── Check https-redirect middleware exists ────────────────────────────────────
|
||||||
echo "── Waiting for WordPress container ──"
|
# If not, add it (some Traefik setups define it globally, some don't)
|
||||||
for i in $(seq 1 30); do
|
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
|
if docker compose exec -T wordpress test -f /var/www/html/wp-includes/version.php 2>/dev/null; then
|
||||||
echo " WordPress files ready."
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
sleep 3
|
sleep 3
|
||||||
done
|
done
|
||||||
|
|
||||||
# ── Install WordPress via WP-CLI ──────────────────────────────────────────────
|
# ── WP-CLI install ────────────────────────────────────────────────────────────
|
||||||
echo "── Installing WordPress ──"
|
echo "── Running WP install via WP-CLI ──"
|
||||||
docker compose run --rm wpcli core install \
|
docker compose run --rm wpcli core install \
|
||||||
--url="$SITE_URL" \
|
--url="$SITE_URL" \
|
||||||
--title="$WP_SITE_TITLE" \
|
--title="${WP_SITE_TITLE:-Ummah FalahOS}" \
|
||||||
--admin_user="$WP_ADMIN_USER" \
|
--admin_user="${WP_ADMIN_USER:-admin}" \
|
||||||
--admin_password="$WP_ADMIN_PASSWORD" \
|
--admin_password="$WP_ADMIN_PASSWORD" \
|
||||||
--admin_email="$WP_ADMIN_EMAIL" \
|
--admin_email="${WP_ADMIN_EMAIL:-wanjauhari@gmail.com}" \
|
||||||
--skip-email 2>/dev/null || echo " (already installed)"
|
--skip-email 2>/dev/null || echo " Already installed."
|
||||||
|
|
||||||
|
# ── Set permalink ─────────────────────────────────────────────────────────────
|
||||||
|
docker compose run --rm wpcli rewrite structure '/%postname%/' --hard 2>/dev/null
|
||||||
|
|
||||||
# ── Install plugins ───────────────────────────────────────────────────────────
|
# ── Install plugins ───────────────────────────────────────────────────────────
|
||||||
echo "── Installing plugins ──"
|
echo "── Installing Falah plugins ──"
|
||||||
|
|
||||||
# Hermes AI Bridge (from Gitea raw)
|
# Falah Shortcodes from GitHub raw
|
||||||
docker compose run --rm wpcli plugin install \
|
docker compose run --rm wpcli plugin install \
|
||||||
"https://git.falahos.my/wmj/hermes-cpanel-agent/archive/main.zip" \
|
"https://github.com/maifors/falah-os/raw/community-edition/wordpress-plugins/falah-shortcodes.zip" \
|
||||||
--activate 2>/dev/null || echo " hermes-ai-bridge: manual install needed"
|
--activate --force 2>/dev/null && echo " falah-shortcodes ✅" || echo " falah-shortcodes: upload manually"
|
||||||
|
|
||||||
# Falah Shortcodes (from Gitea raw via falahos org)
|
# Hermes AI Bridge from GitHub raw
|
||||||
docker compose run --rm wpcli plugin install \
|
docker compose run --rm wpcli plugin install \
|
||||||
"https://git.falahos.my/falahos/falah-os-ce/raw/branch/community-edition/wordpress-plugins/falah-shortcodes.zip" \
|
"https://github.com/maifors/falah-os/raw/community-edition/wordpress-plugins/hermes-ai-bridge.zip" \
|
||||||
--activate 2>/dev/null || echo " falah-shortcodes: manual install needed"
|
--activate --force 2>/dev/null && echo " hermes-ai-bridge ✅" || echo " hermes-ai-bridge: upload manually"
|
||||||
|
|
||||||
# Essential plugins from WP.org
|
# Essential WP.org plugins
|
||||||
for plugin in astra-sites tutor learndash-gutenberg-blocks mailpoet woocommerce easy-digital-downloads redis-cache; do
|
echo "── Installing WP.org plugins ──"
|
||||||
docker compose run --rm wpcli plugin install "$plugin" --activate 2>/dev/null || true
|
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
|
done
|
||||||
|
|
||||||
# ── Set permalink structure ───────────────────────────────────────────────────
|
# ── Astra theme ───────────────────────────────────────────────────────────────
|
||||||
docker compose run --rm wpcli rewrite structure '/%postname%/' --hard
|
docker compose run --rm wpcli theme install astra --activate 2>/dev/null || true
|
||||||
|
|
||||||
# ── Configure Caddy ───────────────────────────────────────────────────────────
|
# ── WP performance settings ───────────────────────────────────────────────────
|
||||||
echo "── Configuring Caddy reverse proxy ──"
|
docker compose run --rm wpcli option update blogdescription "Learn, Discuss, and Grow Together" 2>/dev/null || true
|
||||||
CADDY_FILE="/etc/caddy/conf.d/ummah2.conf"
|
docker compose run --rm wpcli option update timezone_string "Asia/Kuala_Lumpur" 2>/dev/null || true
|
||||||
mkdir -p /etc/caddy/conf.d
|
docker compose run --rm wpcli option update date_format "d F Y" 2>/dev/null || true
|
||||||
|
|
||||||
cat > "$CADDY_FILE" << 'CADDY'
|
|
||||||
ummah2.falahos.my {
|
|
||||||
reverse_proxy localhost:8888
|
|
||||||
|
|
||||||
encode gzip
|
|
||||||
|
|
||||||
header {
|
|
||||||
Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
|
|
||||||
X-Frame-Options SAMEORIGIN
|
|
||||||
X-Content-Type-Options nosniff
|
|
||||||
Referrer-Policy strict-origin-when-cross-origin
|
|
||||||
-Server
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CADDY
|
|
||||||
|
|
||||||
# Reload Caddy if running
|
|
||||||
if systemctl is-active --quiet caddy 2>/dev/null; then
|
|
||||||
systemctl reload caddy
|
|
||||||
echo " Caddy reloaded ✅"
|
|
||||||
elif docker ps --format '{{.Names}}' | grep -q caddy; then
|
|
||||||
docker kill --signal=USR1 "$(docker ps --format '{{.Names}}' | grep caddy)"
|
|
||||||
echo " Caddy (docker) reloaded ✅"
|
|
||||||
else
|
|
||||||
echo " ⚠️ Caddy not found — add ummah2.falahos.my block to your reverse proxy manually"
|
|
||||||
echo " Nginx port 8888 → ummah2.falahos.my"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "✅ ummah2.falahos.my is up on port 8888"
|
echo "✅ ummah2.falahos.my is live!"
|
||||||
echo " WP Admin: $SITE_URL/wp-admin (user: $WP_ADMIN_USER)"
|
echo " WP Admin: $SITE_URL/wp-admin"
|
||||||
|
echo " User: ${WP_ADMIN_USER:-admin}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "── Next: point DNS ──"
|
echo "── DNS (add in Cloudflare) ──"
|
||||||
echo " ummah2.falahos.my A → 13.140.161.244"
|
echo " ummah2.falahos.my A 13.140.161.244 (proxied)"
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
version: "3.9"
|
version: "3.9"
|
||||||
|
|
||||||
|
# ummah2.falahos.my — WordPress on Contabo
|
||||||
|
# Reverse proxy: Traefik (already running)
|
||||||
|
# Run: docker compose up -d
|
||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: mariadb:11
|
image: mariadb:11
|
||||||
container_name: ummah-db
|
container_name: ummah2-db
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
|
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
|
||||||
MYSQL_DATABASE: ummah_wp
|
MYSQL_DATABASE: ummah2_wp
|
||||||
MYSQL_USER: ummah_wp
|
MYSQL_USER: ummah2_wp
|
||||||
MYSQL_PASSWORD: ${DB_PASSWORD}
|
MYSQL_PASSWORD: ${DB_PASSWORD}
|
||||||
volumes:
|
volumes:
|
||||||
- ummah-db-data:/var/lib/mysql
|
- ummah2-db-data:/var/lib/mysql
|
||||||
networks:
|
networks:
|
||||||
- ummah-net
|
- ummah2-internal
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
|
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
@@ -21,66 +25,69 @@ services:
|
|||||||
retries: 5
|
retries: 5
|
||||||
|
|
||||||
wordpress:
|
wordpress:
|
||||||
image: wordpress:6.7-php8.3-fpm-alpine
|
image: wordpress:6.7-php8.3-apache
|
||||||
container_name: ummah-wp
|
container_name: ummah2-wp
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
environment:
|
environment:
|
||||||
WORDPRESS_DB_HOST: db:3306
|
WORDPRESS_DB_HOST: db:3306
|
||||||
WORDPRESS_DB_NAME: ummah_wp
|
WORDPRESS_DB_NAME: ummah2_wp
|
||||||
WORDPRESS_DB_USER: ummah_wp
|
WORDPRESS_DB_USER: ummah2_wp
|
||||||
WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
|
WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
|
||||||
WORDPRESS_TABLE_PREFIX: wp_
|
WORDPRESS_TABLE_PREFIX: wp_
|
||||||
WORDPRESS_DEBUG: "false"
|
WORDPRESS_DEBUG: "false"
|
||||||
# Performance
|
|
||||||
PHP_MEMORY_LIMIT: 256M
|
PHP_MEMORY_LIMIT: 256M
|
||||||
PHP_MAX_EXECUTION_TIME: 300
|
WORDPRESS_CONFIG_EXTRA: |
|
||||||
PHP_UPLOAD_MAX_FILESIZE: 64M
|
define('WP_MEMORY_LIMIT', '256M');
|
||||||
PHP_POST_MAX_SIZE: 64M
|
define('WP_HOME', 'https://ummah2.falahos.my');
|
||||||
|
define('WP_SITEURL', 'https://ummah2.falahos.my');
|
||||||
|
$_SERVER['HTTPS'] = 'on';
|
||||||
|
define('FORCE_SSL_ADMIN', true);
|
||||||
volumes:
|
volumes:
|
||||||
- ummah-wp-data:/var/www/html
|
- ummah2-wp-data:/var/www/html
|
||||||
- ./wordpress-config/php.ini:/usr/local/etc/php/conf.d/ummah.ini:ro
|
- ./wordpress-config/php.ini:/usr/local/etc/php/conf.d/ummah2.ini:ro
|
||||||
networks:
|
networks:
|
||||||
- ummah-net
|
- ummah2-internal
|
||||||
|
- traefik-public
|
||||||
nginx:
|
labels:
|
||||||
image: nginx:alpine
|
- "traefik.enable=true"
|
||||||
container_name: ummah-nginx
|
- "traefik.http.routers.ummah2.rule=Host(`ummah2.falahos.my`)"
|
||||||
restart: unless-stopped
|
- "traefik.http.routers.ummah2.entrypoints=websecure"
|
||||||
depends_on:
|
- "traefik.http.routers.ummah2.tls.certresolver=letsencrypt"
|
||||||
- wordpress
|
- "traefik.http.services.ummah2.loadbalancer.server.port=80"
|
||||||
ports:
|
# Redirect http→https
|
||||||
- "8888:80"
|
- "traefik.http.routers.ummah2-http.rule=Host(`ummah2.falahos.my`)"
|
||||||
volumes:
|
- "traefik.http.routers.ummah2-http.entrypoints=web"
|
||||||
- ummah-wp-data:/var/www/html:ro
|
- "traefik.http.routers.ummah2-http.middlewares=https-redirect"
|
||||||
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
|
||||||
networks:
|
|
||||||
- ummah-net
|
|
||||||
|
|
||||||
wpcli:
|
wpcli:
|
||||||
image: wordpress:cli-2-php8.3
|
image: wordpress:cli-2-php8.3
|
||||||
container_name: ummah-wpcli
|
container_name: ummah2-wpcli
|
||||||
depends_on:
|
depends_on:
|
||||||
- wordpress
|
- wordpress
|
||||||
- db
|
- db
|
||||||
|
user: "33:33"
|
||||||
environment:
|
environment:
|
||||||
WORDPRESS_DB_HOST: db:3306
|
WORDPRESS_DB_HOST: db:3306
|
||||||
WORDPRESS_DB_NAME: ummah_wp
|
WORDPRESS_DB_NAME: ummah2_wp
|
||||||
WORDPRESS_DB_USER: ummah_wp
|
WORDPRESS_DB_USER: ummah2_wp
|
||||||
WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
|
WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
|
||||||
volumes:
|
volumes:
|
||||||
- ummah-wp-data:/var/www/html
|
- ummah2-wp-data:/var/www/html
|
||||||
networks:
|
networks:
|
||||||
- ummah-net
|
- ummah2-internal
|
||||||
entrypoint: ["tail", "-f", "/dev/null"]
|
entrypoint: ["tail", "-f", "/dev/null"]
|
||||||
profiles: ["tools"]
|
profiles: ["tools"]
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
ummah-net:
|
ummah2-internal:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
traefik-public:
|
||||||
|
external: true
|
||||||
|
name: ${TRAEFIK_NETWORK:-traefik-public}
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
ummah-db-data:
|
ummah2-db-data:
|
||||||
ummah-wp-data:
|
ummah2-wp-data:
|
||||||
|
|||||||
Reference in New Issue
Block a user