Spaces:
Running
Changelog: SQLite Migration & Hugging Face Spaces Deployment
Date: 2026-06-09
Branch:feature/hugging-face-deploy
Commits:fd94aa0..1cbbcaa(3 commits)
Overview
Migrated AILIXIR from MySQL/MariaDB to SQLite and deployed the entire platform to 5 Hugging Face Spaces with GitHub-to-HF auto-sync.
Part 1: SQLite Database Migration
Migration Fixes
4 migration files were modified to remove MySQL-specific syntax:
| File | Problem | Fix |
|---|---|---|
database/migrations/2026_04_20_135553_create_admets_table.php |
useCurrentOnUpdate() β MySQL-only |
Replaced manual timestamps with $table->timestamps() |
database/migrations/2026_04_20_044726_create_screening_results_table.php |
output column not nullable, causing ->change() failure |
Changed json('output') to json('output')->nullable() |
database/migrations/2026_04_20_055149_create_target_lookups_table.php |
Same as above | Same fix |
database/migrations/2026_04_21_155344_add_status_to_screening_tables.php |
Used ->change() which requires MySQL-like ALTER TABLE MODIFY |
Rewritten to only add status column, removed all ->change() calls |
Configuration Changes
config/database.phpβ SQLite connection configured with:journal_mode=wal(Write-Ahead Logging for concurrent reads)busy_timeout=5000(5 second wait on locked DB)transaction_mode=IMMEDIATE(prevents "database is locked" errors)
Environment Files Updated
| File | Before | After |
|---|---|---|
.env.example |
DB_CONNECTION=mysql + host/port/user/pass |
DB_CONNECTION=sqlite, DB_DATABASE=database/ailixir.sqlite |
.env.docker |
Same MySQL config | Same SQLite config |
docker/laravel.env |
Same MySQL config | Same SQLite config |
.gitignore
Added *.sqlite, *.sqlite-wal, *.sqlite-shm to prevent accidental commits of database files.
Part 2: Docker Infrastructure Changes
Dockerfile
- PHP extension:
pdo_mysqlβpdo_sqlite - System packages: Added
libsqlite3-dev,supervisor - Ports: Added
EXPOSE 7860for Hugging Face Spaces - Database directory: Creates
database/directory during build - Removed
COPY docker/laravel.env .env(env vars now come from HF Space secrets)
docker/supervisord.conf (new)
Runs two processes in a single container for HF Spaces:
[program:laravel]βphp artisan serve --host=0.0.0.0 --port=7860[program:queue]βphp artisan queue:work --sleep=3 --tries=3 --timeout=300
docker/entrypoint.sh
- Creates SQLite database file at runtime if it doesn't exist
- Checks
RUN_MODE=hfenvironment variable β if set, starts supervisord instead of the default CMD - Still supports Docker Compose mode (runs migrations, then exec's the passed CMD)
docker-compose.yml
- Removed the entire
mysql:service (was MariaDB 11.4) - Removed
mysql-datavolume - Removed
depends_on: mysqlfromlaravelandqueueservices - Removed
DB_HOST: mysqlenvironment overrides - AI microservice configs remain unchanged
.env.hf (new)
Template file with all HF Space URLs pre-configured for the AI microservice URLs.
Part 3: Hugging Face Spaces Deployment
Spaces Created (5)
| Space | Type | Content |
|---|---|---|
ailixir-api |
Docker (Laravel) | Root repo (excludes ai_apps/, Diagrams/) |
ailixir-admet |
Docker (FastAPI) | ai_apps/ADMIT/admet_inference/ |
ailixir-drug-repurposing |
Docker (FastAPI) | ai_apps/Drug Reporposing/ |
ailixir-chemical-rag |
Docker (FastAPI) | ai_apps/chemical-rag-system/chemical-rag-system/ |
ailixir-generation |
Docker (FastAPI) | ai_apps/generation/ (CPU-only Dockerfile) |
Space Configuration
- All spaces use
cpu-basichardware (free tier) - Port configured to 7860 in each Dockerfile
README.mdwith proper YAML frontmatter added to each space- 15-minute sleep timeout for free tier cost savings
Generation Service Adaptation
The generation service originally required NVIDIA CUDA + GPU. For HF Spaces (CPU-only), a lightweight Dockerfile was created that:
- Uses
python:3.10-slimbase (instead ofnvidia/cuda) - Installs only
fastapi,uvicorn,pydantic,requests,rdkit - Disables AutoDock-GPU and DeepPurpose (CPU-only)
- Provides basic molecule generation and docking scoring
Part 4: GitHub-to-HF Auto-Sync
5 GitHub Actions Workflows
| File | Triggers | Syncs |
|---|---|---|
.github/workflows/sync-hf-backend.yml |
Push to main/develop (excl. ai_apps/) |
Whole repo β ailixir-api |
.github/workflows/sync-hf-admet.yml |
Push to ai_apps/ADMIT/admet_inference/ |
Subdir β ailixir-admet |
.github/workflows/sync-hf-drug-repurposing.yml |
Push to ai_apps/Drug Reporposing/ |
Subdir β ailixir-drug-repurposing |
.github/workflows/sync-hf-chemical-rag.yml |
Push to ai_apps/chemical-rag-system/ |
Subdir β ailixir-chemical-rag |
.github/workflows/sync-hf-generation.yml |
Push to ai_apps/generation/ |
Subdir β ailixir-generation |
Each workflow:
- Clones the target HF Space repo
- Rsyncs the relevant files (excluding
.git,__pycache__, etc.) - Commits with the GitHub commit SHA
- Pushes to HF Space
GitHub Actions Workflow Updates
api-tests.ymlβ Removed MySQL wait loop and health check; removed MySQL log collectionintegration-test.ymlβ Same changes across all 4 job definitions
Part 5: Files Modified/Created Summary
Modified (15 files)
.config/database.php
.env.docker
.env.example
.gitignore
Dockerfile
docker-compose.yml
docker/entrypoint.sh
docker/laravel.env
.github/workflows/api-tests.yml
.github/workflows/integration-test.yml
database/migrations/2026_04_20_044726_create_screening_results_table.php
database/migrations/2026_04_20_055149_create_target_lookups_table.php
database/migrations/2026_04_20_135553_create_admets_table.php
database/migrations/2026_04_21_155344_add_status_to_screening_tables.php
database/ailixir.sqlite (new, empty)
Created (9 files)
.env.hf
docker/supervisord.conf
.github/workflows/sync-hf-backend.yml
.github/workflows/sync-hf-admet.yml
.github/workflows/sync-hf-drug-repurposing.yml
.github/workflows/sync-hf-chemical-rag.yml
.github/workflows/sync-hf-generation.yml
HF_SPACES_GUIDE.md (this file)
CHANGELOG_SQLITE_HF.md (this file)
Architecture Diagram
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GitHub Repository β
β RottenShadow/ β
β AILIXIR_BackEnd β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β Push triggers
βΌ
βββββββββββββββββββββββββββββββ
β GitHub Actions (5 WFs) β
β Auto-sync to HF Spaces β
βββββββββββββββ¬ββββββββββββββββ
β
βββββββββββββββββΌββββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ
βailixir- β βailixir- β βailixir- β βailixir- β βailixir- β
βapi β βadmet β βdrug- β βchemical- β βgenerationβ
β(Laravel) β β(ADMET) β βrepurpos. β βrag β β(Molec. β
βSQLite β β β β β β β βGen.) β
ββββββ¬ββββββ ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ
β
β HTTP proxying to AI microservices
ββββ https://shdwRow-ailixir-admet.hf.space
ββββ https://RottenShadow-ailixir-drug-repurposing.hf.space
ββββ https://RottenShadow-ailixir-chemical-rag.hf.space
ββββ https://shdwRow-ailixir-generation.hf.space
Remaining Steps (Manual)
Set HF tokens as GitHub secrets β Required for auto-sync workflows
- Go to: https://github.com/RottenShadow/AILIXIR_BackEnd/settings/secrets/actions
- Add secret:
HF_TOKEN=YOUR_ROTTENSHADOW_TOKEN - Add secret:
HF_TOKEN_AILIXIR=YOUR_AILIXIR_AI_TEAM_TOKEN
Set backend Space secrets β Required for
ailixir-apito function- Go to: https://huggingface.co/spaces/Ailixir-AI-Team/ailixir-api/settings
- Add all secrets listed in
HF_SPACES_GUIDE.mdsection 3.1 - Minimum:
APP_KEY,RUN_MODE=hf, and all AI service URLs
Wait for builds to complete β Backend Docker image is large (~5GB) and takes 15β45 minutes to build on HF free tier
Verify connectivity β Test the health endpoints and ensure the backend can reach all AI services