Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['18.x', '20.x']
node-version: ['20.x', '22.x']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
Expand All @@ -44,7 +44,7 @@ jobs:
validate_commit_messages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Ensure full git history
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
validate_branch_names:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Validate Branch Names
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
Expand Down
13 changes: 0 additions & 13 deletions .github/workflows/create-user-db.yml

This file was deleted.

10 changes: 0 additions & 10 deletions .github/workflows/create-user-mongo-db.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ e2e-test-report/
pg_values.yaml

*secret.yaml


key/
46 changes: 46 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-backstage.cjs

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
nodeLinker: node-modules

plugins:
- checksum: 8fa2e3a1cdf5076dde96b177618478419daea000b8038412817583e4d309fd39bf4813a337eb1fad3bfe9036d31732f7416383affbe3d420f48eacb60f6184d5
path: .yarn/plugins/@yarnpkg/plugin-backstage.cjs
spec: "https://versions.backstage.io/v1/tags/main/yarn-plugin"
68 changes: 58 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Stage 1 - Create yarn install skeleton layer
FROM node:18-bookworm-slim AS packages
FROM node:20-bookworm-slim AS packages

# Enable Corepack (for Yarn management) and install the required Yarn version
RUN corepack enable

WORKDIR /app
COPY package.json yarn.lock ./
COPY backstage.json package.json yarn.lock ./
COPY .yarn ./.yarn
COPY .yarnrc.yml ./


COPY packages packages

Expand All @@ -12,28 +18,46 @@ COPY packages packages
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

