Skip to content

Commit c22d2f5

Browse files
authored
Merge pull request back-stack#3 from vrabbi-backstage/browser-codespace-support
Refactor for browser based codespace support
2 parents 7b9d0fb + c6a85e3 commit c22d2f5

Some content is hidden

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

66 files changed

+1048
-256
lines changed
Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,9 @@
22

33
This directory contains the configuration for running the Backstack Demo in GitHub Codespaces.
44

5-
## What's Included
6-
7-
The devcontainer is configured with:
8-
9-
- **Node.js 20**: The required Node.js version for Backstage
10-
- **kubectl**: Kubernetes command-line tool
11-
- **helm**: Kubernetes package manager
12-
- **kind**: Kubernetes in Docker (for local cluster creation)
13-
- **Docker-in-Docker**: Required for kind and container operations
14-
- **Yarn 4**: Package manager (enabled via corepack)
15-
- **crossplane**: CLI for interacting with crossplane
16-
- **kyverno**: CLI for interacting with Kyverno
17-
- **argocd**: CLI for interacting with ArgoCD
18-
19-
## Pre-installed Extensions
20-
21-
The following VS Code extensions are automatically installed:
22-
- ESLint
23-
- Prettier
24-
- Kubernetes Tools
25-
- YAML support
26-
27-
## Environment Setup
28-
29-
The devcontainer automatically:
30-
1. Enables yarn via corepack
31-
2. Installs Backstage dependencies
32-
3. Configures Node.js environment
33-
4. Forwards ports 3000 (frontend) and 7007 (backend)
34-
5. Creates a Kind Cluster
35-
6. Installs Kyverno, ArgoCD, and Crossplane
36-
7. Configures Crossplane and Kyverno
37-
8. Setups RBAC for Backstage in the Kubernetes Cluster
5+
## Important Notes
6+
* While it can work with the default 2 CPU Core instance of a codespace, it is highly recommended to use at minimum the 4 CPU Core instance type for better performance and speed
7+
* When the browser opens up for backstage after starting it, if it opens up to http://127.0.0.1:3000 change this to http://localhost:3000 as otherwise the github authentication flow will fail
388

399
## Getting Started
4010

@@ -47,7 +17,7 @@ The devcontainer automatically:
4717
* Authorization Callback URL: http://localhost:7007/api/auth/github
4818
3. Copy the Client ID
4919
4. Create a Client Secret and copy it
50-
5. Update first User Manifests Username from vrabbi to your Github Username in [the relevant file](./backstage/examples/org.yaml)
20+
5. Update first User Manifests Username from vrabbi to your Github Username in [the relevant file](../backstage/examples/org.yaml)
5121

