Skip to content

Commit d600265

Browse files
authored
UPD: Migrate backstage backend and frontend (#58)
* ADD: import yarn plugin * UPD: update dependencies * UPD: update dev script * UPD: update index.ts for backend * ADD: setup github auth and update dependencies * ADD: add catalog-info.yaml for idp * FIX: fix test failures for frontend * DEL: delete user pipeline workflows * DEL: delete old backend files * UPD: update node version for docker and package.json * UPD: upgrade dependencies in yarn.lock * FIX: add googlecustom auth resolver * UPD: fix config files * UPD: move software templates * UPD: update playwright tests * FIX: add tsconfig for frontend * FIX: resolve merge conflicts
1 parent 3a8597e commit d600265

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+707
-750
lines changed

.github/workflows/ci-workflow.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
node-version: ['18.x', '20.x']
16+
node-version: ['20.x', '22.x']
1717

1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v4
2020
with:
2121
fetch-depth: 0
2222

2323
- name: Set up Node.js
24-
uses: actions/setup-node@v2
24+
uses: actions/setup-node@v4
2525
with:
2626
node-version: ${{ matrix.node-version }}
2727
cache: 'yarn'
@@ -44,7 +44,7 @@ jobs:
4444
validate_commit_messages:
4545
runs-on: ubuntu-latest
4646
steps:
47-
- uses: actions/checkout@v2
47+
- uses: actions/checkout@v4
4848
with:
4949
fetch-depth: 0
5050
- name: Ensure full git history
@@ -73,7 +73,7 @@ jobs:
7373
validate_branch_names:
7474
runs-on: ubuntu-latest
7575
steps:
76-
- uses: actions/checkout@v2
76+
- uses: actions/checkout@v4
7777
- name: Validate Branch Names
7878
run: |
7979
if [ "${{ github.event_name }}" == "pull_request" ]; then

.github/workflows/create-user-db.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/create-user-mongo-db.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ e2e-test-report/
5656
pg_values.yaml
5757

5858
*secret.yaml
59+
60+
61+
key/

.yarn/plugins/@yarnpkg/plugin-backstage.cjs

Lines changed: 46 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
nodeLinker: node-modules
2+
3+
plugins:
4+
- checksum: 8fa2e3a1cdf5076dde96b177618478419daea000b8038412817583e4d309fd39bf4813a337eb1fad3bfe9036d31732f7416383affbe3d420f48eacb60f6184d5
5+
path: .yarn/plugins/@yarnpkg/plugin-backstage.cjs
6+
spec: "https://versions.backstage.io/v1/tags/main/yarn-plugin"

Dockerfile

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# Stage 1 - Create yarn install skeleton layer
2-
FROM node:18-bookworm-slim AS packages
2+
FROM node:20-bookworm-slim AS packages
3+
4+
# Enable Corepack (for Yarn management) and install the required Yarn version
5+
RUN corepack enable
36

47
WORKDIR /app
5-
COPY package.json yarn.lock ./
8+
COPY backstage.json package.json yarn.lock ./
9+
COPY .yarn ./.yarn
10+
COPY .yarnrc.yml ./
11+
612

713
COPY packages packages
814

@@ -12,28 +18,46 @@ COPY packages packages
1218
RUN find packages \! -name "package.json" -mindepth 2 -maxdepth 2 -exec rm -rf {} \+
1319

1420
# Stage 2 - Install dependencies and build packages
15-
FROM node:18-bookworm-slim AS build
21+
FROM node:20-bookworm-slim AS build
22+
23+
# Set Python interpreter for `node-gyp` to use
24+
ENV PYTHON=/usr/bin/python3
1625

1726
# Install isolate-vm dependencies, these are needed by the @backstage/plugin-scaffolder-backend.
1827
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
1928
--mount=type=cache,target=/var/lib/apt,sharing=locked \
2029
apt-get update && \
2130
apt-get install -y --no-install-recommends python3 g++ build-essential && \
22-
yarn config set python /usr/bin/python3
31+
rm -rf /var/lib/apt/lists/*
32+
33+
# Enable Corepack (for Yarn management) and install the required Yarn version
34+
RUN corepack enable
2335

2436
USER node
37+
38+
ENV DOCKER_BUILDKIT=1
39+
2540
WORKDIR /app
2641

2742
COPY --from=packages --chown=node:node /app .
43+
COPY --from=packages --chown=node:node /app/.yarn ./.yarn
44+
COPY --from=packages --chown=node:node /app/.yarnrc.yml ./
45+
COPY --from=packages --chown=node:node /app/backstage.json ./
2846

47+
# Pre-create and fix ownership for cache directory
48+
RUN mkdir -p /home/node/.cache/node/corepack/v1 && \
49+
chown -R node:node /home/node/.cache
50+
51+
#ENV CYPRESS_INSTALL_BINARY=0
52+
#RUN yarn install --immutable --network-timeout 600000
2953
RUN --mount=type=cache,target=/home/node/.cache/yarn,sharing=locked,uid=1000,gid=1000 \
30-
yarn install --frozen-lockfile --network-timeout 600000
54+
yarn install --immutable
3155

3256
COPY --chown=node:node . .
3357

34-
RUN ls
58+
# RUN ls
3559

36-
RUN ls /app
60+
# RUN ls /app
3761

3862
RUN yarn tsc
3963
RUN yarn --cwd packages/backend build
@@ -45,18 +69,27 @@ RUN mkdir packages/backend/dist/skeleton packages/backend/dist/bundle \
4569
&& tar xzf packages/backend/dist/bundle.tar.gz -C packages/backend/dist/bundle
4670

4771
# Stage 3 - Build the actual backend image and install production dependencies
48-
FROM node:18-bookworm-slim
72+
FROM node:20-bookworm-slim
73+
74+
# Enable Corepack (for Yarn management) and install the required Yarn version
75+
RUN corepack enable
76+
77+
# Set Python interpreter for `node-gyp` to use
78+
ENV PYTHON=/usr/bin/python3
4979

5080
# Install isolate-vm dependencies, these are needed by the @backstage/plugin-scaffolder-backend.
5181
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
5282
--mount=type=cache,target=/var/lib/apt,sharing=locked \
5383
apt-get update && \
5484
apt-get install -y --no-install-recommends python3 g++ build-essential && \
55-
yarn config set python /usr/bin/python3
85+
rm -rf /var/lib/apt/lists/*
86+
5687

5788
# From here on we use the least-privileged `node` user to run the backend.
5889
USER node
5990

91+
ENV DOCKER_BUILDKIT=1
92+
6093
# This should create the app dir as `node`.
6194
# If it is instead created as `root` then the `tar` command below will
6295
# fail: `can't create directory 'packages/': Permission denied`.
@@ -65,22 +98,37 @@ USER node
6598
WORKDIR /app
6699

67100
# Copy the install dependencies from the build stage and context
101+
COPY --from=build --chown=node:node /app/.yarn ./.yarn
102+
COPY --from=build --chown=node:node /app/.yarnrc.yml ./
103+
COPY --from=build --chown=node:node /app/backstage.json ./
68104
COPY --from=build --chown=node:node /app/yarn.lock /app/package.json /app/packages/backend/dist/skeleton/ ./
69105

106+
# Pre-create and fix ownership for cache directory
107+
RUN mkdir -p /home/node/.cache/node/corepack/v1 && \
108+
chown -R node:node /home/node/.cache
109+
70110
RUN --mount=type=cache,target=/home/node/.cache/yarn,sharing=locked,uid=1000,gid=1000 \
71-
yarn install --frozen-lockfile --production --network-timeout 600000
111+
yarn workspaces focus --all --production && rm -rf "$(yarn cache clean)"
72112

73113
# Copy the built packages from the build stage
74114
COPY --from=build --chown=node:node /app/packages/backend/dist/bundle/ ./
75115

76116
ARG APP_ENV
77117

118+
78119
# Copy any other files that we need at runtime, to understand how the configs work refer to the README.md
79120
COPY --chown=node:node app-config.yaml ./
80121
COPY --chown=node:node app-config.docker.yaml ./app-config.docker.yaml
81122
COPY --chown=node:node app-config.${APP_ENV}.yaml ./app-config.env.yaml
82123

124+
# This will include the examples, if you don't need these simply remove this line
125+
COPY --chown=node:node examples ./examples
126+
127+
83128
# This switches many Node.js dependencies to production mode. Important APP_ENV and NODE_ENV serve two different purposes
84129
ENV NODE_ENV production
85130

131+
# This disables node snapshot for Node 20 to work with the Scaffolder
132+
ENV NODE_OPTIONS="--no-node-snapshot"
133+
86134
CMD ["node", "packages/backend", "--config", "app-config.yaml", "--config", "app-config.docker.yaml", "--config", "app-config.env.yaml"]

app-config.docker.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,4 @@ app:
33

44
backend:
55
baseUrl: ${BASE_URL}
6-
listen: ':7007'
7-
8-
catalog:
9-
import:
10-
entityFilename: catalog-info.yaml
11-
pullRequestBranchName: backstage-integration
12-
rules:
13-
- allow: [Component, System, API, Resource, Location]
6+
listen: ':7007'

app-config.production.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
app:
2+
baseUrl: prodlink
3+
4+
backend:
5+
baseUrl: prodlink
6+
cors:
7+
origin: prodlink
8+
methods: [GET, HEAD, PATCH, POST, PUT, DELETE]
9+
credentials: true

app-config.yaml

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
app:
2-
title: Scaffolded Backstage App
2+
title: CODE-IDP Hub
33
baseUrl: http://localhost:3000
44

55
organization:
6-
name: My Company
6+
name: CODE-IDP
77

88
backend:
99
baseUrl: http://localhost:7007
@@ -22,54 +22,55 @@ backend:
2222
port: ${POSTGRES_PORT}
2323
user: ${POSTGRES_USER}
2424
password: ${POSTGRES_PASSWORD}
25+
cache:
26+
store: memory
2527

2628
integrations:
2729
github:
2830
- host: github.com
2931
token: ${GITHUB_TOKEN}
3032

33+
gitlab:
34+
- host: gitlab.com
35+
token: ${GITLAB_TOKEN}
36+
3137
techdocs:
3238
builder: 'local' # Alternatives - 'external'
3339
generator:
3440
runIn: 'docker' # Alternatives - 'local'
3541
publisher:
3642
type: 'local' # Alternatives - 'googleGcs' or 'awsS3'. Read documentation for using alternatives.
3743

44+
# scaffolder:
45+
46+
3847
catalog:
3948
import:
4049
entityFilename: catalog-info.yaml
4150
pullRequestBranchName: backstage-integration
4251
rules:
43-
- allow: [Component, System, API, Resource, Location]
52+
- allow: [Component, System, API, User, Group, Resource, Location, Domain]
4453
locations:
4554
- type: file
46-
target: ../../examples/entities.yaml
47-
48-
- type: file
49-
target: ../../examples/template/template.yaml
55+
target: ./examples/template/initiate-deployment.yaml
5056
rules:
5157
- allow: [Template]
52-
5358
- type: file
54-
target: ../../examples/org.yaml
55-
rules:
56-
- allow: [User, Group]
57-
58-
- type: url
59-
target: https://github.com/backstage/software-templates/blob/main/scaffolder-templates/react-ssr-template/template.yaml
60-
rules:
61-
- allow: [Template]
62-
63-
- type: file
64-
target: ../../packages/backend/src/templates/initiate-deployment.yaml
59+
target: ./examples/template/template.yaml
6560
rules:
6661
- allow: [Template]
62+
6763

6864
auth:
69-
# see https://backstage.io/docs/auth/ to learn about auth providers
7065
environment: development
7166
providers:
7267
google:
7368
development:
7469
clientId: ${GOOGLE_CLIENT_ID}
7570
clientSecret: ${GOOGLE_CLIENT_SECRET}
71+
72+
github:
73+
development:
74+
clientId: ${GITHUB_CLIENT_ID}
75+
clientSecret: ${GITHUB_CLIENT_SECRET}
76+

0 commit comments

Comments
 (0)