Skip to content

Commit

Permalink
Merge branch 'dev' into self-host
Browse files Browse the repository at this point in the history
* dev:
  Merge seed scripts (stack-auth#354)
  chore: update package versions
  added codegen
  disabled fern comments
  Self-host docker (stack-auth#353)

# Conflicts:
#	.dockerignore
#	.github/workflows/docker-build.yaml
#	apps/backend/package.json
#	apps/backend/prisma/tsup.config.ts
#	apps/dashboard/package.json
#	apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/auth-methods/providers.tsx
#	apps/dashboard/src/app/layout.tsx
#	packages/stack/package.json
#	packages/stack/src/lib/stack-app.ts
#	pnpm-lock.yaml
  • Loading branch information
jshimko committed Dec 3, 2024
2 parents f9e7995 + d5d28b2 commit e588310
Show file tree
Hide file tree
Showing 91 changed files with 894 additions and 210 deletions.
116 changes: 116 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,119 @@
# Git ignore rules
*.untracked
*.untracked.*

.vercel

# Misc
.DS_Store
.eslintcache
.env.local
.env.*.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
firebase-debug.log
ui-debug.log
.pnpm-debug.log
.husky
tmp

vitest.config.ts.timestamp-*
tsup.config.bundled_*

# Dependencies
node_modules

# Build dirs
.next
build
dist

# Generated files
.docusaurus
.cache-loader
**.tsbuildinfo

.xata*

# VS
/.vs/slnx.sqlite-journal
/.vs/slnx.sqlite
/.vs
.vscode/generated*

# Jetbrains
.idea

# GitHub Actions runner
/actions-runner
/_work

# DB
dev.db*
packages/adapter-prisma/prisma/dev.db
packages/adapter-prisma/prisma/migrations
db.sqlite
packages/adapter-supabase/supabase/.branches
packages/adapter-drizzle/.drizzle

# Tests
coverage
dynamodblocal-bin
firestore-debug.log
test.schema.gql
test-results
playwright-report
blob-report
playwright/.cache

# Turborepo
.turbo

# docusaurus
docs/.docusaurus
docs/manifest.mjs

# Core
packages/core/src/providers/oauth-types.ts
packages/core/lib
packages/core/providers
docs/docs/reference/core

# Next.js
docs/docs/reference/nextjs
next-env.d.ts

# SvelteKit
packages/frameworks-sveltekit/index.*
packages/frameworks-sveltekit/client.*
packages/frameworks-sveltekit/.svelte-kit
packages/frameworks-sveltekit/package
packages/frameworks-sveltekit/vite.config.js.timestamp-*
packages/frameworks-sveltekit/vite.config.ts.timestamp-*
docs/docs/reference/sveltekit

# SolidStart
docs/docs/reference/solidstart

# Express
docs/docs/reference/express

# Adapters
docs/docs/reference/adapter

## Drizzle migration folder
.drizzle

# Sentry Config File
.sentryclirc

# Python
__pycache__/
.venv/

# Docker ignore rules
.changeset
.git
.github
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/lint-and-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ jobs:
run: pnpm build
env:
QUETZAL_API_KEY: ${{ secrets.QUETZAL_API_KEY }}

- name: Run code gen
run: pnpm codegen

- name: Lint
run: pnpm lint
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/preview-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ jobs:
echo "$OUTPUT"
URL=$(echo "$OUTPUT" | grep -oP 'Published docs to \K.*(?= \()')
echo "Preview URL: $URL"
echo "🌿 Preview your docs: $URL" > docs_preview_url.untracked.txt
# echo "🌿 Preview your docs: $URL" > docs_preview_url.untracked.txt

- name: Comment URL in PR
uses: thollander/[email protected]
with:
filePath: docs_preview_url.untracked.txt
# - name: Comment URL in PR
# uses: thollander/[email protected]
# with:
# filePath: docs_preview_url.untracked.txt
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
run:
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_STACK_URL: http://localhost:8102
NEXT_PUBLIC_STACK_API_URL: http://localhost:8102
NEXT_PUBLIC_STACK_PROJECT_ID: internal
NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY: internal-project-publishable-client-key
STACK_SECRET_SERVER_KEY: internal-project-secret-server-key
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ docs/docs/reference/adapter
# Sentry Config File
.sentryclirc

# python
# Python
__pycache__/
.venv/
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"pageview",
"pkcco",
"PKCE",
"pooler",
"posthog",
"preconfigured",
"Proxied",
Expand All @@ -55,6 +56,7 @@
"RPID",
"simplewebauthn",
"spoofable",
"stackauth",
"stackframe",
"supabase",
"Svix",
Expand Down
13 changes: 12 additions & 1 deletion apps/backend/.env
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# Basic
STACK_BASE_URL=# the base URL of Stack's backend/API. For local development, this is `http://localhost:8102`; for the managed service, this is `https://api.stack-auth.com`.
NEXT_PUBLIC_STACK_API_URL=# the base URL of Stack's backend/API. For local development, this is `http://localhost:8102`; for the managed service, this is `https://api.stack-auth.com`.
NEXT_PUBLIC_STACK_DASHBOARD_URL=# the URL of Stack's dashboard. For local development, this is `http://localhost:8101`; for the managed service, this is `https://app.stack-auth.com`.
STACK_SERVER_SECRET=# a random, unguessable secret key generated by `pnpm generate-keys`

# seed script settings
STACK_SEED_SIGN_UP_ENABLED=# true to add OTP auth to the dashboard when seeding
STACK_SEED_OTP_ENABLED=# true to add OTP auth to the dashboard when seeding
STACK_SEED_ALLOW_LOCALHOST=# true to allow running dashboard on the localhost, set this to true only in development
STACK_SEED_OAUTH_PROVIDERS=# list of oauth providers to add to the dashboard when seeding, separated by comma, for example "github,google,facebook"
STACK_SEED_CLIENT_TEAM_CREATION=# true to allow the users of the internal project to create teams
STACK_SEED_USER_EMAIL=# default user added to the dashboard
STACK_SEED_USER_PASSWORD=# default user's password, paired with STACK_SEED_USER_EMAIL
STACK_SEED_USER_INTERNAL_ACCESS=# if the default user has access to the internal dashboard project
STACK_SEED_USER_GITHUB_ID=# add github oauth id to the default user

# OAuth mock provider settings
STACK_OAUTH_MOCK_URL=# enter the URL of the mock OAuth provider here. For local development, use `http://localhost:8114`.

Expand Down
14 changes: 13 additions & 1 deletion apps/backend/.env.development
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
STACK_BASE_URL=http://localhost:8102
NEXT_PUBLIC_STACK_API_URL=http://localhost:8102
NEXT_PUBLIC_STACK_DASHBOARD_URL=http://localhost:8101
STACK_SERVER_SECRET=23-wuNpik0gIW4mruTz25rbIvhuuvZFrLOLtL7J4tyo

STACK_SEED_SIGN_UP_ENABLED=true
STACK_SEED_OTP_ENABLED=true
STACK_SEED_ALLOW_LOCALHOST=true
STACK_SEED_OAUTH_PROVIDERS=github,spotify,google,microsoft
STACK_SEED_CLIENT_TEAM_CREATION=true
STACK_SEED_USER_INTERNAL_ACCESS=true

NEXT_PUBLIC_STACK_PROJECT_ID=project-id-from-stack-dashboard
NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=this-publishable-client-key-is-for-local-development-only
STACK_SECRET_SERVER_KEY=this-secret-server-key-is-for-local-development-only
STACK_SUPER_SECRET_ADMIN_KEY=this-super-secret-admin-key-is-for-local-development-only

STACK_OAUTH_MOCK_URL=http://localhost:8114

STACK_GITHUB_CLIENT_ID=MOCK
Expand Down
23 changes: 13 additions & 10 deletions apps/backend/.env.docker
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@

STACK_BASE_URL=http://host.docker.internal:8102
NEXT_PUBLIC_STACK_DASHBOARD_URL=http://host.docker.internal:8101
NEXT_PUBLIC_STACK_API_URL=http://host.docker.internal:8102
STACK_SERVER_SECRET=23-wuNpik0gIW4mruTz25rbIvhuuvZFrLOLtL7J4tyo

# Postgres connection strings
STACK_DATABASE_CONNECTION_STRING=postgres://stack:stack123@postgres:5432/stack
STACK_DIRECT_DATABASE_CONNECTION_STRING=postgres://stack:stack123@postgres:5432/stack

# optionally skip migrations on container startup
STACK_SKIP_MIGRATIONS="false"
STACK_RUN_MIGRATIONS="true"

# run Prisma seed script on container startup
STACK_RUN_SEED_SCRIPT="true"
Expand All @@ -16,20 +17,22 @@ STACK_RUN_SEED_SCRIPT="true"
# Optionally create a default admin user and disable signups to the platform when the seed script is run.
# This can be useful for self hosted deployments where you want to restrict access to the Stack "internal" project.
# If not specified, no user will be created and you will have to create the first user manually by signing up.
# [email protected]
# STACK_DEFAULT_ADMIN_PASSWORD=admin123
# STACK_DEFAULT_ADMIN_DISPLAY_NAME=Admin
[email protected]
STACK_SEED_USER_PASSWORD=admin123
STACK_SEED_ADMIN_DISPLAY_NAME=Admin
STACK_SEED_SIGN_UP_ENABLED=true
STACK_SEED_OTP_ENABLED=true
STACK_SEED_ALLOW_LOCALHOST=true
STACK_SEED_OAUTH_PROVIDERS=google,microsoft
STACK_SEED_CLIENT_TEAM_CREATION=false

# Override the name and description of the "internal" Stack project used for the main dashboard.
# STACK_DEFAULT_INTERNAL_PROJECT_NAME="Internal"
# STACK_DEFAULT_INTERNAL_PROJECT_DESCRIPTION="Internal project for self-hosted deployments"
# STACK_SEED_INTERNAL_PROJECT_NAME="Internal"
# STACK_SEED_INTERNAL_PROJECT_DESCRIPTION="Internal project for self-hosted deployments"

# Set the name of your default app project.
# SELF_HOST_DEFAULT_PROJECT_NAME="My App"

# Sign up options
# STACK_SIGN_UP_DISABLED=true

STACK_EMAIL_HOST=inbucket
STACK_EMAIL_PORT=2500
STACK_EMAIL_SECURE=false
Expand Down
9 changes: 9 additions & 0 deletions apps/backend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @stackframe/stack-backend

## 2.6.31

### Patch Changes

- Bugfixes
- Updated dependencies
- @stackframe/stack-shared@2.6.31
- @stackframe/stack-emails@2.6.31

## 2.6.30

### Patch Changes
Expand Down
3 changes: 2 additions & 1 deletion apps/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stackframe/stack-backend",
"version": "2.6.30",
"version": "2.6.31",
"private": true,
"scripts": {
"clean": "rimraf .next && rimraf node_modules",
Expand All @@ -10,6 +10,7 @@
"dev": "concurrently -n \"dev,codegen,prisma-studio\" -k \"next dev --port 8102\" \"pnpm run codegen:watch\" \"pnpm run prisma-studio\"",
"build": "pnpm run codegen && next build --no-lint",
"build:self-host-seed-script": "tsup --config prisma/tsup.config.ts",
"docker-build": "pnpm run codegen && next build --experimental-build-mode compile",
"analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build",
"start": "next start --port 8102",
"codegen-prisma": "pnpm run prisma generate",
Expand Down
7 changes: 4 additions & 3 deletions apps/backend/prisma/seed-self-host.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-restricted-syntax */
import { BooleanTrue, PrismaClient } from '@prisma/client';
import { throwErr } from '@stackframe/stack-shared/dist/utils/errors';
import { hashPassword } from '@stackframe/stack-shared/dist/utils/hashes';
import { generateUuid } from '@stackframe/stack-shared/dist/utils/uuids';

Expand Down Expand Up @@ -38,9 +39,9 @@ async function seed() {
create: [{
description: "Internal API key set",
// These keys must match the values used in the Stack dashboard env to be able to login via the UI.
publishableClientKey: process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY,
secretServerKey: process.env.STACK_SECRET_SERVER_KEY,
superSecretAdminKey: process.env.STACK_SUPER_SECRET_ADMIN_KEY,
publishableClientKey: process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY || throwErr('NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY is not set'),
secretServerKey: process.env.STACK_SECRET_SERVER_KEY || throwErr('STACK_SECRET_SERVER_KEY is not set'),
superSecretAdminKey: process.env.STACK_SUPER_SECRET_ADMIN_KEY || throwErr('STACK_SUPER_SECRET_ADMIN_KEY is not set'),
expiresAt: new Date('2099-12-31T23:59:59Z'),
}],
},
Expand Down
Loading

0 comments on commit e588310

Please sign in to comment.