Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
.next
.git
storage
*.log
.env
.env.local
.env*.local
npm-debug.log*
53 changes: 53 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# ----------------------------------------------------------------------------
# ClipPilot configuration
# Copy this file to `.env.local` and adjust as needed. All values are optional;
# sensible defaults are applied in src/lib/config.ts.
# ----------------------------------------------------------------------------

# Maximum upload size in megabytes.
MAX_UPLOAD_MB=200

# Absolute or relative path to the storage root used for uploads + outputs.
# Defaults to "<project>/storage".
STORAGE_DIR=./storage

# Path to the ffmpeg / ffprobe binaries. Override if they are not on your PATH.
FFMPEG_PATH=ffmpeg
FFPROBE_PATH=ffprobe

# How long (in minutes) finished jobs and their files are kept before the
# automatic sweep is allowed to remove them. Set to 0 to disable auto-sweep.
JOB_TTL_MINUTES=180

# ----------------------------------------------------------------------------
# Using ClipPilot as a headless API (optional — both default to "open")
# ----------------------------------------------------------------------------

# When set, mutating API routes require: Authorization: Bearer <API_TOKEN>.
# Leave blank for open local/self-hosted use.
API_TOKEN=

# CORS allow-list for calling the API from another origin. Comma-separated,
# or "*" for any. Leave blank for same-origin only.
# Example: CORS_ORIGIN=https://my-app.example.com,http://localhost:5173
CORS_ORIGIN=

# ----------------------------------------------------------------------------
# Supabase (optional) — files in Supabase Storage, jobs in Supabase Postgres.
# Leave blank to use the zero-config local filesystem + in-memory store.
# When both URL and the service-role key are set, ClipPilot auto-switches to
# Supabase for storage AND jobs. Run supabase/migrations/0001_jobs.sql first.
# ----------------------------------------------------------------------------

SUPABASE_URL=
# Service-role key — SERVER ONLY, never expose to the browser. Found in
# Supabase dashboard → Project Settings → API.
SUPABASE_SERVICE_ROLE_KEY=
# Private storage bucket name (created automatically if missing).
SUPABASE_BUCKET=media
# How long signed preview/download URLs stay valid (seconds).
SIGNED_URL_TTL=3600

# Force a backend regardless of auto-detection: "local" or "supabase".
# STORAGE_BACKEND=
# JOBS_BACKEND=
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["next/core-web-vitals"],
"rules": {
"@next/next/no-img-element": "off"
}
}
11 changes: 11 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Files not uploaded to Cloud Build when deploying with `gcloud run deploy --source .`
.git
.gitignore
node_modules
.next
storage
*.log
.env
.env.local
.env*.local
README.md
63 changes: 63 additions & 0 deletions .github/workflows/deploy-cloudrun.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Deploy to Cloud Run

# Manual trigger only (Actions tab → "Deploy to Cloud Run" → Run workflow),
# so the dev branch never auto-deploys or shows red checks before secrets exist.
on:
workflow_dispatch:
inputs:
region:
description: "Cloud Run region"
default: "europe-west1"
required: true

# Required repository secrets (Settings → Secrets and variables → Actions):
# GCP_PROJECT your GCP project id
# GCP_SA_KEY a service-account JSON key with Run Admin,
# Cloud Build Editor, Artifact Registry Writer,
# Service Account User (or use Workload Identity)
# SUPABASE_URL your Supabase project URL
# SUPABASE_SERVICE_ROLE_KEY Supabase service-role key (server only)
jobs:
deploy:
runs-on: ubuntu-latest
env:
DB_URL: ${{ secrets.SUPABASE_DB_URL }}
steps:
- uses: actions/checkout@v4