5222
### After the Codespace starts
5323
1. **Set up GitHub credentials** (required for Backstage):
@@ -70,7 +40,8 @@ The devcontainer automatically:
7040
```
7141
3. **Start Backstage**:
7242
```bash
73-
cd backstage
43+
cd backstage/src
44+
yarn install
7445
export NODE_OPTIONS="--max_old_space_size=8192 --no-node-snapshot"
7546
export NODE_TLS_REJECT_UNAUTHORIZED=0
7647
yarn start
@@ -81,3 +52,4 @@ The devcontainer automatically:
8152
- The environment includes Docker-in-Docker support, allowing you to run kind clusters within the Codespace
8253
- All prerequisites mentioned in the main README are pre-installed
8354
- The workspace is configured with recommended VS Code settings for the project
55+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Web Based GitHub Codespaces Configuration
2+
3+
This directory contains the configuration for running the Backstack Demo in GitHub Codespaces.
4+
5+
## Getting Started
6+
7+
### While the Codespace starts:
8+
9+
1. [Create Github PAT](https://github.com/settings/tokens/new)
10+
2. [Create Github Oauth App](https://github.com/settings/applications/new)
11+
12+
* Get the values by running in the terminal of this codespace the following commands:
13+
```bash
14+
echo "Application Name: Backstage"
15+
echo "Homepage URL: https://${CODESPACE_NAME}-443.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"
16+
echo "Authorization Callback URL: https://${CODESPACE_NAME}-443.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}/api/auth/github"
17+
```
18+
3. Copy the Client ID
19+
4. Create a Client Secret and copy it
20+
21+
### After the Codespace starts
22+
1. **Set up GitHub credentials** (required for Backstage):
23+
```bash
24+
export GITHUB_TOKEN="your_github_token"
25+
export GITHUB_CLIENT_ID="your_oauth_app_client_id"
26+
export GITHUB_CLIENT_SECRET="your_oauth_app_client_secret"
27+
export GITHUB_OWNER="your_github_username"
28+
export GITHUB_REPO="your_repo_name"
29+
```
30+
2. **Configure Argo AppSet**:
31+
```bash
32+
envsubst <argo/app-set-template.yaml > argo/app-set-rendered.yaml
33+
kubectl apply -f argo/app-set-rendered.yaml
34+
```
35+
3. **Export Kubernetes Cluster Details**:
36+
```bash
37+
export KUBERNETES_SERVICE_ACCOUNT_TOKEN=`kubectl get secret -n backstage-system backstage-token -o jsonpath='{.data.token}' | base64 --decode`
38+
```
39+
4. **Render Backstage Values File**:
40+
```bash
41+
envsubst <backstage/values-templated.yaml > backstage/values-rendered.yaml
42+
```
43+
3. **Deploy Backstage**:
44+
```bash
45+
helm repo add backstage https://backstage.github.io/charts
46+
helm upgrade --install backstack backstage/backstage -n backstage-system -f backstage/values-rendered.yaml --wait
47+
```
48+
49+
## Notes
50+
51+
- The environment includes Docker-in-Docker support, allowing you to run kind clusters within the Codespace
52+
- All prerequisites mentioned in the main README are pre-installed
53+
- The workspace is configured with recommended VS Code settings for the project

.devcontainer/devcontainer.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,10 @@
3939
}
4040
},
4141
"postCreateCommand": "bash .devcontainer/post-create.sh",
42-
"forwardPorts": [3000, 7007],
42+
"forwardPorts": [443],
4343
"portsAttributes": {
44-
"3000": {
45-
"label": "Backstage Frontend",
46-
"onAutoForward": "notify"
47-
},
48-
"7007": {
49-
"label": "Backstage Backend",
44+
"443": {
45+
"label": "Backstage",
5046
"onAutoForward": "notify"
5147
}
5248
},

.devcontainer/post-create.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
set -e
33

44
echo "Setting up Backstack Demo environment..."
5-
# Navigate to backstage directory and install dependencies
6-
echo "Installing Backstage dependencies..."
7-
cd backstage
8-
yarn install
9-
cd ..
10-
echo "Create Kind Cluster..."
11-
kind create cluster --name backstack-demo
5+
kind create cluster --name backstack-demo --config kind/config.yaml
6+
7+
echo "Install Cert Manager..."
8+
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.19.1/cert-manager.yaml
9+
10+
echo "Install Ingres NGINX..."
11+
kubectl apply -f https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx.yaml
1212

1313
echo "Install Kyverno..."
1414
helm repo add kyverno https://kyverno.github.io/kyverno/
@@ -65,10 +65,17 @@ kubectl apply -f crossplane/06-examples --recursive
6565
echo "Configure Kyverno..."
6666
kubectl apply -f kyverno/
6767

68+
echo "Create Cluster Issuer..."
69+
kubectl apply -f cert-manager/ca-issuer.yaml
70+
71+
echo "Install Metrics Server..."
72+
kubectl apply -k metrics-server/
73+
6874
echo "Setup complete!"
6975
echo ""
7076
echo "Next steps:"
7177
echo " 1. Set up your environment variables (GITHUB_TOKEN, GITHUB_CLIENT_ID, etc.)"
7278
echo " 2. Render and Apply ArgoCD AppSet"
73-
echo " 3. Start Backstage: cd backstage && yarn start"
79+
echo " 3. Render Backstage values file"
80+
echo " 4. Deploy Backstage"
7481
echo ""

.gitignore

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,56 @@
11
# macOS
2-
backstage/.DS_Store
2+
backstage/source/.DS_Store
33

44
# Logs
5-
backstage/logs
6-
backstage/*.log
7-
backstage/npm-debug.log*
8-
backstage/yarn-debug.log*
5+
backstage/source/logs
6+
backstage/source/*.log
7+
backstage/source/npm-debug.log*
8+
backstage/source/yarn-debug.log*
99
yarn-error.log*
1010

1111
# Coverage directory generated when running tests with coverage
12-
backstage/coverage
12+
backstage/source/coverage
1313

1414
# Dependencies
15-
backstage/node_modules/
15+
backstage/source/node_modules/
1616

1717
# Yarn files
18-
backstage/.pnp.*
19-
backstage/.yarn/*
20-
!backstage/.yarn/patches
21-
!backstage/.yarn/plugins
22-
!backstage/.yarn/releases
23-
!backstage/.yarn/sdks
24-
!backstage/.yarn/versions
18+
backstage/source/.pnp.*
19+
backstage/source/.yarn/*
20+
!backstage/source/.yarn/patches
21+
!backstage/source/.yarn/plugins
22+
!backstage/source/.yarn/releases
23+
!backstage/source/.yarn/sdks
24+
!backstage/source/.yarn/versions
2525

2626
# Node version directives
27-
backstage/.nvmrc
27+
backstage/source/.nvmrc
2828

2929
# dotenv environment variables file
30-
backstage/.env
31-
backstage/.env.test
30+
backstage/source/.env
31+
backstage/source/.env.test
3232

3333
# Build output
34-
backstage/dist
35-
backstage/dist-types
34+
backstage/source/dist
35+
backstage/source/dist-types
3636

3737
# Temporary change files created by Vim
38-
backstage/*.swp
38+
backstage/source/*.swp
3939

4040
# MkDocs build output
41-
backstage/site
41+
backstage/source/site
4242

4343
# Sensitive credentials
44-
backstage/*-credentials.yaml
44+
backstage/source/*-credentials.yaml
4545

4646
# vscode database functionality support files
47-
backstage/*.session.sql
47+
backstage/source/*.session.sql
4848

4949
# E2E test reports
50-
backstage/e2e-test-report/
50+
backstage/source/e2e-test-report/
5151

5252
# Cache
53-
backstage/.cache/
53+
backstage/source/.cache/
5454

55-
argo/app-set-rendered.yaml
55+
argo/app-set-rendered.yaml
56+
backstage/values-rendered.yaml

.vscode/mcp.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"servers": {
3+
"dev": {
4+
"url": "https://localhost/api/mcp-actions/v1",
5+
"type": "http"
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)