Skip to content

Commit 1f70358

Browse files
committed
Initial Commit
1 parent 84218d3 commit 1f70358

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+22137
-3
lines changed

.env.example

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# 🎬 FFprobe API v2.0 - Configuration Template
2+
# Copy this file to .env and modify values for your environment
3+
4+
# ================================
5+
# 🔐 SECURITY (REQUIRED)
6+
# ================================
7+
# Change these values for production!
8+
API_KEY=your-super-secret-api-key-change-in-production
9+
JWT_SECRET=your-super-secret-jwt-key-change-in-production
10+
11+
# ================================
12+
# 🌐 API CONFIGURATION
13+
# ================================
14+
API_PORT=8080
15+
LOG_LEVEL=info
16+
ENABLE_AUTH=true
17+
ENABLE_RATE_LIMIT=true
18+
ENABLE_CSRF=false
19+
20+
# Rate Limiting
21+
RATE_LIMIT_PER_MINUTE=60
22+
RATE_LIMIT_PER_HOUR=1000
23+
RATE_LIMIT_PER_DAY=10000
24+
25+
# ================================
26+
# 🗄️ DATABASE CONFIGURATION
27+
# ================================
28+
POSTGRES_HOST=localhost
29+
POSTGRES_PORT=5432
30+
POSTGRES_DB=ffprobe_api
31+
POSTGRES_USER=ffprobe
32+
POSTGRES_PASSWORD=secure_password_here
33+
POSTGRES_SSL_MODE=disable
34+
35+
# ================================
36+
# 📦 REDIS CONFIGURATION
37+
# ================================
38+
REDIS_HOST=localhost
39+
REDIS_PORT=6379
40+
REDIS_PASSWORD=redis_password_here
41+
REDIS_DB=0
42+
43+
# ================================
44+
# 🎥 FFMPEG CONFIGURATION
45+
# ================================
46+
FFMPEG_PATH=/usr/local/bin/ffmpeg
47+
FFPROBE_PATH=/usr/local/bin/ffprobe
48+
VMAF_MODEL_PATH=/usr/local/share/vmaf
49+
50+
# File Upload Limits
51+
MAX_FILE_SIZE=53687091200 # 50GB in bytes
52+
UPLOAD_DIR=/app/uploads
53+
REPORTS_DIR=/app/reports
54+
55+
# ================================
56+
# ☁️ CLOUD STORAGE (Choose One)
57+
# ================================
58+
# Options: local, s3, gcs, azure
59+
STORAGE_PROVIDER=local
60+
STORAGE_BUCKET=./storage
61+
STORAGE_REGION=us-east-1
62+
STORAGE_ACCESS_KEY=your-storage-access-key
63+
STORAGE_SECRET_KEY=your-storage-secret-key
64+
STORAGE_ENDPOINT=
65+
STORAGE_USE_SSL=true
66+
STORAGE_BASE_URL=
67+
68+
# AWS S3 Configuration
69+
AWS_ACCESS_KEY_ID=your-aws-access-key
70+
AWS_SECRET_ACCESS_KEY=your-aws-secret-key
71+
AWS_REGION=us-east-1
72+
73+
# Google Cloud Storage Configuration
74+
GCP_SERVICE_ACCOUNT_JSON={"type":"service_account","project_id":"your-project"}
75+
76+
# Azure Blob Storage Configuration
77+
AZURE_STORAGE_ACCOUNT=your-storage-account
78+
AZURE_STORAGE_KEY=your-storage-key
79+
80+
# ================================
81+
# 🤖 AI/LLM CONFIGURATION (Optional)
82+
# ================================
83+
# Local LLM Model Path (for privacy-focused deployments)
84+
LLM_MODEL_PATH=/models/phi-3-mini-4k-instruct-q4.gguf
85+
86+
# OpenRouter API (for cloud-based AI)
87+
OPENROUTER_API_KEY=your-openrouter-api-key
88+
89+
# ================================
90+
# 📊 MONITORING & OBSERVABILITY
91+
# ================================
92+
ENABLE_METRICS=true
93+
PROMETHEUS_PORT=9090
94+
GRAFANA_PORT=3000
95+
96+
# ================================
97+
# 🔒 SECURITY HEADERS & CORS
98+
# ================================
99+
ALLOWED_ORIGINS=http://localhost:3000,http://localhost:8080
100+
TRUSTED_PROXIES=127.0.0.1,::1
101+
102+
# ================================
103+
# 🛠️ DEVELOPMENT CONFIGURATION
104+
# ================================
105+
GO_ENV=development
106+
107+
# Docker Compose Override
108+
# For development: docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
109+
# For production: docker-compose -f docker-compose.yml -f docker-compose.prod.yml up
110+
111+
# ================================
112+
# 📋 PRODUCTION CHECKLIST
113+
# ================================
114+
# Before deploying to production:
115+
# [ ] Change API_KEY and JWT_SECRET
116+
# [ ] Set strong database passwords
117+
# [ ] Configure cloud storage credentials
118+
# [ ] Set ALLOWED_ORIGINS to your domain
119+
# [ ] Enable HTTPS/TLS termination
120+
# [ ] Configure proper firewall rules
121+
# [ ] Review rate limiting settings
122+
# [ ] Set up monitoring and alerts