# Apply DB migrations first (no-op if SUPABASE_DB_URL isn't set).
- name: Apply Supabase migrations
if: ${{ env.DB_URL != '' }}
run: |
set -euo pipefail
sudo apt-get update && sudo apt-get install -y --no-install-recommends postgresql-client
for f in $(ls supabase/migrations/*.sql | sort); do
echo "Applying $f"; psql "$DB_URL" -v ON_ERROR_STOP=1 -f "$f"
done

- id: auth
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}

- uses: google-github-actions/setup-gcloud@v2

- name: Deploy
run: |
gcloud run deploy clippilot \
--project "${{ secrets.GCP_PROJECT }}" \
--region "${{ github.event.inputs.region }}" \
--source . \
--allow-unauthenticated \
--memory 2Gi --cpu 2 --timeout 600 --concurrency 2 \
--max-instances 3 --no-cpu-throttling \
--set-env-vars "STORAGE_DIR=/tmp/clippilot" \
--set-env-vars "SUPABASE_URL=${{ secrets.SUPABASE_URL }}" \
--set-env-vars "SUPABASE_SERVICE_ROLE_KEY=${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}"

- name: Show URL
run: |
gcloud run services describe clippilot \
--project "${{ secrets.GCP_PROJECT }}" \
--region "${{ github.event.inputs.region }}" \
--format 'value(status.url)'
47 changes: 47 additions & 0 deletions .github/workflows/supabase-migrate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Apply Supabase migrations

# Runs automatically whenever a migration file changes (and can be run manually).
# It is a safe no-op until the SUPABASE_DB_URL secret is set, so it never fails
# noisily before you've configured it. Migrations are idempotent
# (CREATE ... IF NOT EXISTS), so re-runs are harmless.
on:
push:
branches:
- main
- claude/clipforge-mvp-build-epq9io
paths:
- "supabase/migrations/**"
- ".github/workflows/supabase-migrate.yml"
workflow_dispatch:

jobs:
migrate:
runs-on: ubuntu-latest
env:
# Supabase → Project Settings → Database → Connection string (URI).
DB_URL: ${{ secrets.SUPABASE_DB_URL }}
steps:
- uses: actions/checkout@v4

- name: Skip notice
if: ${{ env.DB_URL == '' }}
run: echo "SUPABASE_DB_URL secret not set — skipping migrations."

- name: Install psql
if: ${{ env.DB_URL != '' }}
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends postgresql-client

- name: Apply migrations
if: ${{ env.DB_URL != '' }}
run: |
set -euo pipefail
shopt -s nullglob
files=(supabase/migrations/*.sql)
if [ ${#files[@]} -eq 0 ]; then
echo "No migration files found."; exit 0
fi
for f in $(printf '%s\n' "${files[@]}" | sort); do
echo "Applying $f"
psql "$DB_URL" -v ON_ERROR_STOP=1 -f "$f"
done
echo "Migrations applied."
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# dependencies
/node_modules
/.pnp
.pnp.js

# next.js
/.next/
/out/
next-env.d.ts

# production
/build

# misc
.DS_Store
*.pem
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# env
.env
.env.local
.env*.local

# local storage (uploaded + processed media) — keep the folder, ignore contents
/storage/*
!/storage/.gitkeep

# editor
.vscode/*
!.vscode/extensions.json
.idea
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"singleQuote": false,
"trailingComma": "all",
"printWidth": 90,
"plugins": ["prettier-plugin-tailwindcss"]
}
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ---- Builder ----------------------------------------------------------------
FROM node:20-bookworm-slim AS builder
WORKDIR /app

COPY package.json package-lock.json ./
RUN npm ci

COPY . .
RUN npm run build

# ---- Runner -----------------------------------------------------------------
FROM node:20-bookworm-slim AS runner
WORKDIR /app

# FFmpeg (with vid.stab) + ffprobe are required at runtime.
RUN apt-get update \
&& apt-get install -y --no-install-recommends ffmpeg \
&& rm -rf /var/lib/apt/lists/*

ENV NODE_ENV=production
ENV PORT=3000
# Store media on a mounted volume by default.
ENV STORAGE_DIR=/data/storage

# Next.js standalone output: server + only the deps it actually needs.
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public

RUN mkdir -p /data/storage
VOLUME ["/data/storage"]

EXPOSE 3000
CMD ["node", "server.js"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 ClipPilot

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading