Skip to content

Commit d9b0450

Browse files
amosttAygentic
andcommitted
feat(infra): Docker, CI & legacy cleanup for Supabase/Clerk migration [AYG-72]
Remove all legacy SQLModel/PostgreSQL/JWT/email code, tests, Alembic migrations, and dependencies. Rewrite Dockerfile as multi-stage build with OCI labels, non-root user, and Python healthcheck. Replace test-backend.yml + test-docker-compose.yml with unified ci.yml (lint → test → docker-build → alls-green). Add WITH_UI compose profile gating frontend service. Create .env.example documenting all modern environment variables. Update deploy workflows and prestart script for Supabase-managed infrastructure. - Delete 44 legacy files (models, routes, CRUD, JWT auth, email templates, Alembic migrations, legacy tests) - Remove 7 legacy dependencies (sqlmodel, alembic, psycopg, pyjwt, pwdlib, emails, jinja2) - Rewrite backend/Dockerfile with builder+runtime stages, uv, non-root user - Rewrite compose.yml removing db/adminer/prestart/mailcatcher services - Add profiles: ["ui"] on frontend service for WITH_UI flag - Create .github/workflows/ci.yml with frontend gating via hashFiles - Update deploy-staging.yml and deploy-production.yml for modern env vars - Create .env.example with sectioned variable documentation 198 tests passing | Lint clean | 0 new mypy errors Fixes AYG-72 Related to AYG-64 🤖 Generated by Aygentic Co-Authored-By: Aygentic <noreply@aygentic.com>
1 parent fbbf818 commit d9b0450

62 files changed

Lines changed: 271 additions & 3720 deletions

Some content is hidden

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

.env.example

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# ─── Domain & Routing ────────────────────────────────────────────────────────
2+
# Domain used by Traefik for routing and TLS certificates
3+
DOMAIN=localhost
4+
# STACK_NAME=app # Docker stack name prefix
5+
6+
# ─── Environment ─────────────────────────────────────────────────────────────
7+
# Options: local | staging | production
8+
ENVIRONMENT=local
9+
10+
# ─── Supabase (required) ──────────────────────────────────────────────────────
11+
SUPABASE_URL=https://your-project.supabase.co
12+
SUPABASE_SERVICE_KEY=your-supabase-service-key
13+
14+
# ─── Clerk Authentication (required) ─────────────────────────────────────────
15+
CLERK_SECRET_KEY=sk_test_your-clerk-secret-key
16+
# CLERK_JWKS_URL= # Optional: override the Clerk JWKS endpoint URL
17+
# CLERK_AUTHORIZED_PARTIES= # Optional: comma-separated authorized parties
18+
19+
# ─── Backend ──────────────────────────────────────────────────────────────────
20+
SERVICE_NAME=my-service
21+
SERVICE_VERSION=0.1.0
22+
BACKEND_CORS_ORIGINS=http://localhost,http://localhost:5173
23+
# API_V1_STR=/api/v1 # Default: /api/v1
24+
# HTTP_CLIENT_TIMEOUT=30 # HTTP client timeout in seconds
25+
# HTTP_CLIENT_MAX_RETRIES=3 # HTTP client retry count
26+
27+
# ─── Logging ──────────────────────────────────────────────────────────────────
28+
# LOG_LEVEL options: DEBUG | INFO | WARNING | ERROR
29+
LOG_LEVEL=INFO
30+
# LOG_FORMAT options: json | console
31+
LOG_FORMAT=json
32+
33+
# ─── Frontend ─────────────────────────────────────────────────────────────────
34+
# WITH_UI=false # Set to true to enable frontend services
35+
DOCKER_IMAGE_BACKEND=backend
36+
DOCKER_IMAGE_FRONTEND=frontend
37+
# TAG=latest # Docker image tag
38+
39+
# ─── Observability ────────────────────────────────────────────────────────────
40+
SENTRY_DSN=
41+
# GIT_COMMIT= # Set automatically by CI (git commit SHA)
42+
# BUILD_TIME= # Set automatically by CI (build timestamp)

.github/workflows/ci.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types:
9+
- opened
10+
- synchronize
11+
12+
jobs:
13+
backend-lint:
14+
name: Backend Lint & Type Check
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v6
19+
- name: Set up Python
20+
uses: actions/setup-python@v6
21+
with:
22+
python-version: "3.10"
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v7
25+
- name: Install dependencies
26+
run: uv sync
27+
working-directory: backend
28+
- name: Ruff check
29+
run: uv run ruff check backend/app/
30+
working-directory: backend
31+
- name: Ruff format check
32+
run: uv run ruff format --check backend/app/
33+
working-directory: backend
34+
- name: Mypy
35+
run: uv run mypy backend/app
36+
working-directory: backend
37+
38+
backend-test:
39+
name: Backend Tests
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v6
44+
- name: Set up Python
45+
uses: actions/setup-python@v6
46+
with:
47+
python-version: "3.10"
48+
- name: Install uv
49+
uses: astral-sh/setup-uv@v7
50+
- name: Install dependencies
51+
run: uv sync
52+
working-directory: backend
53+
- name: Run tests
54+
run: uv run coverage run -m pytest tests/unit/ tests/integration/ -v
55+
working-directory: backend
56+
env:
57+
SUPABASE_URL: "http://localhost:54321"
58+
SUPABASE_SERVICE_KEY: "test-service-key"
59+
CLERK_SECRET_KEY: "test-clerk-key"
60+
ENVIRONMENT: "local"
61+
- name: Coverage report
62+
run: uv run coverage report --fail-under=90
63+
working-directory: backend
64+
- name: Coverage HTML
65+
run: uv run coverage html
66+
working-directory: backend
67+
- name: Store coverage files
68+
uses: actions/upload-artifact@v6
69+
with:
70+
name: coverage-html
71+
path: backend/htmlcov
72+
include-hidden-files: true
73+
74+
frontend-ci:
75+
name: Frontend Lint & Build
76+
runs-on: ubuntu-latest
77+
# Only run if frontend/ directory exists
78+
if: hashFiles('frontend/package.json') != ''
79+
steps:
80+
- name: Checkout
81+
uses: actions/checkout@v6
82+
- name: Setup Bun
83+
uses: oven-sh/setup-bun@v2
84+
- name: Install dependencies
85+
run: bun ci
86+
working-directory: frontend
87+
- name: Lint
88+
run: bun run lint
89+
working-directory: frontend
90+
- name: Build
91+
run: bun run build
92+
working-directory: frontend
93+
94+
docker-build:
95+
name: Docker Build
96+
runs-on: ubuntu-latest
97+
needs: [backend-lint, backend-test]
98+
steps:
99+
- name: Checkout
100+
uses: actions/checkout@v6
101+
- name: Build backend image
102+
run: docker build -t test-backend backend/ -f backend/Dockerfile
103+
104+
# Branch protection gate
105+
alls-green:
106+
name: CI Complete
107+
runs-on: ubuntu-latest
108+
needs: [backend-lint, backend-test, docker-build]
109+
if: always()
110+
steps:
111+
- name: Check all jobs
112+
uses: re-actors/alls-green@release/v1
113+
with:
114+
jobs: ${{ toJSON(needs) }}

.github/workflows/deploy-production.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77

