Skip to content

Commit ba41609

Browse files
authored
Create Deployment Scripts for Both Dynamic-Plugin and Backstage-Standalone (#2830)
Create Deployment Scripts for Both Dynamic-Plugin and Backstage-Standalone
1 parent 4379c1a commit ba41609

13 files changed

Lines changed: 563 additions & 16 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-dcm': patch
3+
'@red-hat-developer-hub/backstage-plugin-dcm-backend': patch
4+
'@red-hat-developer-hub/backstage-plugin-dcm-common': patch
5+
---
6+
7+
Add Docker/Podman deployment support for the DCM plugin.
8+
9+
- Added `Dockerfile` (multi-stage build) to produce a standalone Backstage image
10+
- Added `app-config.production.yaml` for container runtime configuration
11+
- Added `scripts/generate-image.sh` (renamed from `dynamic-plugins.sh`) with commands to build and push both the OCI dynamic-plugin artifact and the full Backstage application image
12+
- Added `.dockerignore` to exclude sensitive and dev-only files from the build context
13+
- Configured guest auth (`dangerouslyAllowOutsideDevelopment`) for container environments
14+
- Skip SSO token exchange in the backend proxy when `clientId`/`clientSecret` are not set

workspaces/dcm/.dockerignore

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,32 @@
1-
.git
2-
.yarn/cache
1+
# ── Yarn install state ────────────────────────────────────────────────────────
32
.yarn/install-state.gz
3+
.pnp.*
4+
5+
# ── Local build artefacts ─────────────────────────────────────────────────────
46
node_modules
5-
packages/*/src
6-
packages/*/node_modules
7-
plugins
7+
dist
8+
dist-types
9+
dist-dynamic
10+
dynamic-plugins-root
11+
coverage
12+
13+
# ── Sensitive / local-only config ─────────────────────────────────────────────
14+
# app-config.local.yaml contains real credentials and must never enter the image.
815
*.local.yaml
16+
.env
17+
.env.*
18+
19+
# ── Git history ───────────────────────────────────────────────────────────────
20+
# Git metadata is not needed to build the app and may expose commit history.
21+
.git
22+
.gitignore
23+
.gitattributes
24+
25+
# ── CI / tooling / editor files ───────────────────────────────────────────────
26+
.cursor
27+
.changeset
28+
scripts
29+
*.md
30+
knip.json
31+
catalog-info.yaml
32+
examples

workspaces/dcm/.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
compressionLevel: mixed
2+
nodeLinker: node-modules

workspaces/dcm/Dockerfile

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Copyright Red Hat, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# ── Stage 1: build ────────────────────────────────────────────────────────────
16+
FROM node:20-bookworm-slim AS build
17+
18+
RUN corepack enable
19+
20+
WORKDIR /app
21+
22+
COPY package.json yarn.lock .yarnrc.yml backstage.json ./
23+
COPY .yarn ./.yarn
24+
25+
COPY tsconfig.json .eslintrc.js .eslintignore ./
26+
27+
COPY packages/ ./packages/
28+
COPY plugins/ ./plugins/
29+
30+
COPY app-config.yaml ./
31+
32+
RUN YARN_ENABLE_SCRIPTS=0 \
33+
YARN_ENABLE_IMMUTABLE_INSTALLS=false \
34+
YARN_CACHE_FOLDER=/root/.yarn/berry/cache \
35+
yarn install
36+
37+
RUN yarn tsc
38+
RUN yarn workspace app build
39+
RUN yarn workspace backend build
40+
41+
# ── Stage 2: production image ─────────────────────────────────────────────────
42+
FROM node:20-bookworm-slim
43+
44+
RUN corepack enable \
45+
&& apt-get update && apt-get install -y --no-install-recommends \
46+
python3 make g++ \
47+
&& rm -rf /var/lib/apt/lists/*
48+
49+
WORKDIR /app
50+
51+
COPY --from=build /app/packages/backend/dist/skeleton.tar.gz ./
52+
RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz
53+
54+
COPY --from=build /app/package.json /app/yarn.lock /app/.yarnrc.yml ./
55+
COPY --from=build /app/.yarn ./.yarn
56+
57+
RUN node -e " \
58+
const fs = require('fs'); \
59+
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); \
60+
if (pkg.scripts) pkg.scripts.postinstall = 'true'; \
61+
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); \
62+
" \
63+
&& YARN_ENABLE_IMMUTABLE_INSTALLS=false \
64+
YARN_CACHE_FOLDER=/root/.yarn/berry/cache \
65+
yarn workspaces focus --all --production \
66+
&& rm -rf "$(yarn cache dir)"
67+
68+
COPY --from=build /app/packages/app/package.json packages/app/package.json
69+
RUN ln -sf ../packages/app node_modules/app
70+
71+
COPY --from=build /app/packages/backend/dist/bundle.tar.gz ./
72+
RUN tar xzf bundle.tar.gz && rm bundle.tar.gz
73+
74+
COPY --from=build /app/plugins/dcm-backend/config.d.ts plugins/dcm-backend/config.d.ts
75+
COPY --from=build /app/packages/app/dist packages/app/dist
76+
COPY app-config.yaml app-config.production.yaml ./
77+
78+
RUN chown -R node:node /app
79+
USER node
80+
81+
EXPOSE 7007
82+
83+
CMD ["node", "packages/backend", \
84+
"--config", "app-config.yaml", \
85+
"--config", "app-config.production.yaml"]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
app:
2+
baseUrl: ${APP_BASE_URL:-http://localhost:7007}
3+
4+
backend:
5+
baseUrl: ${APP_BASE_URL:-http://localhost:7007}
6+
listen: ':7007'
7+
cors:
8+
origin: ${APP_BASE_URL:-http://localhost:7007}
9+
database:
10+
client: better-sqlite3
11+
connection: ':memory:'
12+
13+
dcm:
14+
apiGatewayUrl: ${DCM_API_GATEWAY_URL:-}
15+
ssoBaseUrl: ${DCM_SSO_BASE_URL:-}
16+
clientId: ${DCM_CLIENT_ID:-}
17+
clientSecret: ${DCM_CLIENT_SECRET:-}
18+
19+
auth:
20+
providers:
21+
guest:
22+
dangerouslyAllowOutsideDevelopment: true
23+
userEntityRef: user:default/guest
24+
25+
catalog:
26+
locations: []
27+
28+
techdocs:
29+
generator:
30+
runIn: local

workspaces/dcm/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@
4040
"url": "https://github.com/redhat-developer/rhdh-plugins",
4141
"directory": "workspaces/dcm"
4242
},
43-
"packageManager": "yarn@3.8.7",
43+
"packageManager": "yarn@4.12.0",
4444
"devDependencies": {
4545
"@backstage/cli": "^0.35.2",
4646
"@backstage/e2e-test-utils": "^0.1.1",
4747
"@backstage/repo-tools": "^0.16.2",
4848
"@changesets/cli": "^2.27.1",
49+
"@types/jest": "^29.5.12",
50+
"@types/node": "^20.0.0",
51+
"@types/webpack-env": "^1.18.4",
4952
"concurrently": "^9.0.0",
5053
"knip": "^5.27.4",
5154
"node-gyp": "^9.0.0",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
dcm:
2+
# Base URL of the DCM API Gateway (required).
3+
apiGatewayUrl: ${DCM_API_GATEWAY_URL}
4+
5+
# SSO configuration for the backend to obtain bearer tokens via
6+
ssoBaseUrl: ${DCM_SSO_BASE_URL}
7+
clientId: ${DCM_CLIENT_ID}
8+
clientSecret: ${DCM_CLIENT_SECRET}

workspaces/dcm/plugins/dcm-backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@red-hat-developer-hub/backstage-plugin-dcm-backend",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"license": "Apache-2.0",
55
"main": "src/index.ts",
66
"types": "src/index.ts",

workspaces/dcm/plugins/dcm-common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@red-hat-developer-hub/backstage-plugin-dcm-common",
33
"description": "Common functionalities for the dcm plugin",
4-
"version": "0.1.0",
4+
"version": "1.0.0",
55
"backstage": {
66
"pluginId": "dcm",
77
"pluginPackages": [
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
dynamicPlugins:
2+
frontend:
3+
red-hat-developer-hub.backstage-plugin-dcm:
4+
dynamicRoutes:
5+
- path: /dcm
6+
importName: DcmPage
7+
menuItem:
8+
text: DCM
9+
menuItems:
10+
dcm:
11+
title: DCM
12+
priority: 100

0 commit comments

Comments
 (0)