Skip to content

Commit 918f205

Browse files
authored
Self-host docker (stack-auth#353)
1 parent 8c5224c commit 918f205

File tree

56 files changed

+829
-105
lines changed

Some content is hidden

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

56 files changed

+829
-105
lines changed

.dockerignore

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Git ignore rules
2+
*.untracked
3+
*.untracked.*
4+
5+
.vercel
6+
7+
# Misc
8+
.DS_Store
9+
.eslintcache
10+
.env.local
11+
.env.*.local
12+
13+
npm-debug.log*
14+
yarn-debug.log*
15+
yarn-error.log*
16+
firebase-debug.log
17+
ui-debug.log
18+
.pnpm-debug.log
19+
.husky
20+
tmp
21+
22+
vitest.config.ts.timestamp-*
23+
tsup.config.bundled_*
24+
25+
# Dependencies
26+
node_modules
27+
28+
# Build dirs
29+
.next
30+
build
31+
dist
32+
33+
# Generated files
34+
.docusaurus
35+
.cache-loader
36+
**.tsbuildinfo
37+
38+
.xata*
39+
40+
# VS
41+
/.vs/slnx.sqlite-journal
42+
/.vs/slnx.sqlite
43+
/.vs
44+
.vscode/generated*
45+
46+
# Jetbrains
47+
.idea
48+
49+
# GitHub Actions runner
50+
/actions-runner
51+
/_work
52+
53+
# DB
54+
dev.db*
55+
packages/adapter-prisma/prisma/dev.db
56+
packages/adapter-prisma/prisma/migrations
57+
db.sqlite
58+
packages/adapter-supabase/supabase/.branches
59+
packages/adapter-drizzle/.drizzle
60+
61+
# Tests
62+
coverage
63+
dynamodblocal-bin
64+
firestore-debug.log
65+
test.schema.gql
66+
test-results
67+
playwright-report
68+
blob-report
69+
playwright/.cache
70+
71+
# Turborepo
72+
.turbo
73+
74+
# docusaurus
75+
docs/.docusaurus
76+
docs/manifest.mjs
77+
78+
# Core
79+
packages/core/src/providers/oauth-types.ts
80+
packages/core/lib
81+
packages/core/providers
82+
docs/docs/reference/core
83+
84+
# Next.js
85+
docs/docs/reference/nextjs
86+
next-env.d.ts
87+
88+
# SvelteKit
89+
packages/frameworks-sveltekit/index.*
90+
packages/frameworks-sveltekit/client.*
91+
packages/frameworks-sveltekit/.svelte-kit
92+
packages/frameworks-sveltekit/package
93+
packages/frameworks-sveltekit/vite.config.js.timestamp-*
94+
packages/frameworks-sveltekit/vite.config.ts.timestamp-*
95+
docs/docs/reference/sveltekit
96+
97+
# SolidStart
98+
docs/docs/reference/solidstart
99+
100+
# Express
101+
docs/docs/reference/express
102+
103+
# Adapters
104+
docs/docs/reference/adapter
105+
106+
## Drizzle migration folder
107+
.drizzle
108+
109+
# Sentry Config File
110+
.sentryclirc
111+
112+
# Python
113+
__pycache__/
114+
.venv/
115+
116+
# Docker ignore rules
117+
.changeset
118+
.git
119+
.github
120+
.turbo
121+
**/.turbo
122+
.vscode
123+
124+
.env
125+
.env.*
126+
**/.env
127+
**/.env.*
128+
**/.next
129+
130+
**/dist
131+
132+
examples
133+
134+
node_modules
135+
**/node_modules
136+
137+
deploy
138+
!deploy/docker/**/entrypoint.sh
139+
docker-compose.yaml
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Docker Build and Push
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
- docker-build
9+
tags:
10+
- "*.*.*"
11+
pull_request:
12+
13+
jobs:
14+
build-server:
15+
name: Docker Build and Push Server
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Docker meta
22+
id: meta
23+
uses: docker/metadata-action@v5
24+
with:
25+
images: ${{ secrets.DOCKER_REPO }}/server
26+
tags: |
27+
type=ref,event=branch
28+
type=sha,prefix=
29+
type=match,pattern=\d.\d.\d
30+
31+
- name: Set up QEMU
32+
uses: docker/setup-qemu-action@v3
33+
34+
- name: Set up Docker Buildx
35+
uses: docker/setup-buildx-action@v3
36+
37+
- name: Set push condition
38+
id: push-condition
39+
run: |
40+
if [[ ${{ github.event_name == 'push' }} == 'true' ]]; then
41+
echo "should_push=true" >> $GITHUB_OUTPUT
42+
else
43+
echo "should_push=false" >> $GITHUB_OUTPUT
44+
fi
45+
46+
- name: Login to DockerHub
47+
if: steps.push-condition.outputs.should_push == 'true'
48+
uses: docker/login-action@v3
49+
with:
50+
username: ${{ secrets.DOCKER_USER }}
51+
password: ${{ secrets.DOCKER_PASSWORD }}
52+
53+
- name: Build and push
54+
uses: docker/build-push-action@v6
55+
with:
56+
context: .
57+
file: ./docker/server/Dockerfile
58+
push: ${{ steps.push-condition.outputs.should_push }}
59+
tags: ${{ steps.meta.outputs.tags == 'main' && 'latest' || steps.meta.outputs.tags }}
60+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/publish-docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
run:
1010
runs-on: ubuntu-latest
1111
env:
12-
NEXT_PUBLIC_STACK_URL: http://localhost:8102
12+
NEXT_PUBLIC_STACK_API_URL: http://localhost:8102
1313
NEXT_PUBLIC_STACK_PROJECT_ID: internal
1414
NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY: internal-project-publishable-client-key
1515
STACK_SECRET_SERVER_KEY: internal-project-secret-server-key

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ docs/docs/reference/adapter
113113
# Sentry Config File
114114
.sentryclirc
115115

116-
# python
116+
# Python
117117
__pycache__/
118118
.venv/

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"pageview",
4545
"pkcco",
4646
"PKCE",
47+
"pooler",
4748
"posthog",
4849
"preconfigured",
4950
"Proxied",
@@ -55,6 +56,7 @@
5556
"RPID",
5657
"simplewebauthn",
5758
"spoofable",
59+
"stackauth",
5860
"stackframe",
5961
"supabase",
6062
"Svix",

apps/backend/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Basic
2-
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`.
2+
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`.
33
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`.
44
STACK_SERVER_SECRET=# a random, unguessable secret key generated by `pnpm generate-keys`
55

apps/backend/.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
STACK_BASE_URL=http://localhost:8102
1+
NEXT_PUBLIC_STACK_API_URL=http://localhost:8102
22
NEXT_PUBLIC_STACK_DASHBOARD_URL=http://localhost:8101
33
STACK_SERVER_SECRET=23-wuNpik0gIW4mruTz25rbIvhuuvZFrLOLtL7J4tyo
44

apps/backend/next.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ const withConfiguredSentryConfig = (nextConfig) =>
4747

4848
/** @type {import('next').NextConfig} */
4949
const nextConfig = {
50+
// optionally set output to "standalone" for Docker builds
51+
// https://nextjs.org/docs/pages/api-reference/next-config-js/output
52+
output: process.env.NEXT_CONFIG_OUTPUT,
53+
5054
// we're open-source, so we can provide source maps
5155
productionBrowserSourceMaps: true,
5256
poweredByHeader: false,

apps/backend/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"with-env:prod": "dotenv -c --",
1010
"dev": "concurrently -n \"dev,codegen,prisma-studio\" -k \"next dev --port 8102\" \"pnpm run codegen:watch\" \"pnpm run prisma-studio\"",
1111
"build": "pnpm run codegen && next build",
12+
"docker-build": "pnpm run codegen && next build --experimental-build-mode compile",
13+
"self-host-seed-script": "tsup --config prisma/tsup.config.ts",
1214
"analyze-bundle": "ANALYZE_BUNDLE=1 pnpm run build",
1315
"start": "next start --port 8102",
1416
"codegen-prisma": "pnpm run prisma generate",
@@ -78,8 +80,9 @@
7880
"@types/semver": "^7.5.8",
7981
"concurrently": "^8.2.2",
8082
"glob": "^10.4.1",
81-
"prisma": "^5.9.1",
83+
"prisma": "^5.20.0",
8284
"rimraf": "^5.0.5",
85+
"tsup": "^8.3.0",
8386
"tsx": "^4.7.2"
8487
}
8588
}

0 commit comments

Comments
 (0)