mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
<!--
Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md
-->
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Port dashboard to Next.js 15, update dependencies, and enhance Docker
workflows.
>
> - **Next.js 15 Migration**:
> - Update `next` to `15.2.3` in `apps/backend/package.json`,
`apps/dashboard/package.json`, and `examples/demo/package.json`.
> - Remove MDX support in `next.config.mjs`.
> - Use `turbopack` in `dev` scripts in `apps/dashboard/package.json`
and `examples/demo/package.json`.
> - **Docker Workflows**:
> - Add `docker-emulator-test.yaml` for testing Docker emulator.
> - Rename `docker-build.yaml` to `docker-server-build.yaml` and
`docker-test.yaml` to `docker-server-test.yaml`.
> - Update `docker-compose.yaml` for emulator setup.
> - **Code Refactoring**:
> - Convert several `Page` components to async functions in
`apps/dashboard/src/app`.
> - Use `dynamic` import for `react-globe.gl` in `globe.tsx`.
> - Remove `experimental` config in `next.config.mjs`.
> - **Dependency Updates**:
> - Update `react` and `react-dom` to `19.0.0` in
`apps/backend/package.json`, `apps/dashboard/package.json`, and
`examples/demo/package.json`.
> - Add `pnpm` overrides for `@types/react` and `@types/react-dom` in
multiple `package.json` files.
> - **Miscellaneous**:
> - Add `docker/readme.md` for Docker instructions.
> - Update `entrypoint.sh` for Docker server setup.
> - Remove `globals.d.ts` as it's empty.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for 5f5d8fd65c. It will automatically
update as commits are pushed.</sup>
<!-- ELLIPSIS_HIDDEN -->
---------
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: Zai Shi <zaishi00@outlook.com>
96 lines
3.5 KiB
Bash
96 lines
3.5 KiB
Bash
#!/bin/bash
|
||
|
||
set -e
|
||
|
||
# ============= FORWARD MOCK OAUTH SERVER =============
|
||
|
||
# Start socat to forward port 32202 for mock-oauth-server if enabled
|
||
if [ "$STACK_FORWARD_MOCK_OAUTH_SERVER" = "true" ]; then
|
||
socat TCP-LISTEN:32202,fork,reuseaddr TCP:host.docker.internal:32202 &
|
||
fi
|
||
|
||
# ============= ENV VARS =============
|
||
|
||
export STACK_SEED_INTERNAL_PROJECT_PUBLISHABLE_CLIENT_KEY=$(openssl rand -base64 32)
|
||
export STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY=$(openssl rand -base64 32)
|
||
export STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY=$(openssl rand -base64 32)
|
||
|
||
export NEXT_PUBLIC_STACK_PROJECT_ID=internal
|
||
export NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY=${STACK_SEED_INTERNAL_PROJECT_PUBLISHABLE_CLIENT_KEY}
|
||
export STACK_SECRET_SERVER_KEY=${STACK_SEED_INTERNAL_PROJECT_SECRET_SERVER_KEY}
|
||
export STACK_SUPER_SECRET_ADMIN_KEY=${STACK_SEED_INTERNAL_PROJECT_SUPER_SECRET_ADMIN_KEY}
|
||
|
||
export NEXT_PUBLIC_BROWSER_STACK_DASHBOARD_URL=${NEXT_PUBLIC_STACK_DASHBOARD_URL}
|
||
export NEXT_PUBLIC_SERVER_STACK_DASHBOARD_URL="http://localhost:8101"
|
||
export NEXT_PUBLIC_BROWSER_STACK_API_URL=${NEXT_PUBLIC_STACK_API_URL}
|
||
export NEXT_PUBLIC_SERVER_STACK_API_URL="http://localhost:8102"
|
||
|
||
export USE_INLINE_ENV_VARS=true
|
||
|
||
if [ -z "${NEXT_PUBLIC_STACK_SVIX_SERVER_URL}" ]; then
|
||
export NEXT_PUBLIC_STACK_SVIX_SERVER_URL=${STACK_SVIX_SERVER_URL}
|
||
fi
|
||
|
||
# ============= MIGRATIONS =============
|
||
|
||
if [ "$STACK_SKIP_MIGRATIONS" = "true" ]; then
|
||
echo "Skipping migrations."
|
||
else
|
||
echo "Running migrations..."
|
||
prisma migrate deploy --schema=./apps/backend/prisma/schema.prisma
|
||
fi
|
||
|
||
if [ "$STACK_SKIP_SEED_SCRIPT" = "true" ]; then
|
||
echo "Skipping seed script."
|
||
else
|
||
echo "Running seed script..."
|
||
cd apps/backend
|
||
node seed.js
|
||
cd ../..
|
||
fi
|
||
|
||
# ============= ENV VARS =============
|
||
|
||
# Find all files in /app/apps that contain a STACK_ENV_VAR_SENTINEL and extract the unique sentinel strings.
|
||
unhandled_sentinels=$(find /app/apps -type f -exec grep -l "STACK_ENV_VAR_SENTINEL" {} + | \
|
||
xargs grep -h "STACK_ENV_VAR_SENTINEL" | \
|
||
grep -o "STACK_ENV_VAR_SENTINEL[A-Z_]*" | \
|
||
sort -u | grep -v "^STACK_ENV_VAR_SENTINEL$")
|
||
|
||
# Choose an uncommon delimiter – here, we use the ASCII Unit Separator (0x1F)
|
||
delimiter=$(printf '\037')
|
||
|
||
for sentinel in $unhandled_sentinels; do
|
||
# The sentinel is like "STACK_ENV_VAR_SENTINEL_MY_VAR", so extract the env var name.
|
||
env_var=${sentinel#STACK_ENV_VAR_SENTINEL_}
|
||
|
||
# Get the corresponding environment variable value.
|
||
value="${!env_var}"
|
||
|
||
# If the env var is not set, skip replacement.
|
||
if [ -z "$value" ]; then
|
||
continue
|
||
fi
|
||
|
||
# Although the sentinel only contains [A-Z_] we still escape it for any regex meta-characters.
|
||
escaped_sentinel=$(printf '%s\n' "$sentinel" | sed -e 's/\\/\\\\/g' -e 's/[][\/.^$*]/\\&/g')
|
||
|
||
# For the replacement value, first escape backslashes, then escape any occurrence of
|
||
# the chosen delimiter and the '&' (which has special meaning in sed replacements).
|
||
escaped_value=$(printf '%s\n' "$value" | sed -e 's/\\/\\\\/g' -e "s/[${delimiter}&]/\\\\&/g")
|
||
|
||
# Now replace the sentinel with the (properly escaped) value in all files.
|
||
find /app/apps -type f -exec sed -i "s${delimiter}${escaped_sentinel}${delimiter}${escaped_value}${delimiter}g" {} +
|
||
done
|
||
|
||
# ============= START BACKEND AND DASHBOARD =============
|
||
|
||
echo "Starting backend on port $BACKEND_PORT..."
|
||
PORT=$BACKEND_PORT HOSTNAME=0.0.0.0 node apps/backend/server.js &
|
||
|
||
echo "Starting dashboard on port $DASHBOARD_PORT..."
|
||
PORT=$DASHBOARD_PORT HOSTNAME=0.0.0.0 node apps/dashboard/server.js &
|
||
|
||
# Wait for both to finish
|
||
wait -n
|