change
This commit is contained in:
222
dev/backstage/setup/setup-with-techdocs.sh
Executable file
222
dev/backstage/setup/setup-with-techdocs.sh
Executable file
@@ -0,0 +1,222 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# ------------------------
|
||||
# Load NVM
|
||||
# ------------------------
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
|
||||
# Use Node 20
|
||||
nvm use 20
|
||||
|
||||
# ------------------------
|
||||
# Configuration
|
||||
# ------------------------
|
||||
APP_NAME="backstage"
|
||||
APP_DIR="$PWD/$APP_NAME"
|
||||
|
||||
echo "=== 1. Creating Backstage app ==="
|
||||
# Use --ignore-existing to avoid cached/missing binaries
|
||||
npx --ignore-existing @backstage/create-app@latest "$APP_DIR"
|
||||
|
||||
cd "$APP_DIR"
|
||||
|
||||
echo "=== 2. Bumping Backstage version to 1.42.1 ==="
|
||||
yarn backstage-cli versions:bump --release 1.42.1
|
||||
|
||||
echo "=== 3. Installing plugin dependencies (Yarn 4 compatible) ==="
|
||||
# Backend plugins
|
||||
yarn --cwd packages/backend add \
|
||||
@backstage/plugin-techdocs-backend \
|
||||
@backstage/plugin-catalog-backend-module-github \
|
||||
@backstage/plugin-catalog-backend-module-gitea \
|
||||
@backstage/plugin-devtools-backend
|
||||
# Frontend plugins
|
||||
yarn --cwd packages/app add \
|
||||
@backstage/plugin-techdocs \
|
||||
@backstage/plugin-catalog \
|
||||
@backstage/plugin-catalog-graph \
|
||||
@backstage/plugin-techdocs-module-addons-contrib
|
||||
|
||||
echo "=== 4. Patching backend/src/index.ts ==="
|
||||
BACKEND_FILE=packages/backend/src/index.ts
|
||||
cat > "$BACKEND_FILE" <<'EOF'
|
||||
import { createBackend } from '@backstage/backend-defaults';
|
||||
import { createBackendFeatureLoader } from '@backstage/backend-plugin-api';
|
||||
|
||||
const backend = createBackend();
|
||||
|
||||
// Catalog
|
||||
backend.add(import('@backstage/plugin-catalog-backend'));
|
||||
backend.add(import('@backstage/plugin-catalog-backend-module-scaffolder-entity-model'));
|
||||
backend.add(import('@backstage/plugin-catalog-backend-module-unprocessed'));
|
||||
backend.add(import('@backstage/plugin-catalog-backend-module-github'));
|
||||
backend.add(import('@backstage/plugin-catalog-backend-module-gitea'));
|
||||
backend.add(import('@backstage/plugin-devtools-backend'));
|
||||
// Scaffolder
|
||||
backend.add(import('@backstage/plugin-scaffolder-backend'));
|
||||
backend.add(import('@backstage/plugin-scaffolder-backend-module-github'));
|
||||
backend.add(import('@backstage/plugin-scaffolder-backend-module-notifications'));
|
||||
|
||||
// Auth
|
||||
backend.add(import('@backstage/plugin-auth-backend'));
|
||||
backend.add(import('@backstage/plugin-auth-backend-module-guest-provider'));
|
||||
|
||||
// TechDocs
|
||||
backend.add(import('@backstage/plugin-techdocs-backend'));
|
||||
|
||||
// Kubernetes
|
||||
backend.add(import('@backstage/plugin-kubernetes-backend'));
|
||||
|
||||
// Search
|
||||
const searchLoader = createBackendFeatureLoader({
|
||||
*loader() {
|
||||
yield import('@backstage/plugin-search-backend');
|
||||
yield import('@backstage/plugin-search-backend-module-catalog');
|
||||
yield import('@backstage/plugin-search-backend-module-techdocs');
|
||||
},
|
||||
});
|
||||
backend.add(searchLoader);
|
||||
|
||||
// Misc
|
||||
backend.add(import('@backstage/plugin-devtools-backend'));
|
||||
backend.add(import('@backstage/plugin-app-backend'));
|
||||
backend.add(import('@backstage/plugin-proxy-backend'));
|
||||
backend.add(import('@backstage/plugin-permission-backend'));
|
||||
backend.add(import('@backstage/plugin-permission-backend-module-allow-all-policy'));
|
||||
backend.add(import('@backstage/plugin-notifications-backend'));
|
||||
backend.add(import('@backstage/plugin-events-backend'));
|
||||
|
||||
backend.start();
|
||||
EOF
|
||||
echo "✓ Backend patched."
|
||||
|
||||
echo "=== 5. Patching packages/app/src/App.tsx ==="
|
||||
APP_FILE=packages/app/src/App.tsx
|
||||
cat > "$APP_FILE" <<'EOF'
|
||||
import React from 'react';
|
||||
import { createApp } from '@backstage/app-defaults';
|
||||
import { FlatRoutes } from '@backstage/core-app-api';
|
||||
import { Route, Navigate } from 'react-router-dom';
|
||||
|
||||
import { CatalogIndexPage, CatalogEntityPage } from '@backstage/plugin-catalog';
|
||||
import { CatalogGraphPage } from '@backstage/plugin-catalog-graph';
|
||||
import { ApiExplorerPage } from '@backstage/plugin-api-docs';
|
||||
|
||||
import { TechDocsIndexPage, TechDocsReaderPage } from '@backstage/plugin-techdocs';
|
||||
import { ScaffolderPage } from '@backstage/plugin-scaffolder';
|
||||
import { SearchPage } from '@backstage/plugin-search';
|
||||
import { UserSettingsPage } from '@backstage/plugin-user-settings';
|
||||
|
||||
const app = createApp();
|
||||
|
||||
const routes = (
|
||||
<FlatRoutes>
|
||||
<Route path="/" element={<Navigate to="/catalog" />} />
|
||||
|
||||
<Route path="/catalog" element={<CatalogIndexPage />} />
|
||||
<Route path="/catalog/:namespace/:kind/:name" element={<CatalogEntityPage />} />
|
||||
|
||||
<Route path="/catalog-graph" element={<CatalogGraphPage />} />
|
||||
|
||||
<Route path="/api-docs" element={<ApiExplorerPage />} />
|
||||
|
||||
<Route path="/docs" element={<TechDocsIndexPage />} />
|
||||
<Route path="/docs/:namespace/:kind/:name/*" element={<TechDocsReaderPage />} />
|
||||
|
||||
<Route path="/search" element={<SearchPage />} />
|
||||
|
||||
<Route path="/create" element={<ScaffolderPage />} />
|
||||
|
||||
<Route path="/settings" element={<UserSettingsPage />} />
|
||||
</FlatRoutes>
|
||||
);
|
||||
|
||||
export default app.createRoot(routes);
|
||||
EOF
|
||||
echo "✓ App.tsx patched."
|
||||
|
||||
echo "=== 6. Installing all dependencies ==="
|
||||
# Yarn 4 uses --immutable instead of --frozen-lockfile
|
||||
yarn install --immutable
|
||||
|
||||
echo "=== 7. Building backend artifacts ==="
|
||||
yarn workspace backend build
|
||||
|
||||
# Verify the build output
|
||||
if [ ! -f packages/backend/dist/bundle.tar.gz ] || [ ! -f packages/backend/dist/skeleton.tar.gz ]; then
|
||||
echo "❌ Backend build failed: required files not found!"
|
||||
exit 1
|
||||
fi
|
||||
echo "✓ Backend build complete."
|
||||
|
||||
# -----------------------------
|
||||
# 8a. Patch backend Dockerfile to include TechDocs/MkDocs + Yarn 4 support
|
||||
# -----------------------------
|
||||
DOCKERFILE=packages/backend/Dockerfile
|
||||
cat > "$DOCKERFILE" <<'EOF'
|
||||
# This dockerfile builds an image for the backend package.
|
||||
# It should be executed with the root of the repo as docker context.
|
||||
#
|
||||
# Before building this image, be sure to have run the following commands in the repo root:
|
||||
#
|
||||
# yarn install
|
||||
# yarn tsc
|
||||
# yarn build:backend
|
||||
#
|
||||
# Once the commands have been run, you can build the image using `yarn build-image`
|
||||
|
||||
FROM node:20-bookworm-slim
|
||||
|
||||
# Install sqlite3 dependencies. You can skip this if you don't use sqlite3 in the image,
|
||||
# in which case you should also move better-sqlite3 to "devDependencies" in package.json.
|
||||
# Additionally, we install dependencies for `techdocs.generator.runIn: local`.
|
||||
# https://backstage.io/docs/features/techdocs/getting-started#disabling-docker-in-docker-situation-optional
|
||||
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends libsqlite3-dev python3 python3-pip python3-venv build-essential && \
|
||||
yarn config set python /usr/bin/python3
|
||||
|
||||
# Set up a virtual environment for mkdocs-techdocs-core.
|
||||
ENV VIRTUAL_ENV=/opt/venv
|
||||
RUN python3 -m venv $VIRTUAL_ENV
|
||||
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||
|
||||
RUN pip3 install mkdocs-techdocs-core==1.1.7
|
||||
|
||||
# From here on we use the least-privileged `node` user to run the backend.
|
||||
WORKDIR /app
|
||||
RUN chown node:node /app
|
||||
USER node
|
||||
|
||||
|
||||
# This switches many Node.js dependencies to production mode.
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Copy over Yarn 3 configuration, release, and plugins
|
||||
COPY --chown=node:node .yarn ./.yarn
|
||||
COPY --chown=node:node .yarnrc.yml ./
|
||||
|
||||
# Copy repo skeleton first, to avoid unnecessary docker cache invalidation.
|
||||
# The skeleton contains the package.json of each package in the monorepo,
|
||||
# and along with yarn.lock and the root package.json, that's enough to run yarn install.
|
||||
COPY --chown=node:node yarn.lock package.json packages/backend/dist/skeleton.tar.gz ./
|
||||
RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz
|
||||
|
||||
RUN --mount=type=cache,target=/home/node/.yarn/berry/cache,sharing=locked,uid=1000,gid=1000 \
|
||||
yarn workspaces focus --all --production
|
||||
|
||||
# Then copy the rest of the backend bundle, along with any other files we might want.
|
||||
COPY --chown=node:node packages/backend/dist/bundle.tar.gz app-config*.yaml ./
|
||||
RUN tar xzf bundle.tar.gz && rm bundle.tar.gz
|
||||
|
||||
CMD ["node", "packages/backend", "--config", "app-config.yaml"]
|
||||
EOF
|
||||
echo "✓ Backend Dockerfile patched with TechDocs + Yarn 4 support."
|
||||
echo "=== 8. Building backend Docker image ==="
|
||||
yarn workspace backend build-image
|
||||
|
||||
echo "✅ Backstage 1.42.1 setup complete with TechDocs!"
|
||||
echo "Run with: docker run -p 7007:7007 <image_name>"
|
||||
178
dev/backstage/setup/setup.sh
Executable file
178
dev/backstage/setup/setup.sh
Executable file
@@ -0,0 +1,178 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# ------------------------
|
||||
# Configuration
|
||||
# ------------------------
|
||||
APP_NAME="backstage"
|
||||
APP_DIR="$PWD/$APP_NAME"
|
||||
BACKSTAGE_RELEASE="1.42.1"
|
||||
NODE_VERSION_MIN=18
|
||||
|
||||
echo
|
||||
echo "=== Backstage automated setup script ==="
|
||||
echo "App dir: $APP_DIR"
|
||||
echo "Target Backstage release: $BACKSTAGE_RELEASE"
|
||||
echo
|
||||
|
||||
# Quick environment checks
|
||||
command -v node >/dev/null 2>&1 || echo "Warning: node not found (need >= ${NODE_VERSION_MIN})"
|
||||
command -v yarn >/dev/null 2>&1 || echo "Warning: yarn not found"
|
||||
|
||||
# ------------------------
|
||||
# 1) Create Backstage app
|
||||
# ------------------------
|
||||
if [ -d "$APP_DIR" ]; then
|
||||
echo "Directory $APP_DIR already exists — aborting to avoid overwriting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== 1) Creating Backstage app ==="
|
||||
npx --ignore-existing @backstage/create-app@latest "$APP_DIR"
|
||||
cd "$APP_DIR"
|
||||
|
||||
# ------------------------
|
||||
# 2) Bump Backstage versions
|
||||
# ------------------------
|
||||
echo "=== 2) Bumping Backstage packages to release $BACKSTAGE_RELEASE ==="
|
||||
yarn backstage-cli versions:bump --release "$BACKSTAGE_RELEASE"
|
||||
|
||||
# ------------------------
|
||||
# 3) Install backend plugins
|
||||
# ------------------------
|
||||
echo "=== 3) Installing backend plugins ==="
|
||||
yarn --cwd packages/backend add \
|
||||
@backstage/plugin-catalog-backend \
|
||||
@backstage/plugin-catalog-backend-module-scaffolder-entity-model \
|
||||
@backstage/plugin-catalog-backend-module-unprocessed \
|
||||
@backstage/plugin-catalog-backend-module-github \
|
||||
@backstage/plugin-catalog-backend-module-gitea \
|
||||
@backstage/plugin-scaffolder-backend \
|
||||
@backstage/plugin-scaffolder-backend-module-github \
|
||||
@backstage/plugin-scaffolder-backend-module-notifications \
|
||||
@backstage/plugin-auth-backend \
|
||||
@backstage/plugin-techdocs-backend \
|
||||
@backstage/plugin-kubernetes-backend \
|
||||
@backstage/plugin-devtools-backend \
|
||||
@backstage/plugin-app-backend \
|
||||
@backstage/plugin-proxy-backend \
|
||||
@backstage/plugin-permission-backend \
|
||||
@backstage/plugin-permission-backend-module-allow-all-policy \
|
||||
@backstage/plugin-notifications-backend \
|
||||
@backstage/plugin-events-backend \
|
||||
@backstage/plugin-search-backend \
|
||||
@backstage/plugin-search-backend-module-catalog \
|
||||
@backstage/plugin-search-backend-module-techdocs
|
||||
|
||||
# ------------------------
|
||||
# 4) Install frontend plugins
|
||||
# ------------------------
|
||||
echo "=== 4) Installing frontend plugins ==="
|
||||
yarn --cwd packages/app add \
|
||||
@backstage/plugin-catalog \
|
||||
@backstage/plugin-catalog-graph \
|
||||
@backstage/plugin-catalog-import \
|
||||
@backstage/plugin-techdocs \
|
||||
@backstage/plugin-techdocs-module-addons-contrib \
|
||||
@backstage/plugin-scaffolder \
|
||||
@backstage/plugin-user-settings \
|
||||
@backstage/plugin-search \
|
||||
@backstage/plugin-api-docs \
|
||||
@backstage/plugin-org
|
||||
|
||||
# ------------------------
|
||||
# 5) Patch backend index.ts with static imports
|
||||
# ------------------------
|
||||
echo "=== 5) Patching backend index.ts ==="
|
||||
BACKEND_FILE="packages/backend/src/index.ts"
|
||||
|
||||
mkdir -p "$(dirname "$BACKEND_FILE")"
|
||||
|
||||
cat > "$BACKEND_FILE" <<'EOF'
|
||||
import { createBackend } from '@backstage/backend-defaults';
|
||||
import { createBackendFeatureLoader } from '@backstage/backend-plugin-api';
|
||||
|
||||
import appBackend from '@backstage/plugin-app-backend';
|
||||
import catalogBackend from '@backstage/plugin-catalog-backend';
|
||||
import catalogScaffolderEntityModel from '@backstage/plugin-catalog-backend-module-scaffolder-entity-model';
|
||||
import catalogUnprocessed from '@backstage/plugin-catalog-backend-module-unprocessed';
|
||||
import catalogGithub from '@backstage/plugin-catalog-backend-module-github';
|
||||
import catalogGitea from '@backstage/plugin-catalog-backend-module-gitea';
|
||||
import scaffolderBackend from '@backstage/plugin-scaffolder-backend';
|
||||
import scaffolderGithub from '@backstage/plugin-scaffolder-backend-module-github';
|
||||
import scaffolderNotifications from '@backstage/plugin-scaffolder-backend-module-notifications';
|
||||
import authBackend from '@backstage/plugin-auth-backend';
|
||||
import techdocsBackend from '@backstage/plugin-techdocs-backend';
|
||||
import kubernetesBackend from '@backstage/plugin-kubernetes-backend';
|
||||
import devtoolsBackend from '@backstage/plugin-devtools-backend';
|
||||
import proxyBackend from '@backstage/plugin-proxy-backend';
|
||||
import permissionBackend from '@backstage/plugin-permission-backend';
|
||||
import allowAllPolicy from '@backstage/plugin-permission-backend-module-allow-all-policy';
|
||||
import notificationsBackend from '@backstage/plugin-notifications-backend';
|
||||
import eventsBackend from '@backstage/plugin-events-backend';
|
||||
|
||||
const backend = createBackend();
|
||||
|
||||
backend.add(appBackend);
|
||||
backend.add(catalogBackend);
|
||||
backend.add(catalogScaffolderEntityModel);
|
||||
backend.add(catalogUnprocessed);
|
||||
backend.add(catalogGithub);
|
||||
backend.add(catalogGitea);
|
||||
|
||||
backend.add(scaffolderBackend);
|
||||
backend.add(scaffolderGithub);
|
||||
backend.add(scaffolderNotifications);
|
||||
|
||||
backend.add(authBackend);
|
||||
|
||||
backend.add(techdocsBackend);
|
||||
backend.add(kubernetesBackend);
|
||||
|
||||
backend.add(devtoolsBackend);
|
||||
backend.add(proxyBackend);
|
||||
backend.add(permissionBackend);
|
||||
backend.add(allowAllPolicy);
|
||||
backend.add(notificationsBackend);
|
||||
backend.add(eventsBackend);
|
||||
|
||||
const searchLoader = createBackendFeatureLoader({
|
||||
*loader() {
|
||||
yield import('@backstage/plugin-search-backend');
|
||||
yield import('@backstage/plugin-search-backend-module-catalog');
|
||||
yield import('@backstage/plugin-search-backend-module-techdocs');
|
||||
},
|
||||
});
|
||||
backend.add(searchLoader);
|
||||
|
||||
backend.start();
|
||||
EOF
|
||||
|
||||
echo "✓ Backend index.ts patched."
|
||||
|
||||
# ------------------------
|
||||
# 6) Do NOT overwrite App.tsx
|
||||
# ------------------------
|
||||
echo "=== 6) Preserving existing App.tsx ==="
|
||||
|
||||
# ------------------------
|
||||
# 7) Install workspace dependencies
|
||||
# ------------------------
|
||||
echo "=== 7) Installing workspace dependencies ==="
|
||||
yarn install
|
||||
|
||||
# ------------------------
|
||||
# 8) Build backend bundle
|
||||
# ------------------------
|
||||
echo "=== 8) Building backend bundle ==="
|
||||
yarn workspace backend build
|
||||
|
||||
# ------------------------
|
||||
# 9) Build Docker image
|
||||
# ------------------------
|
||||
echo "=== 9) Building backend Docker image ==="
|
||||
yarn workspace backend build-image
|
||||
|
||||
echo "=== DONE ==="
|
||||
echo "Backstage app created at: $APP_DIR"
|
||||
echo "Docker image built successfully. Run with: docker run -p 7007:7007 <image_name>"
|
||||
205
dev/backstage/setup/setup3.sh
Executable file
205
dev/backstage/setup/setup3.sh
Executable file
@@ -0,0 +1,205 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# ------------------------
|
||||
# Configuration
|
||||
# ------------------------
|
||||
APP_NAME="backstage"
|
||||
APP_DIR="$PWD/$APP_NAME"
|
||||
BACKSTAGE_RELEASE="1.42.1"
|
||||
NODE_VERSION_MIN=18
|
||||
|
||||
echo
|
||||
echo "=== Backstage automated setup script ==="
|
||||
echo "App dir: $APP_DIR"
|
||||
echo "Target Backstage release: $BACKSTAGE_RELEASE"
|
||||
echo
|
||||
|
||||
# Quick environment checks
|
||||
command -v node >/dev/null 2>&1 || echo "Warning: node not found (need >= ${NODE_VERSION_MIN})"
|
||||
command -v yarn >/dev/null 2>&1 || echo "Warning: yarn not found"
|
||||
|
||||
# ------------------------
|
||||
# 1) Create Backstage app
|
||||
# ------------------------
|
||||
if [ -d "$APP_DIR" ]; then
|
||||
echo "Directory $APP_DIR already exists — aborting to avoid overwriting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== 1) Creating Backstage app ==="
|
||||
npx --ignore-existing @backstage/create-app@latest "$APP_DIR"
|
||||
cd "$APP_DIR"
|
||||
|
||||
# ------------------------
|
||||
# 2) Bump Backstage versions
|
||||
# ------------------------
|
||||
echo "=== 2) Bumping Backstage packages to release $BACKSTAGE_RELEASE ==="
|
||||
yarn backstage-cli versions:bump --release "$BACKSTAGE_RELEASE"
|
||||
|
||||
# ------------------------
|
||||
# 3) Install backend plugins
|
||||
# ------------------------
|
||||
echo "=== 3) Installing backend plugins ==="
|
||||
yarn --cwd packages/backend add \
|
||||
@backstage/plugin-catalog-backend \
|
||||
@backstage/plugin-catalog-backend-module-scaffolder-entity-model \
|
||||
@backstage/plugin-catalog-backend-module-unprocessed \
|
||||
@backstage/plugin-catalog-backend-module-github \
|
||||
@backstage/plugin-catalog-backend-module-gitea \
|
||||
@backstage/plugin-scaffolder-backend \
|
||||
@backstage/plugin-scaffolder-backend-module-github \
|
||||
@backstage/plugin-scaffolder-backend-module-notifications \
|
||||
@backstage/plugin-auth-backend \
|
||||
@backstage/plugin-auth-backend-module-guest-provider \
|
||||
@backstage/plugin-techdocs-backend \
|
||||
@backstage/plugin-kubernetes-backend \
|
||||
@backstage/plugin-devtools-backend \
|
||||
@backstage/plugin-app-backend \
|
||||
@backstage/plugin-proxy-backend \
|
||||
@backstage/plugin-permission-backend \
|
||||
@backstage/plugin-permission-backend-module-allow-all-policy \
|
||||
@backstage/plugin-notifications-backend \
|
||||
@backstage/plugin-events-backend \
|
||||
@backstage/plugin-search-backend \
|
||||
@backstage/plugin-search-backend-module-catalog \
|
||||
@backstage/plugin-search-backend-module-techdocs
|
||||
|
||||
# ------------------------
|
||||
# 4) Install frontend plugins
|
||||
# ------------------------
|
||||
echo "=== 4) Installing frontend plugins ==="
|
||||
yarn --cwd packages/app add \
|
||||
@backstage/plugin-catalog \
|
||||
@backstage/plugin-catalog-graph \
|
||||
@backstage/plugin-catalog-import \
|
||||
@backstage/plugin-techdocs \
|
||||
@backstage/plugin-techdocs-module-addons-contrib \
|
||||
@backstage/plugin-scaffolder \
|
||||
@backstage/plugin-user-settings \
|
||||
@backstage/plugin-search \
|
||||
@backstage/plugin-api-docs \
|
||||
@backstage/plugin-org
|
||||
|
||||
# ------------------------
|
||||
# 5) Patch backend index.ts with static imports
|
||||
# ------------------------
|
||||
echo "=== 5) Patching backend index.ts ==="
|
||||
BACKEND_FILE="packages/backend/src/index.ts"
|
||||
|
||||
mkdir -p "$(dirname "$BACKEND_FILE")"
|
||||
|
||||
cat > "$BACKEND_FILE" <<'EOF'
|
||||
import { createBackend } from '@backstage/backend-defaults';
|
||||
import { createBackendFeatureLoader } from '@backstage/backend-plugin-api';
|
||||
|
||||
import appBackend from '@backstage/plugin-app-backend';
|
||||
import catalogBackend from '@backstage/plugin-catalog-backend';
|
||||
import catalogScaffolderEntityModel from '@backstage/plugin-catalog-backend-module-scaffolder-entity-model';
|
||||
import catalogUnprocessed from '@backstage/plugin-catalog-backend-module-unprocessed';
|
||||
import catalogGithub from '@backstage/plugin-catalog-backend-module-github';
|
||||
import catalogGitea from '@backstage/plugin-catalog-backend-module-gitea';
|
||||
import scaffolderBackend from '@backstage/plugin-scaffolder-backend';
|
||||
import scaffolderGithub from '@backstage/plugin-scaffolder-backend-module-github';
|
||||
import scaffolderNotifications from '@backstage/plugin-scaffolder-backend-module-notifications';
|
||||
import authBackend from '@backstage/plugin-auth-backend';
|
||||
import guestProvider from '@backstage/plugin-auth-backend-module-guest-provider';
|
||||
import techdocsBackend from '@backstage/plugin-techdocs-backend';
|
||||
import kubernetesBackend from '@backstage/plugin-kubernetes-backend';
|
||||
import devtoolsBackend from '@backstage/plugin-devtools-backend';
|
||||
import proxyBackend from '@backstage/plugin-proxy-backend';
|
||||
import permissionBackend from '@backstage/plugin-permission-backend';
|
||||
import allowAllPolicy from '@backstage/plugin-permission-backend-module-allow-all-policy';
|
||||
import notificationsBackend from '@backstage/plugin-notifications-backend';
|
||||
import eventsBackend from '@backstage/plugin-events-backend';
|
||||
|
||||
const backend = createBackend();
|
||||
|
||||
backend.add(appBackend);
|
||||
backend.add(catalogBackend);
|
||||
backend.add(catalogScaffolderEntityModel);
|
||||
backend.add(catalogUnprocessed);
|
||||
backend.add(catalogGithub);
|
||||
backend.add(catalogGitea);
|
||||
|
||||
backend.add(scaffolderBackend);
|
||||
backend.add(scaffolderGithub);
|
||||
backend.add(scaffolderNotifications);
|
||||
|
||||
backend.add(authBackend);
|
||||
backend.add(guestProvider);
|
||||
|
||||
backend.add(techdocsBackend);
|
||||
backend.add(kubernetesBackend);
|
||||
|
||||
backend.add(devtoolsBackend);
|
||||
backend.add(proxyBackend);
|
||||
backend.add(permissionBackend);
|
||||
backend.add(allowAllPolicy);
|
||||
backend.add(notificationsBackend);
|
||||
backend.add(eventsBackend);
|
||||
|
||||
const searchLoader = createBackendFeatureLoader({
|
||||
*loader() {
|
||||
yield import('@backstage/plugin-search-backend');
|
||||
yield import('@backstage/plugin-search-backend-module-catalog');
|
||||
yield import('@backstage/plugin-search-backend-module-techdocs');
|
||||
},
|
||||
});
|
||||
backend.add(searchLoader);
|
||||
|
||||
backend.start();
|
||||
EOF
|
||||
|
||||
echo "✓ Backend index.ts patched."
|
||||
|
||||
# ------------------------
|
||||
# 6) Do NOT overwrite App.tsx
|
||||
# ------------------------
|
||||
echo "=== 6) Preserving existing App.tsx ==="
|
||||
|
||||
# ------------------------
|
||||
# 7) Install workspace dependencies
|
||||
# ------------------------
|
||||
echo "=== 7) Installing workspace dependencies ==="
|
||||
yarn install
|
||||
|
||||
# ------------------------
|
||||
# 8) Build backend bundle
|
||||
# ------------------------
|
||||
echo "=== 8) Building backend bundle ==="
|
||||
yarn workspace backend build
|
||||
|
||||
# ------------------------
|
||||
# 9) Patch backend Dockerfile for TechDocs
|
||||
# ------------------------
|
||||
DOCKERFILE="packages/backend/Dockerfile"
|
||||
echo "=== Patching backend Dockerfile for TechDocs mkdocs ==="
|
||||
|
||||
# Insert mkdocs virtualenv only if not already patched
|
||||
if ! grep -q "VIRTUAL_ENV=/opt/venv" "$DOCKERFILE"; then
|
||||
cat >> "$DOCKERFILE" <<'EOF'
|
||||
|
||||
# --- TechDocs MkDocs virtualenv ---
|
||||
USER root
|
||||
RUN apt-get update && apt-get install -y python3 python3-pip python3-venv git build-essential && rm -rf /var/lib/apt/lists/*
|
||||
ENV VIRTUAL_ENV=/opt/venv
|
||||
RUN python3 -m venv $VIRTUAL_ENV
|
||||
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||
RUN pip3 install mkdocs-techdocs-core mkdocs-awesome-pages-plugin
|
||||
USER node
|
||||
EOF
|
||||
echo "✓ Dockerfile patched with mkdocs virtualenv"
|
||||
else
|
||||
echo "✓ Dockerfile already patched"
|
||||
fi
|
||||
|
||||
# ------------------------
|
||||
# 10) Build Docker image
|
||||
# ------------------------
|
||||
echo "=== 10) Building backend Docker image ==="
|
||||
yarn workspace backend build-image
|
||||
|
||||
echo "=== DONE ==="
|
||||
echo "Backstage app created at: $APP_DIR"
|
||||
echo "Docker image built successfully. Run with: docker run -p 7007:7007 <image_name>"
|
||||
Reference in New Issue
Block a user