Dev container for codespaces (#610)

This commit is contained in:
Zai Shi 2025-04-09 01:47:52 +02:00 committed by GitHub
parent 3940e581ce
commit 8e71f18f4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 6 deletions

View File

@ -9,7 +9,8 @@
"ghcr.io/devcontainers-contrib/features/pnpm:2": {
"version": "9"
},
"ghcr.io/devcontainers/features/git:1": {}
"ghcr.io/devcontainers/features/git:1": {},
"github-cli": "latest"
},
"hostRequirements": {
"cpus": 2,
@ -31,8 +32,9 @@
8180, 8181, 8182, 8183, 8184, 8185, 8186, 8187, 8188, 8189,
8190, 8191, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199
],
"postCreateCommand": "pnpm install && pnpm build:packages && pnpm codegen && pnpm run start-deps && pnpm run stop-deps",
"postStartCommand": "pnpm install && clear && echo 'To start the development server with dependencies, run: pnpm restart-deps && pnpm dev' && echo 'To run the tests, run: pnpm test [<path-filter>]'",
"postCreateCommand": "chmod +x .devcontainer/set-env.sh && pnpm install && pnpm build:packages && pnpm codegen && pnpm run start-deps && pnpm run stop-deps",
"postStartCommand": "pnpm install && clear",
"postAttachCommand": ". .devcontainer/set-env.sh",
"customizations": {
"vscode": {
"extensions": [

10
.devcontainer/set-env.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
if [ -n "$CODESPACE_NAME" ]; then
export NEXT_PUBLIC_STACK_API_URL="https://${CODESPACE_NAME}-8102.app.github.dev"
export STACK_MOCK_OAUTH_REDIRECT_URIS="https://${CODESPACE_NAME}-8102.app.github.dev/api/v1/auth/oauth/callback/{id}"
export NEXT_PUBLIC_STACK_DASHBOARD_URL="https://${CODESPACE_NAME}-8101.app.github.dev"
gh codespace ports visibility 8102:public -c $CODESPACE_NAME && gh codespace ports visibility 8114:public -c $CODESPACE_NAME
fi
echo 'To start the development server with dependencies, run: pnpm restart-deps && pnpm dev'

View File

@ -18,9 +18,12 @@ const providerIds = [
const clients = providerIds.map((id) => ({
client_id: id,
client_secret: 'MOCK-SERVER-SECRET',
redirect_uris: [8102, 32102].map(port =>
`http://localhost:${port}/api/v1/auth/oauth/callback/${id}`
),
redirect_uris: [
...([8102, 32102].map(port =>
`http://localhost:${port}/api/v1/auth/oauth/callback/${id}`
)),
...(process.env.STACK_MOCK_OAUTH_REDIRECT_URIS ? [process.env.STACK_MOCK_OAUTH_REDIRECT_URIS.replace("{id}", id)] : [])
]
}));
const configuration = {