chore: 初始版本提交 - 简化架构 + 轮询改造
- 移除 Motia Streams 实时通信,改用 3 秒轮询 - 简化前端代码,移除冗余组件 - 简化后端架构,准备 FastAPI 重构 - 更新 pixi.toml 环境配置 - 保留 bttoxin_digger_v5_repro 作为参考文档 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
24
docker/scripts/entrypoint.backend.sh
Normal file
24
docker/scripts/entrypoint.backend.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# Backend-only entrypoint for Traefik deployment
|
||||
# Nginx is handled by separate frontend container
|
||||
|
||||
set -e
|
||||
|
||||
# Create jobs directory
|
||||
mkdir -p /app/jobs
|
||||
|
||||
# Activate pixi webbackend environment
|
||||
echo "Activating pixi webbackend environment..."
|
||||
pixi shell-hook -e webbackend > /app/activate.sh
|
||||
echo 'exec "$@"' >> /app/activate.sh
|
||||
|
||||
# Start backend
|
||||
echo "Starting BtToxin Pipeline backend..."
|
||||
exec /bin/bash /app/activate.sh bash -c "
|
||||
mkdir -p /app/jobs
|
||||
|
||||
# Set API_BASE_URL from environment or default
|
||||
export API_BASE_URL=\${API_BASE_URL:-http://localhost}
|
||||
|
||||
uvicorn web.backend.main:app --host 0.0.0.0 --port 8000
|
||||
"
|
||||
91
docker/scripts/entrypoint.sh
Executable file
91
docker/scripts/entrypoint.sh
Executable file
@@ -0,0 +1,91 @@
|
||||
#!/bin/bash
|
||||
# Entrypoint script for bttoxin-pipeline
|
||||
# Activates pixi environment and starts services
|
||||
|
||||
set -e
|
||||
|
||||
# Create jobs directory
|
||||
mkdir -p /app/jobs
|
||||
|
||||
# Install nginx from apt if not already installed
|
||||
if ! command -v nginx &> /dev/null; then
|
||||
echo "Installing nginx..."
|
||||
apt-get update > /dev/null 2>&1
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends nginx curl > /dev/null 2>&1
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
fi
|
||||
|
||||
# Create shell-hook script for webbackend environment (includes uvicorn)
|
||||
echo "Activating pixi webbackend environment..."
|
||||
pixi shell-hook -e webbackend > /app/activate.sh
|
||||
echo 'exec "$@"' >> /app/activate.sh
|
||||
|
||||
# Create nginx config in /tmp (writable)
|
||||
cat > /tmp/nginx.conf << 'NGINXCONF'
|
||||
worker_processes auto;
|
||||
pid /tmp/nginx.pid;
|
||||
error_log /tmp/nginx_error.log;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent"';
|
||||
|
||||
access_log /tmp/nginx_access.log main;
|
||||
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
client_max_body_size 100M;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
root /var/www/html;
|
||||
index index.html;
|
||||
|
||||
gzip on;
|
||||
gzip_types text/plain text/css application/json application/javascript;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:8000/api/;
|
||||
proxy_http_version 1.1;
|
||||
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 X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location = /health {
|
||||
proxy_pass http://127.0.0.1:8000/api/health;
|
||||
}
|
||||
}
|
||||
}
|
||||
NGINXCONF
|
||||
|
||||
# Start services using the shell hook
|
||||
echo "Starting BtToxin Pipeline services..."
|
||||
exec /bin/bash /app/activate.sh bash -c "
|
||||
mkdir -p /app/jobs
|
||||
|
||||
# Set API_BASE_URL from environment or default
|
||||
export API_BASE_URL=\${API_BASE_URL:-http://localhost}
|
||||
|
||||
# Start nginx with custom config
|
||||
nginx -c /tmp/nginx.conf &
|
||||
|
||||
# Start backend
|
||||
uvicorn backend.app.main:app --host 127.0.0.1 --port 8000 &
|
||||
|
||||
wait
|
||||
"
|
||||
26
docker/scripts/switch-to-traefik.sh
Executable file
26
docker/scripts/switch-to-traefik.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
# Switch to Traefik mode
|
||||
|
||||
echo "Stopping test container..."
|
||||
docker compose -f /home/zly/project/bttoxin-pipeline/docker/compose/docker-compose.test.yml down
|
||||
|
||||
echo "Starting with Traefik..."
|
||||
docker run -d \
|
||||
--name bttoxin-pipeline \
|
||||
--network traefik-network \
|
||||
-v /home/zly/project/bttoxin-pipeline/jobs:/app/jobs \
|
||||
-e JOBS_DIR=/app/jobs \
|
||||
--label traefik.enable=true \
|
||||
--label traefik.http.routers.bttoxin.rule="Host(\`bttiaw.hzau.edu.cn\`)" \
|
||||
--label traefik.http.routers.bttoxin.entrypoints=web \
|
||||
--label traefik.http.routers.bttoxin.middlewares=redirect-to-https \
|
||||
--label traefik.http.routers.bttoxin-secure.rule="Host(\`bttiaw.hzau.edu.cn\`)" \
|
||||
--label traefik.http.routers.bttoxin-secure.entrypoints=websecure \
|
||||
--label traefik.http.routers.bttoxin-secure.tls=true \
|
||||
--label traefik.http.services.bttoxin.loadbalancer.server.port=8000 \
|
||||
--label traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https \
|
||||
--label traefik.http.middlewares.redirect-to-https.redirectscheme.permanent=true \
|
||||
--restart unless-stopped \
|
||||
bttoxin-pipeline:latest
|
||||
|
||||
echo "Done! Access via: https://bttiaw.hzau.edu.cn"
|
||||
Reference in New Issue
Block a user