Skip to content

Commit

Permalink
Upgrade 16 (#58)
Browse files Browse the repository at this point in the history
Upgraded to version 1.16.0 of backstage.
  • Loading branch information
MonicaG authored Nov 23, 2023
1 parent 8ac8c5d commit 75aa5b4
Show file tree
Hide file tree
Showing 12 changed files with 6,817 additions and 7,980 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ examples
*.github
*.log
*.git
**/.swc
1 change: 0 additions & 1 deletion app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ backend:
csp:
connect-src: [ "'self'", 'http:', 'https:' ]
img-src: [ "'self'", "*.gov.bc.ca", "data:" ]
script-src: [ "'self'", "*.gov.bc.ca" ]
frame-src: ["www.youtube.com"]
# Content-Security-Policy directives follow the Helmet format: https://helmetjs.github.io/#reference
# Default Helmet Content-Security-Policy values can be removed by setting the key to false
Expand Down
2 changes: 1 addition & 1 deletion backstage.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "1.14.2"
"version": "1.16.0"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
]
},
"devDependencies": {
"@backstage/cli": "^0.22.7",
"@backstage/cli": "^0.22.9",
"@spotify/prettier-config": "^12.0.0",
"concurrently": "^6.0.0",
"lerna": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/cypress/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"jest/expect-expect": [
"error",
{
"assertFunctionNames": ["expect", "cy.contains"]
"assertFunctionNames": ["expect", "cy.contains", "cy.**.should"]
}
]
}
Expand Down
54 changes: 27 additions & 27 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,33 @@
"cy:run": "cypress run --browser chrome"
},
"dependencies": {
"@backstage/app-defaults": "^1.3.1",
"@backstage/catalog-model": "^1.3.0",
"@backstage/cli": "^0.22.7",
"@backstage/core-app-api": "^1.8.0",
"@backstage/core-components": "^0.13.1",
"@backstage/core-plugin-api": "^1.5.1",
"@backstage/integration-react": "^1.1.13",
"@backstage/plugin-api-docs": "^0.9.4",
"@backstage/plugin-catalog": "^1.11.1",
"@backstage/plugin-catalog-common": "^1.0.13",
"@backstage/plugin-catalog-graph": "^0.2.30",
"@backstage/plugin-catalog-import": "^0.9.8",
"@backstage/plugin-catalog-react": "^1.6.0",
"@backstage/plugin-github-actions": "^0.5.18",
"@backstage/plugin-home": "^0.5.2",
"@backstage/plugin-org": "^0.6.8",
"@backstage/plugin-permission-react": "^0.4.12",
"@backstage/plugin-scaffolder": "^1.13.1",
"@backstage/plugin-search": "^1.3.1",
"@backstage/plugin-search-react": "^1.6.1",
"@backstage/plugin-stack-overflow": "^0.1.16",
"@backstage/plugin-tech-radar": "^0.6.4",
"@backstage/plugin-techdocs": "^1.6.3",
"@backstage/app-defaults": "^1.4.1",
"@backstage/catalog-model": "^1.4.1",
"@backstage/cli": "^0.22.9",
"@backstage/core-app-api": "^1.9.0",
"@backstage/core-components": "^0.13.3",
"@backstage/core-plugin-api": "^1.5.3",
"@backstage/integration-react": "^1.1.15",
"@backstage/plugin-api-docs": "^0.9.6",
"@backstage/plugin-catalog": "^1.12.0",
"@backstage/plugin-catalog-common": "^1.0.15",
"@backstage/plugin-catalog-graph": "^0.2.32",
"@backstage/plugin-catalog-import": "^0.9.10",
"@backstage/plugin-catalog-react": "^1.8.0",
"@backstage/plugin-github-actions": "^0.6.1",
"@backstage/plugin-home": "^0.5.4",
"@backstage/plugin-org": "^0.6.10",
"@backstage/plugin-permission-react": "^0.4.14",
"@backstage/plugin-scaffolder": "^1.14.1",
"@backstage/plugin-search": "^1.3.3",
"@backstage/plugin-search-react": "^1.6.3",
"@backstage/plugin-stack-overflow": "^0.1.18",
"@backstage/plugin-tech-radar": "^0.6.6",
"@backstage/plugin-techdocs": "^1.6.5",
"@backstage/plugin-techdocs-module-addons-contrib": "^1.0.18",
"@backstage/plugin-techdocs-react": "^1.1.6",
"@backstage/plugin-user-settings": "^0.7.3",
"@backstage/theme": "^0.3.0",
"@backstage/plugin-techdocs-react": "^1.1.8",
"@backstage/plugin-user-settings": "^0.7.5",
"@backstage/theme": "^0.4.1",
"@bcgov/bc-sans": "^2.0.0",
"@internal/plugin-analytics-module-snowplow": "^0.1.0",
"@app/plugin-toc-fix2": "0.0.0",
Expand All @@ -62,7 +62,7 @@
"styled-components": "^6.0.0-rc.3"
},
"devDependencies": {
"@backstage/test-utils": "^1.3.1",
"@backstage/test-utils": "^1.4.1",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^14.0.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ const app = createApp({
bind(catalogPlugin.externalRoutes, {
createComponent: scaffolderPlugin.routes.root,
viewTechDoc: techdocsPlugin.routes.docRoot,
createFromTemplate: scaffolderPlugin.routes.selectedTemplate,
});

bind(scaffolderPlugin.externalRoutes, {
viewTechDoc: techdocsPlugin.routes.docRoot,
});

bind(orgPlugin.externalRoutes, {
catalogIndex: catalogPlugin.routes.catalogIndex,
});
Expand Down
10 changes: 10 additions & 0 deletions packages/app/src/components/catalog/EntityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
isKind,
hasCatalogProcessingErrors,
isOrphan,
hasRelationWarnings,
EntityRelationWarning,
} from '@backstage/plugin-catalog';
import {
isGithubActionsAvailable,
Expand Down Expand Up @@ -101,6 +103,14 @@ const entityWarningContent = (
</EntitySwitch.Case>
</EntitySwitch>

<EntitySwitch>
<EntitySwitch.Case if={hasRelationWarnings}>
<Grid item xs={12}>
<EntityRelationWarning />
</Grid>
</EntitySwitch.Case>
</EntitySwitch>

<EntitySwitch>
<EntitySwitch.Case if={hasCatalogProcessingErrors}>
<Grid item xs={12}>
Expand Down
99 changes: 49 additions & 50 deletions packages/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,79 +1,78 @@
# From https://github.com/janus-idp/backstage-showcase/
# Stage 1 - Install dependencies
FROM registry.access.redhat.com/ubi9/nodejs-18:latest AS deps
# Stage 1 - Build nodejs skeleton

FROM registry.access.redhat.com/ubi9/nodejs-18:1-80.1699550448 AS skeleton
USER 0

RUN dnf install -y -q --allowerasing --nobest \
python3 gcc gcc-c++ zlib-devel brotli-devel openssl-devel && \
dnf update -y && dnf clean all


# Env vars
ENV YARN=./.yarn/releases/yarn-1.22.19.cjs
ENV REMOTE_SOURCES=.
ENV REMOTE_SOURCES_DIR=/opt/app-root/src
ENV EXTERNAL_SOURCE=.
ENV CONTAINER_SOURCE=/opt/app-root/src

WORKDIR $REMOTE_SOURCES_DIR/
COPY $REMOTE_SOURCES $REMOTE_SOURCES_DIR
RUN chmod +x $REMOTE_SOURCES_DIR/.yarn/releases/yarn-1.22.19.cjs
WORKDIR $CONTAINER_SOURCE/
COPY $EXTERNAL_SOURCE/.yarn ./.yarn
COPY $EXTERNAL_SOURCE/.yarnrc.yml ./
RUN chmod +x "$YARN"

# Remove all files except package.json
RUN find packages -mindepth 2 -maxdepth 2 \! -name "package.json" -exec rm -rf {} \+
# Stage 2 - Install dependencies
FROM skeleton AS deps

RUN $YARN install --frozen-lockfile --network-timeout 600000 --ignore-scripts
COPY $EXTERNAL_SOURCE/package.json $EXTERNAL_SOURCE/yarn.lock ./
COPY $EXTERNAL_SOURCE/packages/app/package.json ./packages/app/package.json
COPY $EXTERNAL_SOURCE/packages/backend/package.json ./packages/backend/package.json
COPY $EXTERNAL_SOURCE/plugins/ ./plugins/

# Stage 2 - Build packages
FROM registry.access.redhat.com/ubi9/nodejs-18:latest AS build
USER 0
RUN "$YARN" install --frozen-lockfile --network-timeout 600000

# Env vars
ENV YARN=./.yarn/releases/yarn-1.22.19.cjs
ENV REMOTE_SOURCES=.
ENV REMOTE_SOURCES_DIR=/opt/app-root/src
# Stage 3 - Build packages
FROM deps AS build

WORKDIR $REMOTE_SOURCES_DIR/
COPY $REMOTE_SOURCES $REMOTE_SOURCES_DIR
COPY --from=deps $REMOTE_SOURCES_DIR $REMOTE_SOURCES_DIR
RUN chmod +x $REMOTE_SOURCES_DIR/.yarn/releases/yarn-1.22.19.cjs
RUN git config --global --add safe.directory $REMOTE_SOURCES_DIR/
COPY $EXTERNAL_SOURCE ./
RUN git config --global --add safe.directory ./

RUN $YARN tsc
RUN $YARN build:backend

# Stage 3 - Build the actual backend image and install production dependencies
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1 AS runner
USER 0

# Install gzip for tar and clean up
RUN microdnf install -y gzip && microdnf clean all

# Env vars
ENV YARN=./.yarn/releases/yarn-1.22.19.cjs
ENV REMOTE_SOURCES=.
ENV REMOTE_SOURCES_DIR=/opt/app-root/src

WORKDIR $REMOTE_SOURCES_DIR/
COPY --from=build --chown=1001:1001 $REMOTE_SOURCES_DIR/.yarn $REMOTE_SOURCES_DIR/.yarn
COPY --from=build --chown=1001:1001 $REMOTE_SOURCES_DIR/.yarnrc.yml $REMOTE_SOURCES_DIR/
RUN chmod +x $REMOTE_SOURCES_DIR/.yarn/releases/yarn-1.22.19.cjs
# Stage 4 - Build the actual backend image and install production dependencies
FROM skeleton AS cleanup

# Copy the install dependencies from the build stage and context
COPY --from=build --chown=1001:1001 $REMOTE_SOURCES_DIR/yarn.lock $REMOTE_SOURCES_DIR/package.json $REMOTE_SOURCES_DIR/packages/backend/dist/skeleton.tar.gz $REMOTE_SOURCES_DIR/
COPY --from=build $CONTAINER_SOURCE/yarn.lock $CONTAINER_SOURCE/package.json $CONTAINER_SOURCE/packages/backend/dist/skeleton.tar.gz ./
RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz

# Copy the built packages from the build stage
COPY --from=build --chown=1001:1001 $REMOTE_SOURCES_DIR/packages/backend/dist/bundle.tar.gz $REMOTE_SOURCES_DIR/
RUN tar xzf $REMOTE_SOURCES_DIR/bundle.tar.gz && rm $REMOTE_SOURCES_DIR/bundle.tar.gz
COPY --from=build $CONTAINER_SOURCE/packages/backend/dist/bundle.tar.gz ./
RUN tar xzf bundle.tar.gz && rm bundle.tar.gz

# Copy any other files that we need at runtime
COPY --chown=1001:1001 $REMOTE_SOURCES/app-config.yaml \
$REMOTE_SOURCES/app-config.production.yaml \
$REMOTE_SOURCES/catalog-info.yaml \
$REMOTE_SOURCES/catalog-seed.yaml $REMOTE_SOURCES_DIR/
# Copy app-config files needed in runtime
COPY $EXTERNAL_SOURCE/app-config.yaml \
$EXTERNAL_SOURCE/app-config.production.yaml \
$EXTERNAL_SOURCE/catalog-info.yaml \
$EXTERNAL_SOURCE/catalog-seed.yaml ./

# Install production dependencies
RUN $YARN install --frozen-lockfile --production --network-timeout 600000 --ignore-scripts && $YARN cache clean
RUN "$YARN" install --frozen-lockfile --production --network-timeout 600000 && "$YARN" cache clean

# Stage 5 - Build the runner image
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-85.1699549021 AS runner
USER 0

# Env vars
ENV YARN=./.yarn/releases/yarn-1.22.19.cjs
ENV CONTAINER_SOURCE=/opt/app-root/src

WORKDIR $CONTAINER_SOURCE/
COPY --from=cleanup --chown=1001:1001 $CONTAINER_SOURCE/ ./

# The fix-permissions script is important when operating in environments that dynamically use a random UID at runtime, such as OpenShift.
# The upstream backstage image does not account for this and it causes the container to fail at runtime.
RUN fix-permissions $REMOTE_SOURCES_DIR/

RUN fix-permissions ./
# Switch to nodejs user
USER 1001

ENTRYPOINT ["node", "packages/backend", "--config", "app-config.yaml", "--config", "app-config.production.yaml"]
42 changes: 22 additions & 20 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,36 @@
"build-image": "docker build ../.. -f Dockerfile --tag backstage"
},
"dependencies": {
"@backstage/backend-common": "^0.18.5",
"@backstage/backend-tasks": "^0.5.2",
"@backstage/catalog-client": "^1.4.1",
"@backstage/catalog-model": "^1.3.0",
"@backstage/config": "^1.0.7",
"@backstage/plugin-app-backend": "^0.3.45",
"@backstage/plugin-auth-backend": "^0.18.3",
"@backstage/plugin-auth-node": "^0.2.14",
"@backstage/plugin-catalog-backend": "^1.9.1",
"@backstage/plugin-catalog-backend-module-github": "^0.3.0",
"@backstage/plugin-permission-common": "^0.7.5",
"@backstage/plugin-permission-node": "^0.7.8",
"@backstage/plugin-proxy-backend": "^0.2.39",
"@backstage/plugin-scaffolder-backend": "^1.14.0",
"@backstage/plugin-search-backend": "^1.3.1",
"@backstage/plugin-search-backend-module-pg": "^0.5.6",
"@backstage/plugin-search-backend-node": "^1.2.1",
"@backstage/backend-common": "^0.19.1",
"@backstage/backend-tasks": "^0.5.4",
"@backstage/catalog-client": "^1.4.3",
"@backstage/catalog-model": "^1.4.1",
"@backstage/config": "^1.0.8",
"@backstage/plugin-app-backend": "^0.3.47",
"@backstage/plugin-auth-backend": "^0.20.0",
"@backstage/plugin-auth-node": "^0.2.16",
"@backstage/plugin-catalog-backend": "^1.11.0",
"@backstage/plugin-catalog-backend-module-github": "^0.3.2",
"@backstage/plugin-permission-common": "^0.7.7",
"@backstage/plugin-permission-node": "^0.7.10",
"@backstage/plugin-proxy-backend": "^0.4.5",
"@backstage/plugin-scaffolder-backend": "^1.15.1",
"@backstage/plugin-search-backend": "^1.3.3",
"@backstage/plugin-search-backend-module-pg": "^0.5.8",
"@backstage/plugin-search-backend-node": "^1.2.3",
"@backstage/plugin-stack-overflow-backend": "^0.2.6",
"@backstage/plugin-techdocs-backend": "^1.6.2",
"@backstage/plugin-techdocs-backend": "^1.6.4",
"app": "link:../app",
"dockerode": "^3.3.1",
"express": "^4.17.1",
"express-promise-router": "^4.1.0",
"pg": "^8.10.0",
"winston": "^3.2.1"
"winston": "^3.2.1",
"node-gyp": "^9.0.0",
"isolated-vm": "4.6.0"
},
"devDependencies": {
"@backstage/cli": "^0.22.7",
"@backstage/cli": "^0.22.9",
"@types/dockerode": "^3.3.0",
"@types/express": "^4.17.6",
"@types/express-serve-static-core": "^4.17.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
notFoundHandler,
CacheManager,
DatabaseManager,
SingleHostDiscovery,
HostDiscovery,
UrlReaders,
ServerTokenManager,
} from '@backstage/backend-common';
Expand All @@ -35,7 +35,7 @@ import { DefaultIdentityClient } from '@backstage/plugin-auth-node';
function makeCreateEnv(config: Config) {
const root = getRootLogger();
const reader = UrlReaders.default({ logger: root, config });
const discovery = SingleHostDiscovery.fromConfig(config);
const discovery = HostDiscovery.fromConfig(config);
const cacheManager = CacheManager.fromConfig(config);
const databaseManager = DatabaseManager.fromConfig(config, { logger: root });
const tokenManager = ServerTokenManager.noop();
Expand Down
Loading

0 comments on commit 75aa5b4

Please sign in to comment.