Skip to content

Commit 77a629c

Browse files
committed
sss
1 parent ee0484d commit 77a629c

File tree

16 files changed

+34031
-56
lines changed

16 files changed

+34031
-56
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
push:
5+
# Publish `v1.2.3` tags as releases.
6+
tags:
7+
- v*
8+
# Run tests for any PRs.
9+
# pull_request:
10+
11+
env:
12+
# REGISTRY: ghcr.io
13+
# IMAGE_NAME: ${{ github.repository }}
14+
REGISTRY: docker.io
15+
IMAGE_NAME: nxest/xlabs-developer-platform
16+
17+
jobs:
18+
push:
19+
runs-on: ubuntu-latest
20+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
21+
# permissions:
22+
# contents: read
23+
# packages: write
24+
# attestations: write
25+
# id-token: write
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- uses: actions/setup-node@v4
31+
with:
32+
node-version: '20'
33+
cache: 'yarn'
34+
35+
- name: Install package
36+
run: |
37+
yarn install --immutable
38+
39+
- name: Node build
40+
run: |
41+
yarn tsc
42+
yarn build:backend
43+
44+
- name: Login to dockerhub
45+
uses: docker/login-action@v3
46+
with:
47+
registry: ${{ env.REGISTRY }}
48+
# username: ${{ github.actor }}
49+
# password: ${{ secrets.GITHUB_TOKEN }}
50+
username: ${{ secrets.DOCKER_USERNAME }}
51+
password: ${{ secrets.DOCKER_PASSWORD }}
52+
53+
- name: Setup qemu
54+
uses: docker/setup-qemu-action@v3
55+
with:
56+
platforms: all
57+
58+
- name: Setup buildx
59+
id: buildx
60+
uses: docker/setup-buildx-action@v3
61+
62+
- name: Build and Push image
63+
run: |
64+
# Strip git ref prefix from version
65+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
66+
67+
# Strip "v" prefix from tag name, keep the number version
68+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
69+
70+
yarn build-image \
71+
--tag $IMAGE_NAME:$VERSION \
72+
--tag $IMAGE_NAME:latest \
73+
--platform linux/amd64,linux/arm64 \
74+
--push

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# macOS
22
.DS_Store
3+
out/
4+
gen/
35

46
# Logs
57
logs
@@ -52,3 +54,21 @@ site
5254

5355
# E2E test reports
5456
e2e-test-report/
57+
58+
59+
### IntelliJ IDEA ###
60+
.idea
61+
*.iws
62+
*.iml
63+
*.ipr
64+
65+
### NetBeans ###
66+
/nbproject/private/
67+
/nbbuild/
68+
/dist/
69+
/nbdist/
70+
/.nb-gradle/
71+
build/
72+
73+
### VS Code ###
74+
.vscode/

README.md

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,71 @@
1-
# [Backstage](https://backstage.io)
1+
# xlabs-developer-platform
22

3-
This is your newly scaffolded Backstage App, Good Luck!
3+
卫星实验室基于 Backstage 构建的内部开发者平台。
44

