Migrate from GitHub to Gitea with CI/CD
Some checks failed
Deploy / deploy (push) Failing after 6m11s
Some checks failed
Deploy / deploy (push) Failing after 6m11s
- Add Gitea Actions workflow for automated frontend and API deployment - Update all raw download URLs from GitHub to Gitea - Remove deprecated Amplify config and GitHub-specific Terraform variables - Clean up commented-out Amplify resources from Terraform - Update documentation to reflect new repository and CI/CD setup
This commit is contained in:
63
CLAUDE.md
63
CLAUDE.md
@@ -7,7 +7,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
Filamenteka is a 3D printing filament inventory management system for tracking Bambu Lab filaments. It consists of:
|
||||
- **Frontend**: Next.js app with React, TypeScript, and Tailwind CSS (static export)
|
||||
- **Backend**: Node.js API server with PostgreSQL database
|
||||
- **Infrastructure**: AWS (Amplify for frontend, EC2 for API, RDS for database)
|
||||
- **Infrastructure**: AWS (CloudFront + S3 for frontend, EC2 for API, RDS for database)
|
||||
|
||||
## Critical Rules
|
||||
|
||||
@@ -20,13 +20,17 @@ Filamenteka is a 3D printing filament inventory management system for tracking B
|
||||
## Common Commands
|
||||
|
||||
```bash
|
||||
# Development
|
||||
# Frontend Development
|
||||
npm run dev # Start Next.js development server (port 3000)
|
||||
npm run build # Build static export to /out directory
|
||||
npm run lint # Run ESLint
|
||||
npm run typecheck # Run TypeScript type checking
|
||||
npm test # Run Jest tests
|
||||
npm run test:watch # Run Jest in watch mode
|
||||
|
||||
# API Development (in /api directory)
|
||||
cd api && npm run dev # Start API server with nodemon (port 4000)
|
||||
|
||||
# Security & Quality
|
||||
npm run security:check # Check for credential leaks (scripts/security/security-check.js)
|
||||
npm run test:build # Test if build succeeds without creating files
|
||||
@@ -67,10 +71,15 @@ scripts/deploy-frontend.sh # Manual frontend deployment helper
|
||||
### Key Components
|
||||
- `FilamentTableV2` - Main inventory display with sorting/filtering
|
||||
- `SaleManager` - Bulk sale management interface
|
||||
- `BulkFilamentPriceEditor` - Bulk price modification interface
|
||||
- `ColorCell` - Smart color rendering with gradient support
|
||||
- `EnhancedFilters` - Advanced filtering system
|
||||
- `ColorRequestForm` - Customer color request form
|
||||
- `ColorRequestModal` - Modal for color requests
|
||||
- `SaleCountdown` - Sale timer display
|
||||
- `MatomoAnalytics` - Analytics tracking
|
||||
- `BackToTop` - Scroll-to-top button
|
||||
- `MaterialBadge`, `ColorSwatch`, `InventoryBadge` - Display components
|
||||
|
||||
### Data Models
|
||||
|
||||
@@ -117,11 +126,15 @@ color_requests: {
|
||||
|
||||
## Deployment
|
||||
|
||||
### Frontend (AWS Amplify)
|
||||
- Automatic deployment on push to main branch
|
||||
- Build output: Static files in `/out` directory
|
||||
- Config: `amplify.yml`, `next.config.js` (output: 'export')
|
||||
- Security check runs during build (amplify.yml preBuild phase)
|
||||
### Frontend (AWS CloudFront + S3)
|
||||
- **Primary Method**: CloudFront distribution with S3 origin
|
||||
- S3 bucket: `filamenteka-frontend`
|
||||
- CloudFront Function: `index-rewrite` for directory-to-index.html routing
|
||||
- Build output: Static files in `/out` directory (Next.js static export)
|
||||
- Config: `next.config.js` (output: 'export'), `terraform/cloudfront-frontend.tf`
|
||||
- Cache: 24h TTL for static assets, GET/HEAD methods cached
|
||||
- OAC (Origin Access Control): S3 public access blocked, CloudFront-only access
|
||||
- **CI/CD**: Gitea Actions workflow (`.gitea/workflows/deploy.yml`) auto-deploys on push to main
|
||||
|
||||
### API Server (EC2)
|
||||
- Deployment via `scripts/deploy-api-update.sh` (uses AWS SSM to push updates)
|
||||
@@ -129,7 +142,7 @@ color_requests: {
|
||||
- Server IP: `3.71.161.51`
|
||||
- Domain: `api.filamenteka.rs`
|
||||
- Service: `node-api` (systemd)
|
||||
- Deploy script pulls from GitHub main branch and restarts service
|
||||
- Deploy script pulls from Gitea main branch and restarts service
|
||||
- IMPORTANT: When deploying API, remember to build for AMD64 Linux (not ARM macOS)
|
||||
|
||||
### Database (RDS PostgreSQL)
|
||||
@@ -170,7 +183,14 @@ color_requests: {
|
||||
- Config: `jest.config.js`, `jest.setup.js`
|
||||
- Coverage goal: >80%
|
||||
- Run with `npm test` or `npm run test:watch`
|
||||
- Tests include: component tests, API integration tests, data consistency checks
|
||||
- Test files include:
|
||||
- `ui-features.test.ts` - UI functionality
|
||||
- `api-integration.test.ts` - API interactions
|
||||
- `no-mock-data.test.ts` - Real data validation (ensures no fake/mock data)
|
||||
- `color-management.test.ts` - Color CRUD operations
|
||||
- `data-consistency.test.ts` - Data validation
|
||||
- `components/*.test.tsx` - Component unit tests
|
||||
- `data/*.test.ts` - Data structure validation
|
||||
|
||||
## Environment Variables
|
||||
|
||||
@@ -225,18 +245,16 @@ Important database constraints:
|
||||
- `filaments.kolicina` has check constraint: `kolicina = refill + spulna`
|
||||
- Always update `colors` table first before adding filaments with new colors
|
||||
|
||||
### API Deployment Workflow
|
||||
1. Make changes to `/api/server.js`
|
||||
2. Commit and push to main branch
|
||||
3. Run `./scripts/deploy-api-update.sh` (uses AWS SSM to pull from GitHub and restart)
|
||||
4. Verify deployment: `curl https://api.filamenteka.rs/` should return `{"status":"ok"}`
|
||||
### Deployment Workflow (Gitea Actions CI/CD)
|
||||
Pushing to `main` triggers `.gitea/workflows/deploy.yml` which auto-detects what changed:
|
||||
- **Frontend changes**: Runs security check, tests, builds Next.js, deploys to S3 with cache headers, invalidates CloudFront
|
||||
- **API changes**: Sends SSM command to EC2 to download `server.js` from Gitea and restart the service
|
||||
- **Both**: If a push touches frontend and API files, both deploy steps run
|
||||
|
||||
### Frontend Deployment Workflow
|
||||
1. Make changes to app/components/pages
|
||||
2. Test locally: `npm run dev`
|
||||
3. Run pre-commit checks: `./scripts/pre-commit.sh`
|
||||
4. Commit and push to main branch
|
||||
5. AWS Amplify automatically builds and deploys (monitors main branch)
|
||||
Manual deployment is still available:
|
||||
1. Frontend: `./scripts/deploy-frontend.sh`
|
||||
2. API: `./scripts/deploy-api-update.sh`
|
||||
3. Verify API: `curl https://api.filamenteka.rs/` should return `{"status":"ok"}`
|
||||
|
||||
## Infrastructure
|
||||
|
||||
@@ -256,4 +274,7 @@ Infrastructure as Code in `/terraform/`:
|
||||
- **API**: EC2 instance running Node.js/Express with systemd service
|
||||
- **Database**: AWS RDS PostgreSQL (eu-central-1)
|
||||
- **DNS**: Cloudflare for api.filamenteka.rs
|
||||
- **Deployment**: AWS Amplify for frontend, SSM for API updates
|
||||
- **CI/CD**: Gitea Actions (`.gitea/workflows/deploy.yml`)
|
||||
- **Deployment**: CloudFront + S3 for frontend, SSM for API updates
|
||||
- **Repository**: `git.demirix.dev/dax/Filamenteka`
|
||||
- **CDN**: CloudFront PriceClass_100 (US, Canada, Europe)
|
||||
Reference in New Issue
Block a user