# Install isolate-vm dependencies, these are needed by the @backstage/plugin-scaffolder-backend.
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 python3 g++ build-essential && \
yarn config set python /usr/bin/python3
rm -rf /var/lib/apt/lists/*

# Enable Corepack (for Yarn management) and install the required Yarn version
RUN corepack enable

USER node

ENV DOCKER_BUILDKIT=1

WORKDIR /app

COPY --from=packages --chown=node:node /app .
COPY --from=packages --chown=node:node /app/.yarn ./.yarn
COPY --from=packages --chown=node:node /app/.yarnrc.yml ./
COPY --from=packages --chown=node:node /app/backstage.json ./

# Pre-create and fix ownership for cache directory
RUN mkdir -p /home/node/.cache/node/corepack/v1 && \
chown -R node:node /home/node/.cache

#ENV CYPRESS_INSTALL_BINARY=0
#RUN yarn install --immutable --network-timeout 600000
RUN --mount=type=cache,target=/home/node/.cache/yarn,sharing=locked,uid=1000,gid=1000 \
yarn install --frozen-lockfile --network-timeout 600000
yarn install --immutable

COPY --chown=node:node . .

RUN ls
# RUN ls

RUN ls /app
# RUN ls /app

RUN yarn tsc
RUN yarn --cwd packages/backend build
Expand All @@ -45,18 +69,27 @@ 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

# Enable Corepack (for Yarn management) and install the required Yarn version
RUN corepack enable

# Set Python interpreter for `node-gyp` to use
ENV PYTHON=/usr/bin/python3

# Install isolate-vm dependencies, these are needed by the @backstage/plugin-scaffolder-backend.
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 python3 g++ build-essential && \
yarn config set python /usr/bin/python3
rm -rf /var/lib/apt/lists/*


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

ENV DOCKER_BUILDKIT=1

# This should create the app dir as `node`.
# If it is instead created as `root` then the `tar` command below will
# fail: `can't create directory 'packages/': Permission denied`.
Expand All @@ -65,22 +98,37 @@ USER node
WORKDIR /app

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

# Pre-create and fix ownership for cache directory
RUN mkdir -p /home/node/.cache/node/corepack/v1 && \
chown -R node:node /home/node/.cache

RUN --mount=type=cache,target=/home/node/.cache/yarn,sharing=locked,uid=1000,gid=1000 \
yarn install --frozen-lockfile --production --network-timeout 600000
yarn workspaces focus --all --production && rm -rf "$(yarn cache clean)"

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

ARG APP_ENV


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

# This will include the examples, if you don't need these simply remove this line
COPY --chown=node:node examples ./examples


# This switches many Node.js dependencies to production mode. Important APP_ENV and NODE_ENV serve two different purposes
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.docker.yaml", "--config", "app-config.env.yaml"]
9 changes: 1 addition & 8 deletions app-config.docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,4 @@ app:

backend:
baseUrl: ${BASE_URL}
listen: ':7007'

catalog:
import:
entityFilename: catalog-info.yaml
pullRequestBranchName: backstage-integration
rules:
- allow: [Component, System, API, Resource, Location]
listen: ':7007'
9 changes: 9 additions & 0 deletions app-config.production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
app:
baseUrl: prodlink

backend:
baseUrl: prodlink
cors:
origin: prodlink
methods: [GET, HEAD, PATCH, POST, PUT, DELETE]
credentials: true
41 changes: 21 additions & 20 deletions app-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
app:
title: Scaffolded Backstage App
title: CODE-IDP Hub
baseUrl: http://localhost:3000

organization:
name: My Company
name: CODE-IDP

backend:
baseUrl: http://localhost:7007
Expand All @@ -22,54 +22,55 @@ backend:
port: ${POSTGRES_PORT}
user: ${POSTGRES_USER}
password: ${POSTGRES_PASSWORD}
cache:
store: memory

integrations:
github:
- host: github.com
token: ${GITHUB_TOKEN}

gitlab:
- host: gitlab.com
token: ${GITLAB_TOKEN}

techdocs:
builder: 'local' # Alternatives - 'external'
generator:
runIn: 'docker' # Alternatives - 'local'
publisher:
type: 'local' # Alternatives - 'googleGcs' or 'awsS3'. Read documentation for using alternatives.

# scaffolder:


catalog:
import:
entityFilename: catalog-info.yaml
pullRequestBranchName: backstage-integration
rules:
- allow: [Component, System, API, Resource, Location]
- allow: [Component, System, API, User, Group, Resource, Location, Domain]
locations:
- type: file
target: ../../examples/entities.yaml

- type: file
target: ../../examples/template/template.yaml
target: ./examples/template/initiate-deployment.yaml
rules:
- allow: [Template]

- type: file
target: ../../examples/org.yaml
rules:
- allow: [User, Group]

- type: url
target: https://github.com/backstage/software-templates/blob/main/scaffolder-templates/react-ssr-template/template.yaml
rules:
- allow: [Template]

- type: file
target: ../../packages/backend/src/templates/initiate-deployment.yaml
target: ./examples/template/template.yaml
rules:
- allow: [Template]


auth:
# see https://backstage.io/docs/auth/ to learn about auth providers
environment: development
providers:
google:
development:
clientId: ${GOOGLE_CLIENT_ID}
clientSecret: ${GOOGLE_CLIENT_SECRET}

github:
development:
clientId: ${GITHUB_CLIENT_ID}
clientSecret: ${GITHUB_CLIENT_SECRET}

2 changes: 1 addition & 1 deletion backstage.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "1.22.1"
"version": "1.33.5"
}
39 changes: 32 additions & 7 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
---
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: demo-app
description: An example of a Backstage application.
# Example for optional annotations
# annotations:
# github.com/project-slug: backstage/backstage
name: code-idp
description: CODE-IDP is the platform to automate the deployment process for the projects using nodejs and flask frameworks.
It also enables users to store, view and discover information about projects in CODE.
annotations:
github.com/project-slug: 'codeuniversity/code-idp'
# backstage.io/techdocs-ref: dir:.
spec:
type: website
owner: [email protected]
lifecycle: experimental
owner: code_idp_team
lifecycle: production

---
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: idp-hosted-projects
description: The IDP Hosted Projects component is a collection of flask and nodejs projects that are hosted on google cloud using the automated deployment.
spec:
type: service
owner: code_idp_team
lifecycle: production
---
apiVersion: backstage.io/v1alpha1
kind: Group
metadata:
name: code_idp_team
description: The CODE-IDP team is responsible for the development and maintenance of the Internal Developer Platform.
spec:
type: team
profile:
displayName: Infrastructure Team
email: [email protected]
children: []
members: [Yvette]
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ services:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-admin}
GITHUB_TOKEN: ${GITHUB_TOKEN}
GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID}
GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET}
GITHUB_CLIENT_ID: ${GITHUB_CLIENT_ID}
GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET}
GITLAB_TOKEN: ${GITLAB_TOKEN}
BASE_URL: ${BASE_URL}
ports:
- 7007:7007
Expand Down
Loading
Loading