2e2c161770
- backed/: Go Fiber backend with cpdaily integration - frondend/: Vue 3 + Vite frontend - Dockerfile: multi-stage build (Node → Go → Alpine) - deploy/docker-compose.yml: production compose file - .woodpecker/build.yml: CI/CD with blue-green zero-downtime deploy - /health endpoint for deployment health checks - Port 8884/8885 blue-green swap via 1Panel OpenResty
69 lines
2.4 KiB
Bash
69 lines
2.4 KiB
Bash
#!/bin/bash
|
|
# ============================================================
|
|
# cpdaily-xiaozhushou 首次部署初始化脚本
|
|
# 仅需在首次部署时执行一次
|
|
# ============================================================
|
|
set -e
|
|
|
|
SITE_NAME="xiaozhushou"
|
|
DOMAIN="xiaozhushou.eu.cc"
|
|
ACTIVE_PORT=8884
|
|
|
|
echo "=== 1. 创建生产配置目录 ==="
|
|
mkdir -p /opt/cpdaily-xiaozhushou
|
|
|
|
echo "=== 2. 创建 1Panel 站点配置 ==="
|
|
docker exec 1Panel-openresty-ESmn mkdir -p /www/sites/$SITE_NAME/proxy /www/sites/$SITE_NAME/log
|
|
|
|
cat <<NGINX_EOF | docker exec -i 1Panel-openresty-ESmn tee /usr/local/openresty/nginx/conf/conf.d/$SITE_NAME.conf
|
|
server {
|
|
listen 80 ;
|
|
server_name $DOMAIN;
|
|
index index.php index.html index.htm default.php default.htm default.html;
|
|
proxy_set_header Host \$host;
|
|
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Host \$server_name;
|
|
proxy_set_header X-Real-IP \$remote_addr;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade \$http_upgrade;
|
|
proxy_set_header Connection \$http_connection;
|
|
access_log /www/sites/$SITE_NAME/log/access.log main;
|
|
error_log /www/sites/$SITE_NAME/log/error.log;
|
|
location ^~ /.well-known/acme-challenge {
|
|
allow all;
|
|
root /usr/share/nginx/html;
|
|
}
|
|
include /www/sites/$SITE_NAME/proxy/*.conf;
|
|
}
|
|
NGINX_EOF
|
|
|
|
cat <<PROXY_EOF | docker exec -i 1Panel-openresty-ESmn tee /www/sites/$SITE_NAME/proxy/api.conf
|
|
location ^~ / {
|
|
proxy_pass http://10.10.10.128:$ACTIVE_PORT/;
|
|
proxy_set_header Host \$host;
|
|
proxy_set_header X-Real-IP \$remote_addr;
|
|
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
|
proxy_set_header REMOTE-HOST \$remote_addr;
|
|
proxy_set_header Upgrade \$http_upgrade;
|
|
proxy_set_header Connection \$http_connection;
|
|
proxy_set_header X-Forwarded-Proto https;
|
|
proxy_set_header X-Forwarded-Port \$server_port;
|
|
proxy_http_version 1.1;
|
|
add_header X-Cache \$upstream_cache_status;
|
|
add_header Cache-Control no-cache;
|
|
proxy_ssl_server_name off;
|
|
proxy_ssl_name \$proxy_host;
|
|
}
|
|
PROXY_EOF
|
|
|
|
docker exec 1Panel-openresty-ESmn nginx -s reload
|
|
echo " 1Panel 站点配置完成 ✓"
|
|
|
|
echo ""
|
|
echo "=== 初始化完成 ==="
|
|
echo "1Panel 站点: $SITE_NAME ($DOMAIN)"
|
|
echo "代理端口: $ACTIVE_PORT"
|
|
echo ""
|
|
echo "请手动创建 /opt/cpdaily-xiaozhushou/config.toml 后执行 Woodpecker 部署"
|
|
echo "配置文件模板见 backed/config.toml"
|