feat: add CI/CD pipeline, backup system, and deployment automation
Some checks failed
CI/CD Pipeline / Run Tests (pull_request) Has been cancelled
CI/CD Pipeline / Code Quality (pull_request) Has been cancelled
CI Pipeline / Lint Code (pull_request) Has been cancelled
CI Pipeline / Test API Package (pull_request) Has been cancelled
CI Pipeline / Test Web Package (pull_request) Has been cancelled
CI Pipeline / Test Shared Package (pull_request) Has been cancelled
Docker Build & Deploy / Build Docker Images (pull_request) Has been cancelled
E2E Tests / End-to-End Tests (pull_request) Has been cancelled
E2E Tests / E2E Tests (Mobile) (pull_request) Has been cancelled
Security Scanning / NPM Audit (pull_request) Has been cancelled
Security Scanning / Dependency License Check (pull_request) Has been cancelled
Security Scanning / Code Quality Scan (pull_request) Has been cancelled
Security Scanning / Docker Image Security (pull_request) Has been cancelled
CI/CD Pipeline / Build and Push Docker Images (pull_request) Has been cancelled
CI Pipeline / Build All Packages (pull_request) Has been cancelled
CI Pipeline / Generate Coverage Report (pull_request) Has been cancelled
Docker Build & Deploy / Push Docker Images (pull_request) Has been cancelled
Docker Build & Deploy / Deploy to Staging (pull_request) Has been cancelled
Docker Build & Deploy / Deploy to Production (pull_request) Has been cancelled
Security Scanning / Security Summary (pull_request) Has been cancelled

## Summary
- Add complete CI/CD pipeline with Gitea Actions for automated testing, building, and deployment
- Implement backup and restore system with full database and file backup to ZIP
- Add deployment automation with webhook receiver and systemd service
- Enhance recipe editing UI with improved ingredient parsing and cooking mode features
- Add comprehensive documentation for CI/CD, deployment, and backup features

## CI/CD Pipeline
- New workflow in .gitea/workflows/ci-cd.yml with test, build, and deploy stages
- Automated Docker image building and pushing to registry
- Webhook-triggered deployments to production servers

## Backup & Restore
- New backup service with ZIP creation including database dump and uploads
- REST API endpoints for create, list, download, restore, and delete operations
- Configurable backup path via BACKUP_PATH environment variable

## Deployment
- Automated deployment scripts (deploy.sh, manual-deploy.sh)
- Webhook receiver with systemd service for deployment triggers
- Environment configuration template (.env.deploy.example)

## Documentation
- docs/CI-CD-SETUP.md - Complete CI/CD pipeline setup guide
- docs/DEPLOYMENT-QUICK-START.md - Quick deployment reference
- docs/BACKUP.md - Backup and restore documentation
- docs/REMOTE_DATABASE.md - Remote database configuration guide
- scripts/README.md - Deployment scripts documentation

## Web Improvements
- Enhanced ingredient parser with better unit and quantity detection
- Improved recipe editing interface with unified edit experience
- Better cooking mode functionality
- Updated dependencies in package.json

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-08 05:04:39 +00:00
parent 35a3088c30
commit d1156833a2
24 changed files with 3543 additions and 229 deletions

View File

