Merge branch 'backstage:master' into jjung/fix-techdocs-extensions-docs

This commit is contained in:
Joshua Jung
2024-09-16 08:41:43 -05:00
committed by Joshua Jung
38 changed files with 781 additions and 937 deletions
+10 -4
View File
@@ -54,7 +54,7 @@ Once the host build is complete, we are ready to build our image. The following
`Dockerfile` is included when creating a new app with `@backstage/create-app`:
```dockerfile
FROM node:18-bookworm-slim
FROM node:20-bookworm-slim
# Set Python interpreter for `node-gyp` to use
ENV PYTHON=/usr/bin/python3
@@ -89,6 +89,9 @@ COPY --chown=node:node .yarnrc.yml ./
# This switches many Node.js dependencies to production mode.
ENV NODE_ENV=production
# This disables node snapshot for Node 20 to work with the Scaffolder
ENV NODE_OPTIONS "--no-node-snapshot"
# 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.
@@ -175,7 +178,7 @@ the repo root:
```dockerfile
# Stage 1 - Create yarn install skeleton layer
FROM node:18-bookworm-slim AS packages
FROM node:20-bookworm-slim AS packages
WORKDIR /app
COPY package.json yarn.lock ./
@@ -190,7 +193,7 @@ COPY plugins plugins
RUN find packages \! -name "package.json" -mindepth 2 -maxdepth 2 -exec rm -rf {} \+
# Stage 2 - Install dependencies and build packages
FROM node:18-bookworm-slim AS build
FROM node:20-bookworm-slim AS build
# Set Python interpreter for `node-gyp` to use
ENV PYTHON=/usr/bin/python3
@@ -230,7 +233,7 @@ RUN mkdir packages/backend/dist/skeleton packages/backend/dist/bundle \
&& tar xzf packages/backend/dist/bundle.tar.gz -C packages/backend/dist/bundle
# Stage 3 - Build the actual backend image and install production dependencies
FROM node:18-bookworm-slim
FROM node:20-bookworm-slim
# Set Python interpreter for `node-gyp` to use
ENV PYTHON=/usr/bin/python3
@@ -283,6 +286,9 @@ COPY --chown=node:node examples ./examples
# This switches many Node.js dependencies to production mode.
ENV NODE_ENV=production
# This disables node snapshot for Node 20 to work with the Scaffolder
ENV NODE_OPTIONS "--no-node-snapshot"
CMD ["node", "packages/backend", "--config", "app-config.yaml", "--config", "app-config.production.yaml"]
```
+2 -2
View File
@@ -28,7 +28,7 @@ The following two code snippets demonstrate this method. The first block of code
# yarn build:backend
#
# Once the commands have been run, you can build the image using `yarn build-image`
FROM node:18-bookworm-slim as build
FROM node:20-bookworm-slim as build
USER node
WORKDIR /app
@@ -43,7 +43,7 @@ RUN yarn tsc
# The configuration files here should match the one you use inside the Dockerfile below.
RUN yarn build:backend --config ../../app-config.yaml
FROM node:18-bookworm-slim
FROM node:20-bookworm-slim
# Install isolate-vm dependencies, these are needed by the @backstage/plugin-scaffolder-backend.
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
@@ -527,6 +527,8 @@ spec:
system: artist-engagement-portal
dependsOn:
- resource:default/artists-db
dependencyOf:
- component:default/artist-web-lookup
providesApis:
- artist-api
```
@@ -636,6 +638,17 @@ field is optional.
| [`Component`](#kind-component) | Same as this entity, typically `default` | [`dependsOn`, and reverse `dependencyOf`](well-known-relations.md#dependson-and-dependencyof) |
| [`Resource`](#kind-resource) | Same as this entity, typically `default` | [`dependsOn`, and reverse `dependencyOf`](well-known-relations.md#dependson-and-dependencyof) |
### `spec.dependencyOf` [optional]
An array of [entity references](references.md#string-references) to the
components and resources that the component is a dependency of, e.g. `artist-web-lookup`.
This field is optional.
| [`kind`](#apiversion-and-kind-required) | Default [`namespace`](#namespace-optional) | Generated [relation](well-known-relations.md) type |
| --------------------------------------- | ------------------------------------------ | --------------------------------------------------------------------------------------------- |
| [`Component`](#kind-component) | Same as this entity, typically `default` | [`dependencyOf`, and reverse `dependsOn`](well-known-relations.md#dependson-and-dependencyof) |
| [`Resource`](#kind-resource) | Same as this entity, typically `default` | [`dependencyOf`, and reverse `dependsOn`](well-known-relations.md#dependson-and-dependencyof) |
## Kind: Template
The following describes the following entity kind:
@@ -43,6 +43,7 @@ After running the command, the CLI will create a new directory with your new sca
Let's create a simple action that adds a new file and some contents that are passed as `input` to the function. Within the generated directory, locate the file at `src/actions/example/example.ts`. Feel free to rename this file along with its generated unit test. We will replace the existing placeholder code with our custom action code as follows:
```ts title="With Zod"
import { resolveSafeChildPath } from '@backstage/backend-plugin-api';
import { createTemplateAction } from '@backstage/plugin-scaffolder-node';
import fs from 'fs-extra';
import { z } from 'zod';
@@ -62,7 +63,7 @@ export const createNewFileAction = () => {
async handler(ctx) {
await fs.outputFile(
`${ctx.workspacePath}/${ctx.input.filename}`,
resolveSafeChildPath(ctx.workspacePath, ctx.input.filename),
ctx.input.contents,
);
},
@@ -90,6 +91,7 @@ The `createTemplateAction` takes an object which specifies the following:
You can also choose to define your custom action using JSON schema instead of `zod`:
```ts title="With JSON Schema"
import { resolveSafeChildPath } from '@backstage/backend-plugin-api';
import { createTemplateAction } from '@backstage/plugin-scaffolder-node';
import { writeFile } from 'fs';
@@ -118,7 +120,7 @@ export const createNewFileAction = () => {
async handler(ctx) {
const { signal } = ctx;
await writeFile(
`${ctx.workspacePath}/${ctx.input.filename}`,
resolveSafeChildPath(ctx.workspacePath, ctx.input.filename),
ctx.input.contents,
{ signal },
_ => {},
+1 -1
View File
@@ -420,7 +420,7 @@ The following is an example of a `Dockerfile` that can be used to package the
output of building a package with role `'backend'` into an image:
```Dockerfile
FROM node:18-bookworm-slim
FROM node:20-bookworm-slim
WORKDIR /app
COPY yarn.lock package.json packages/backend/dist/skeleton.tar.gz ./