5-
To start the app, run:
5+
效果展示请访问 [app.xlabs.club](https://app.xlabs.club)
6+
7+
## 本地开发指导
8+
9+
Backstage 官方开源有开箱即用的容器镜像,也有丰富的插件生态,然而区别于其他插件类应用,Backstage 有自己的特点:
10+
11+
1. Backstage 插件分为 frontend 和 backend,一个完整的插件可能包含两种,也可能只包含其中一种。
12+
2. 开源发布的开箱即用的容器镜像,只包含基础插件,一般只用来作为初次学习使用。
13+
3. 如果想使用其他插件,需要做一些编码工作,一般步骤如下。
14+
15+
- 使用 `npx @backstage/create-app@latest` 创建一个基础项目。
16+
- 按插件要求安装插件,配置插件菜单、UI 效果、权限、认证信息等,每个插件要求不同。
17+
- 按需开发自己的插件。
18+
- 编译成新容器镜像,某些插件可能还需要在容器中额外安装一些依赖包,部署时使用此容器镜像。
19+
20+
4. 基本上每个插件都有自己的配置要求,需根据插件文档配置 app-config.yaml。
21+
22+
本地开发请先安装 Node.js 以及 yarn,版本要求请参考根目录 `package.json`, 然后根据提示按需执行以下命令:
623

724
```sh
25+
# 本地开发
826
yarn install
927
yarn dev
28+
29+
# 版本发布
30+
yarn install --immutable
31+
yarn tsc && yarn build:backend
32+
# 编译镜像,需要安装 docker 并启用 docker buildx,示例
33+
yarn build-image --tag xlabs-developer-platform:dev --platform linux/amd64,linux/arm64 --load
34+
# 发布镜像,需要先登录 docker hub
35+
# yarn build-image --tag nxest/xlabs-developer-platform:dev --platform linux/amd64 --push
1036
```
37+
38+
### Backstage 版本升级
39+
40+
Backstage 版本更新很频繁,保持最新版本的方法请参考官方文档 [keeping-backstage-updated](https://backstage.io/docs/getting-started/keeping-backstage-updated/).
41+
42+
一般更新步骤如下。
43+
44+
1. 使用命令行升级 package.json 依赖包,注意这一步只升级 Dependencies,不会升级其中 scripts、config、Dockefile 等其他内容。
45+
46+
```sh
47+
# 只升级 @backstage 包
48+
yarn backstage-cli versions:bump
49+
# 按指定 pattern 升级包
50+
yarn backstage-cli versions:bump --pattern '@{backstage,backstage-community}/*'
51+
```
52+
53+
2. 从 backstage.json 获取当前项目版本,使用 [upgrade-helper](https://backstage.github.io/upgrade-helper/?from=1.30.0&to=1.31.1) 比对从 x 版本到 y 版本有哪些更新,根据 diff 手动合并到自己项目中。
54+
3. 根据 release change log 查看是否有破坏性变更,更新代码。
55+
4. 按需更新插件版本,注意插件本身相关的配置变更。
56+
57+
### 本项目变更
58+
59+
此项目使用 `npx @backstage/create-app@latest` 初始化,然后我们逐步修改了一些内容,主要修改内容参考如下列表。
60+
61+
常规变更:
62+
63+
- `backend/package.json` 修改了 `build-image`, 增加 `\"$@\"`,支持 docker 编译指定参数,编译命令参考 `.github/workflows/deploy-image.yaml` 文件。
64+
65+
插件列表:
66+
67+
- pluing list。
68+
69+
## License
70+
71+
Licensed under the [Apache License, Version 2.0]( http://www.apache.org/licenses/LICENSE-2.0)。

app-config.production.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# 请注意,此文件在部署时,会用 k8s ConfigMap 全部替换掉
12
app:
23
# Should be the same as backend.baseUrl when using the `app-backend` plugin.
34
baseUrl: http://localhost:7007

app-config.yaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
app:
2-
title: Scaffolded Backstage App
2+
title: 卫星实验室
33
baseUrl: http://localhost:3000
44

55
organization:
6-
name: My Company
6+
name: XLabs Club
77

88
backend:
99
# Used for enabling authentication, secret is shared by all backend plugins
@@ -64,6 +64,7 @@ techdocs:
6464

6565
auth:
6666
# see https://backstage.io/docs/auth/ to learn about auth providers
67+
environment: development
6768
providers:
6869
# See https://backstage.io/docs/auth/guest/provider
6970
guest: {}
@@ -82,17 +83,17 @@ catalog:
8283
- type: file
8384
target: ../../examples/entities.yaml
8485

85-
# Local example template
86-
- type: file
87-
target: ../../examples/template/template.yaml
88-
rules:
89-
- allow: [Template]
86+
# # Local example template
87+
# - type: file
88+
# target: ../../examples/template/template.yaml
89+
# rules:
90+
# - allow: [Template]
9091

91-
# Local example organizational data
92-
- type: file
93-
target: ../../examples/org.yaml
94-
rules:
95-
- allow: [User, Group]
92+
# # Local example organizational data
93+
# - type: file
94+
# target: ../../examples/org.yaml
95+
# rules:
96+
# - allow: [User, Group]
9697

9798
## Uncomment these lines to add more example data
9899
# - type: url

backstage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "1.36.0"
2+
"version": "1.36.1"
33
}

packages/app/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
"lint": "backstage-cli package lint"
1515
},
1616
"dependencies": {
17+
"@backstage-community/plugin-explore": "^0.7.0",
18+
"@backstage-community/plugin-playlist": "^0.4.0",
19+
"@backstage-community/plugin-rbac": "^1.38.1",
20+
"@backstage-community/plugin-shortcuts": "^0.5.2",
1721
"@backstage/app-defaults": "^1.5.17",
1822
"@backstage/catalog-model": "^1.7.3",
1923
"@backstage/cli": "^0.30.0",
@@ -27,7 +31,9 @@
2731
"@backstage/plugin-catalog-graph": "^0.4.16",
2832
"@backstage/plugin-catalog-import": "^0.12.10",
2933
"@backstage/plugin-catalog-react": "^1.15.2",
34+
"@backstage/plugin-home": "^0.8.5",
3035
"@backstage/plugin-kubernetes": "^0.12.4",
36+
"@backstage/plugin-notifications": "^0.5.2",
3137
"@backstage/plugin-org": "^0.6.36",
3238
"@backstage/plugin-permission-react": "^0.4.31",
3339
"@backstage/plugin-scaffolder": "^1.28.0",

packages/app/src/App.tsx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Navigate, Route } from 'react-router-dom';
2+
import { Route } from 'react-router-dom';
33
import { apiDocsPlugin, ApiExplorerPage } from '@backstage/plugin-api-docs';
44
import {
55
CatalogEntityPage,
@@ -29,16 +29,25 @@ import { Root } from './components/Root';
2929
import {
3030
AlertDisplay,
3131
OAuthRequestDialog,
32+
ProxiedSignInPage,
3233
SignInPage,
3334
} from '@backstage/core-components';
3435
import { createApp } from '@backstage/app-defaults';
3536
import { AppRouter, FlatRoutes } from '@backstage/core-app-api';
3637
import { CatalogGraphPage } from '@backstage/plugin-catalog-graph';
3738
import { RequirePermission } from '@backstage/plugin-permission-react';
39+
import { configApiRef, useApi } from '@backstage/core-plugin-api';
3840
import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';
41+
import { RbacPage } from '@backstage-community/plugin-rbac';
42+
import { PlaylistIndexPage, PlaylistPage } from '@backstage-community/plugin-playlist';
43+
import { HomepageCompositionRoot } from '@backstage/plugin-home';
44+
import { HomePage } from './components/home/HomePage';
45+
import * as plugins from './plugins';
46+
import { ExplorePage } from '@backstage-community/plugin-explore';
3947

4048
const app = createApp({
4149
apis,
50+
plugins: Object.values(plugins),
4251
bindRoutes({ bind }) {
4352
bind(catalogPlugin.externalRoutes, {
4453
createComponent: scaffolderPlugin.routes.root,
@@ -57,13 +66,29 @@ const app = createApp({
5766
});
5867
},
5968
components: {
60-
SignInPage: props => <SignInPage {...props} auto providers={['guest']} />,
69+
// SignInPage: props => <SignInPage {...props} auto providers={['guest']} />,
70+
SignInPage: props => {
71+
const configApi = useApi(configApiRef);
72+
// 开发环境使用guest账号,生产环境使用oauth2Proxy作为登录认证
73+
if (configApi.getString('auth.environment') === 'development') {
74+
return (
75+
<SignInPage
76+
{...props}
77+
providers={['guest']}
78+
/>
79+
);
80+
}
81+
return <ProxiedSignInPage {...props} provider="oauth2Proxy" />;
82+
},
6183
},
6284
});
6385

6486
const routes = (
6587
<FlatRoutes>
66-
<Route path="/" element={<Navigate to="catalog" />} />
88+
{/* <Route path="/" element={<Navigate to="catalog" />} /> */}
89+
<Route path="/" element={<HomepageCompositionRoot />}>
90+
<HomePage />
91+
</Route>;
6792
<Route path="/catalog" element={<CatalogIndexPage />} />
6893
<Route
6994
path="/catalog/:namespace/:kind/:name"
@@ -94,7 +119,11 @@ const routes = (
94119
{searchPage}
95120
</Route>
96121
<Route path="/settings" element={<UserSettingsPage />} />
122+
<Route path="/playlist" element={<PlaylistIndexPage />} />
123+
<Route path="/playlist/:playlistId" element={<PlaylistPage />} />
97124
<Route path="/catalog-graph" element={<CatalogGraphPage />} />
125+
<Route path="/explore" element={<ExplorePage />} />
126+
<Route path="/rbac" element={<RbacPage />} />;
98127
</FlatRoutes>
99128
);
100129

packages/app/src/components/Root/Root.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React, { PropsWithChildren } from 'react';
22
import { makeStyles } from '@material-ui/core';
33
import HomeIcon from '@material-ui/icons/Home';
4+
import CategoryIcon from '@material-ui/icons/Category';
5+
import LayersIcon from '@material-ui/icons/Layers';
46
import ExtensionIcon from '@material-ui/icons/Extension';
57
import LibraryBooks from '@material-ui/icons/LibraryBooks';
68
import CreateComponentIcon from '@material-ui/icons/AddCircleOutline';
@@ -27,6 +29,8 @@ import MenuIcon from '@material-ui/icons/Menu';
2729
import SearchIcon from '@material-ui/icons/Search';
2830
import { MyGroupsSidebarItem } from '@backstage/plugin-org';
2931
import GroupIcon from '@material-ui/icons/People';
32+
import { Administration } from '@backstage-community/plugin-rbac';
33+
import { Shortcuts } from '@backstage-community/plugin-shortcuts';
3034

3135
const useSidebarLogoStyles = makeStyles({
3236
root: {
@@ -66,7 +70,8 @@ export const Root = ({ children }: PropsWithChildren<{}>) => (
6670
<SidebarDivider />
6771
<SidebarGroup label="Menu" icon={<MenuIcon />}>
6872
{/* Global nav, not org-specific */}
69-
<SidebarItem icon={HomeIcon} to="catalog" text="Home" />
73+
<SidebarItem icon={HomeIcon} to="/" text="Home" />
74+
<SidebarItem icon={CategoryIcon} to="catalog" text="Catalog" />
7075
<MyGroupsSidebarItem
7176
singularTitle="My Group"
7277
pluralTitle="My Groups"
@@ -75,13 +80,16 @@ export const Root = ({ children }: PropsWithChildren<{}>) => (
7580
<SidebarItem icon={ExtensionIcon} to="api-docs" text="APIs" />
7681
<SidebarItem icon={LibraryBooks} to="docs" text="Docs" />
7782
<SidebarItem icon={CreateComponentIcon} to="create" text="Create..." />
83+
<SidebarItem icon={LayersIcon} to="explore" text="Explore" />
7884
{/* End global nav */}
7985
<SidebarDivider />
8086
<SidebarScrollWrapper>
8187
{/* Items in this group will be scrollable if they run out of space */}
8288
</SidebarScrollWrapper>
8389
</SidebarGroup>
8490
<SidebarSpace />
91+
{/* <SidebarItem icon={PlaylistPlayIcon} to="playlist" text="Playlists" /> */}
92+
<Shortcuts allowExternalLinks={true} />
8593
<SidebarDivider />
8694
<SidebarGroup
8795
label="Settings"
@@ -90,6 +98,7 @@ export const Root = ({ children }: PropsWithChildren<{}>) => (
9098
>
9199
<SidebarSettings />
92100
</SidebarGroup>
101+
<Administration />
93102
</Sidebar>
94103
{children}
95104
</SidebarPage>

0 commit comments

Comments
 (0)