@@ -47,6 +47,11 @@ npm run build
# Lint all packages
npm run lint
# Testing
npm test # Run all unit tests
npm run test:e2e # Run E2E tests with Playwright
npm run test:e2e:ui # Run E2E tests with Playwright UI
# Docker commands
npm run docker:up # Start all services (PostgreSQL, API, web)
npm run docker:down # Stop all services
@@ -93,6 +98,7 @@ NODE_ENV=development
DATABASE_URL=postgresql://basil:basil@localhost:5432/basil?schema=public
STORAGE_TYPE=local # or 's3'
LOCAL_STORAGE_PATH=./uploads
BACKUP_PATH=./backups
CORS_ORIGIN=http://localhost:5173
```
@@ -104,6 +110,11 @@ S3_ACCESS_KEY_ID=your-key
S3_SECRET_ACCESS_KEY=your-secret
```
For remote PostgreSQL database, update:
```
DATABASE_URL=postgresql://username:password@remote-host:5432/basil?schema=public
```
## Key Features
### Recipe Import from URL
@@ -125,6 +136,13 @@ S3_SECRET_ACCESS_KEY=your-secret
- S3 storage: Placeholder for AWS SDK implementation
- Easy to extend for other storage providers
### Backup & Restore
- Complete data backup to single ZIP file including database and uploaded files
- Backup service in `packages/api/src/services/backup.service.ts`
- REST API for creating, listing, downloading, and restoring backups
- Automatic backup of all recipes, cookbooks, tags, and relationships
- Configurable backup storage location via `BACKUP_PATH` environment variable
## Adding New Features
### Adding a New API Endpoint
@@ -161,6 +179,22 @@ This starts:
Persistent volumes:
- `postgres_data` - Database storage
- `uploads_data` - Uploaded images
- `backups_data` - Backup files
### Using a Remote Database
To use a remote PostgreSQL database instead of the local Docker container:
1. Set the `DATABASE_URL` environment variable to point to your remote database
2. Update `docker-compose.yml` to pass the environment variable or create a `.env` file in the root
3. Optionally, remove or comment out the `postgres` service and its dependency in `docker-compose.yml`
Example `.env` file in project root:
```
DATABASE_URL=postgresql://username:password@remote-host:5432/basil?schema=public
```
The docker-compose.yml is configured to use `${DATABASE_URL:-default}` which will use the environment variable if set, or fall back to the local postgres container.
## API Reference
@@ -178,6 +212,13 @@ Persistent volumes:
- `search` - Search in title/description
- `cuisine`, `category` - Filter by cuisine or category
**Backups:**
- `POST /api/backup` - Create a new backup (returns backup metadata)
- `GET /api/backup` - List all available backups
- `GET /api/backup/:filename` - Download a specific backup file
- `POST /api/backup/restore` - Restore from backup (accepts file upload or existing filename)
- `DELETE /api/backup/:filename` - Delete a backup file
## Important Implementation Details
### Prisma Relations
@@ -200,3 +241,32 @@ Persistent volumes:
- Root `package.json` defines npm workspaces
- Packages can reference each other (e.g., `@basil/shared`)
- Must rebuild shared package when types change for other packages to see updates
## CI/CD and Deployment
Basil includes a complete CI/CD pipeline with Gitea Actions for automated testing, building, and deployment.
**Quick Start:**
- See [CI/CD Setup Guide](docs/CI-CD-SETUP.md) for full documentation
- See [Deployment Quick Start](docs/DEPLOYMENT-QUICK-START.md) for quick reference
**Pipeline Overview:**
1. **Test Stage**: Runs unit tests (Vitest) and E2E tests (Playwright)
2. **Build Stage**: Builds Docker images for API and Web (main branch only)
3. **Deploy Stage**: Pushes images to registry and triggers webhook deployment
**Deployment Options:**
- **Automatic**: Push to main branch triggers full CI/CD pipeline
- **Manual**: Run `./scripts/manual-deploy.sh` for interactive deployment
- **Webhook**: Systemd service listens for deployment triggers
**Key Files:**
- `.gitea/workflows/ci-cd.yml` - Main CI/CD workflow
- `scripts/deploy.sh` - Deployment script
- `scripts/webhook-receiver.sh` - Webhook server
- `.env.deploy.example` - Deployment configuration template
**Required Secrets (Gitea):**
- `DOCKER_USERNAME` - Docker Hub username
- `DOCKER_PASSWORD` - Docker Hub access token
- `DEPLOY_WEBHOOK_URL` - Webhook endpoint for deployments