Files
bttoxin-pipeline/docker/scripts/entrypoint.sh
zly 963215de2d Fix(pipeline): prevent nested zip packaging and update CRISPR dependencies
- Add filter to skip .zip and .tar.gz files when creating result archive
- Update CRISPR feature with CASFinder dependencies (hmmer, blast, vmatch, etc.)
- Add install-casfinder task for macsydata installation
- Remove obsolete CRISPR test files

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-28 20:06:41 +08:00

92 lines
2.4 KiB
Bash

#!/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
"