.github/workflows/ci.yml

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
env:
10+
GO_VERSION: "1.21"
11+
POSTGRES_VERSION: "15"
12+
REDIS_VERSION: "7"
13+
14+
jobs:
15+
test:
16+
name: Test
17+
runs-on: ubuntu-latest
18+
19+
services:
20+
postgres:
21+
image: postgres:15
22+
env:
23+
POSTGRES_PASSWORD: postgres
24+
POSTGRES_DB: ffprobe_api_test
25+
options: >-
26+
--health-cmd pg_isready
27+
--health-interval 10s
28+
--health-timeout 5s
29+
--health-retries 5
30+
ports:
31+
- 5432:5432
32+
33+
redis:
34+
image: redis:7
35+
options: >-
36+
--health-cmd "redis-cli ping"
37+
--health-interval 10s
38+
--health-timeout 5s
39+
--health-retries 5
40+
ports:
41+
- 6379:6379
42+
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
47+
- name: Set up Go
48+
uses: actions/setup-go@v4
49+
with:
50+
go-version: ${{ env.GO_VERSION }}
51+
52+
- name: Cache Go modules
53+
uses: actions/cache@v3
54+
with:
55+
path: ~/go/pkg/mod
56+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
57+
restore-keys: |
58+
${{ runner.os }}-go-
59+
60+
- name: Install dependencies
61+
run: |
62+
sudo apt-get update
63+
sudo apt-get install -y ffmpeg
64+
go mod download
65+
66+
- name: Run tests
67+
run: make test
68+
env:
69+
POSTGRES_HOST: localhost
70+
POSTGRES_PORT: 5432
71+
POSTGRES_DB: ffprobe_api_test
72+
POSTGRES_USER: postgres
73+
POSTGRES_PASSWORD: postgres
74+
REDIS_HOST: localhost
75+
REDIS_PORT: 6379
76+
77+
- name: Run integration tests
78+
run: make test-integration
79+
env:
80+
POSTGRES_HOST: localhost
81+
POSTGRES_PORT: 5432
82+
POSTGRES_DB: ffprobe_api_test
83+
POSTGRES_USER: postgres
84+
POSTGRES_PASSWORD: postgres
85+
REDIS_HOST: localhost
86+
REDIS_PORT: 6379
87+
88+
- name: Generate coverage report
89+
run: make test-coverage
90+
91+
- name: Upload coverage to Codecov
92+
uses: codecov/codecov-action@v3
93+
with:
94+
file: ./coverage.out
95+
flags: unittests
96+
name: codecov-umbrella
97+
98+
lint:
99+
name: Lint
100+
runs-on: ubuntu-latest
101+
102+
steps:
103+
- name: Checkout code
104+
uses: actions/checkout@v4
105+
106+
- name: Set up Go
107+
uses: actions/setup-go@v4
108+
with:
109+
go-version: ${{ env.GO_VERSION }}
110+
111+
- name: Run golangci-lint
112+
uses: golangci/golangci-lint-action@v3
113+
with:
114+
version: latest
115+
args: --timeout=5m
116+
117+
security:
118+
name: Security Scan
119+
runs-on: ubuntu-latest
120+
121+
steps:
122+
- name: Checkout code
123+
uses: actions/checkout@v4
124+
125+
- name: Set up Go
126+
uses: actions/setup-go@v4
127+
with:
128+
go-version: ${{ env.GO_VERSION }}
129+
130+
- name: Run Gosec Security Scanner
131+
uses: securecodewarrior/github-action-gosec@master
132+
with:
133+
args: './...'
134+
135+
- name: Run Trivy vulnerability scanner
136+
uses: aquasecurity/trivy-action@master
137+
with:
138+
scan-type: 'fs'
139+
scan-ref: '.'
140+
141+
build:
142+
name: Build
143+
runs-on: ubuntu-latest
144+
needs: [test, lint, security]
145+
146+
steps:
147+
- name: Checkout code
148+
uses: actions/checkout@v4
149+
150+
- name: Set up Go
151+
uses: actions/setup-go@v4
152+
with:
153+
go-version: ${{ env.GO_VERSION }}
154+
155+
- name: Build application
156+
run: make build
157+
158+
- name: Upload build artifacts
159+
uses: actions/upload-artifact@v3
160+
with:
161+
name: ffprobe-api-binary
162+
path: bin/ffprobe-api
163+
164+
docker:
165+
name: Docker Build
166+
runs-on: ubuntu-latest
167+
needs: [test, lint, security]
168+
if: github.event_name == 'push'
169+
170+
steps:
171+
- name: Checkout code
172+
uses: actions/checkout@v4
173+
174+
- name: Set up Docker Buildx
175+
uses: docker/setup-buildx-action@v3
176+
177+
- name: Login to Docker Hub
178+
uses: docker/login-action@v3
179+
with:
180+
username: ${{ secrets.DOCKER_USERNAME }}
181+
password: ${{ secrets.DOCKER_PASSWORD }}
182+
183+
- name: Extract metadata
184+
id: meta
185+
uses: docker/metadata-action@v5
186+
with:
187+
images: rendiffdev/ffprobe-api
188+
tags: |
189+
type=ref,event=branch
190+
type=ref,event=pr
191+
type=sha,prefix={{branch}}-
192+
type=raw,value=latest,enable={{is_default_branch}}
193+
194+
- name: Build and push Docker image
195+
uses: docker/build-push-action@v5
196+
with:
197+
context: .
198+
platforms: linux/amd64,linux/arm64
199+
push: true
200+
tags: ${{ steps.meta.outputs.tags }}
201+
labels: ${{ steps.meta.outputs.labels }}
202+
cache-from: type=gha
203+
cache-to: type=gha,mode=max
204+
205+
release:
206+
name: Release
207+
runs-on: ubuntu-latest
208+
needs: [build, docker]
209+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
210+
211+
steps:
212+
- name: Checkout code
213+
uses: actions/checkout@v4
214+
with:
215+
fetch-depth: 0
216+
217+
- name: Set up Go
218+
uses: actions/setup-go@v4
219+
with:
220+
go-version: ${{ env.GO_VERSION }}
221+
222+
- name: Run GoReleaser
223+
uses: goreleaser/goreleaser-action@v5
224+
with:
225+
distribution: goreleaser
226+
version: latest
227+
args: release --rm-dist
228+
env:
229+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)