88
jobs:
99
deploy:
10-
# Do not deploy in the main repository, only in user projects
1110
if: github.repository_owner != 'fastapi'
1211
runs-on:
1312
- self-hosted
@@ -16,15 +15,14 @@ jobs:
1615
ENVIRONMENT: production
1716
DOMAIN: ${{ secrets.DOMAIN_PRODUCTION }}
1817
STACK_NAME: ${{ secrets.STACK_NAME_PRODUCTION }}
19-
SECRET_KEY: ${{ secrets.SECRET_KEY }}
20-
FIRST_SUPERUSER: ${{ secrets.FIRST_SUPERUSER }}
21-
FIRST_SUPERUSER_PASSWORD: ${{ secrets.FIRST_SUPERUSER_PASSWORD }}
22-
SMTP_HOST: ${{ secrets.SMTP_HOST }}
23-
SMTP_USER: ${{ secrets.SMTP_USER }}
24-
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
25-
EMAILS_FROM_EMAIL: ${{ secrets.EMAILS_FROM_EMAIL }}
26-
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
18+
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
19+
SUPABASE_SERVICE_KEY: ${{ secrets.SUPABASE_SERVICE_KEY }}
20+
CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
21+
BACKEND_CORS_ORIGINS: ${{ secrets.BACKEND_CORS_ORIGINS }}
2722
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
23+
SERVICE_NAME: ${{ secrets.SERVICE_NAME }}
24+
DOCKER_IMAGE_BACKEND: ${{ secrets.DOCKER_IMAGE_BACKEND }}
25+
DOCKER_IMAGE_FRONTEND: ${{ secrets.DOCKER_IMAGE_FRONTEND }}
2826
steps:
2927
- name: Checkout
3028
uses: actions/checkout@v6

.github/workflows/deploy-staging.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77

88
jobs:
99
deploy:
10-
# Do not deploy in the main repository, only in user projects
1110
if: github.repository_owner != 'fastapi'
1211
runs-on:
1312
- self-hosted
@@ -16,15 +15,14 @@ jobs:
1615
ENVIRONMENT: staging
1716
DOMAIN: ${{ secrets.DOMAIN_STAGING }}
1817
STACK_NAME: ${{ secrets.STACK_NAME_STAGING }}
19-
SECRET_KEY: ${{ secrets.SECRET_KEY }}
20-
FIRST_SUPERUSER: ${{ secrets.FIRST_SUPERUSER }}
21-
FIRST_SUPERUSER_PASSWORD: ${{ secrets.FIRST_SUPERUSER_PASSWORD }}
22-
SMTP_HOST: ${{ secrets.SMTP_HOST }}
23-
SMTP_USER: ${{ secrets.SMTP_USER }}
24-
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }}
25-
EMAILS_FROM_EMAIL: ${{ secrets.EMAILS_FROM_EMAIL }}
26-
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
18+
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
19+
SUPABASE_SERVICE_KEY: ${{ secrets.SUPABASE_SERVICE_KEY }}
20+
CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
21+
BACKEND_CORS_ORIGINS: ${{ secrets.BACKEND_CORS_ORIGINS }}
2722
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
23+
SERVICE_NAME: ${{ secrets.SERVICE_NAME }}
24+
DOCKER_IMAGE_BACKEND: ${{ secrets.DOCKER_IMAGE_BACKEND }}
25+
DOCKER_IMAGE_FRONTEND: ${{ secrets.DOCKER_IMAGE_FRONTEND }}
2826
steps:
2927
- name: Checkout
3028
uses: actions/checkout@v6

.github/workflows/smokeshow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Smokeshow
22

33
on:
44
workflow_run:
5-
workflows: [Test Backend]
5+
workflows: [CI]
66
types: [completed]
77

88
jobs:

.github/workflows/test-backend.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/test-docker-compose.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ repos:
1212
- id: end-of-file-fixer
1313
exclude: |
1414
(?x)^(
15-
frontend/src/client/.*|
16-
backend/app/email-templates/build/.*
15+
frontend/src/client/.*
1716
)$
1817
- id: trailing-whitespace
1918
exclude: ^frontend/src/client/.*
@@ -46,10 +45,3 @@ repos:
4645
require_serial: true
4746
language: unsupported
4847
pass_filenames: false
49-
50-
- id: generate-frontend-sdk
51-
name: Generate Frontend SDK
52-
entry: bash ./scripts/generate-client.sh
53-
pass_filenames: false
54-
language: unsupported
55-
files: ^backend/.*$|^scripts/generate-client\.sh$

0 commit comments

Comments
 (0)