From 1025bb2890055333569462094828966b4d1ec210 Mon Sep 17 00:00:00 2001 From: Yvette Nartey Date: Mon, 3 Feb 2025 06:43:07 +0100 Subject: [PATCH 1/7] ADD: prod configurations --- .github/workflows/cd-workflow.yaml | 6 ++++++ Dockerfile | 1 + app-config.production.yaml | 11 +++++++++++ app-config.yaml | 9 --------- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cd-workflow.yaml b/.github/workflows/cd-workflow.yaml index f9a7624..7fedea2 100644 --- a/.github/workflows/cd-workflow.yaml +++ b/.github/workflows/cd-workflow.yaml @@ -99,6 +99,7 @@ jobs: with: project_id: ${{ secrets.GCP_PROJECT_ID }} + - name: Deploy to Cloud Run id: deploy uses: google-github-actions/deploy-cloudrun@v1 @@ -110,3 +111,8 @@ jobs: flags: > --allow-unauthenticated --port=7007 + --add-cloudsql-instances=${{ secrets.GCP_SQL_CONNECTION_NAME }} + env_vars: | + POSTGRES_HOST=/cloudsql/${{ secrets.GCP_SQL_CONNECTION_NAME }} + POSTGRES_PORT=5432 + # BASE_URL=https://backstage.foundations-software-engineering.com diff --git a/Dockerfile b/Dockerfile index 1e175e7..c5fd1bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -120,6 +120,7 @@ ARG APP_ENV 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 +COPY --chown=node:node app-config.production.yaml ./app-config.production.yaml # This will include the examples, if you don't need these simply remove this line COPY --chown=node:node examples ./examples diff --git a/app-config.production.yaml b/app-config.production.yaml index 5db14f2..4b12949 100644 --- a/app-config.production.yaml +++ b/app-config.production.yaml @@ -7,6 +7,17 @@ backend: origin: https://backstage-deployment-1006240973223.europe-west10.run.app methods: [GET, HEAD, PATCH, POST, PUT, DELETE] credentials: true + database: + client: pg + connection: + host: ${POSTGRES_HOST} + port: ${POSTGRES_PORT} + user: ${POSTGRES_USER} + password: ${POSTGRES_PASSWORD} + plugin: + auth: + connection: + database: ${POSTGRES_DB} auth: environment: production diff --git a/app-config.yaml b/app-config.yaml index 7f7a894..fd2544b 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -15,15 +15,6 @@ backend: origin: http://localhost:3000 methods: [GET, HEAD, PATCH, POST, PUT, DELETE] credentials: true - database: - client: pg - connection: - host: ${POSTGRES_HOST} - port: ${POSTGRES_PORT} - user: ${POSTGRES_USER} - password: ${POSTGRES_PASSWORD} - cache: - store: memory integrations: github: From f3e2159752916eebd9faa79165498a3ed320ac01 Mon Sep 17 00:00:00 2001 From: Yvette Nartey Date: Mon, 3 Feb 2025 11:47:53 +0100 Subject: [PATCH 2/7] ADD: migrate scaffolder plugin for github --- packages/backend/package.json | 2 ++ packages/backend/src/index.ts | 6 +++++- yarn.lock | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/backend/package.json b/packages/backend/package.json index 6c9b060..d834a23 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -36,6 +36,8 @@ "@backstage/plugin-permission-node": "^0.8.5", "@backstage/plugin-proxy-backend": "^0.5.8", "@backstage/plugin-scaffolder-backend": "^1.27.2", + "@backstage/plugin-scaffolder-backend-module-github": "^0.5.5", + "@backstage/plugin-scaffolder-backend-module-gitlab": "^0.7.1", "@backstage/plugin-search-backend": "^1.7.0", "@backstage/plugin-search-backend-module-catalog": "^0.2.5", "@backstage/plugin-search-backend-module-pg": "^0.5.38", diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index a992e93..addc509 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -11,7 +11,6 @@ const backend = createBackend(); backend.add(import('@backstage/plugin-app-backend')); backend.add(import('@backstage/plugin-proxy-backend')) -backend.add(import('@backstage/plugin-scaffolder-backend')); backend.add(import('@backstage/plugin-techdocs-backend')); // Add the auth backend @@ -117,6 +116,11 @@ backend.add(import('@backstage/plugin-catalog-backend')); backend.add(import('@backstage/plugin-catalog-backend-module-scaffolder-entity-model'), ); +// scaffolder plugin +backend.add(import('@backstage/plugin-scaffolder-backend')); +backend.add(import('@backstage/plugin-scaffolder-backend-module-github')); +backend.add(import('@backstage/plugin-scaffolder-backend-module-gitlab')); + backend.add(import('@backstage/plugin-permission-backend')); backend.add( import('@backstage/plugin-permission-backend-module-allow-all-policy'), diff --git a/yarn.lock b/yarn.lock index 18710f9..08d7e9c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15420,6 +15420,8 @@ __metadata: "@backstage/plugin-permission-node": "npm:^0.8.5" "@backstage/plugin-proxy-backend": "npm:^0.5.8" "@backstage/plugin-scaffolder-backend": "npm:^1.27.2" + "@backstage/plugin-scaffolder-backend-module-github": "npm:^0.5.5" + "@backstage/plugin-scaffolder-backend-module-gitlab": "npm:^0.7.1" "@backstage/plugin-search-backend": "npm:^1.7.0" "@backstage/plugin-search-backend-module-catalog": "npm:^0.2.5" "@backstage/plugin-search-backend-module-pg": "npm:^0.5.38" From 69f1a4687e6c3fa30ac2b1f5ab7c8a5ce91d0234 Mon Sep 17 00:00:00 2001 From: Yvette Nartey Date: Mon, 3 Feb 2025 15:49:18 +0100 Subject: [PATCH 3/7] UPD: update database config --- .github/workflows/cd-workflow.yaml | 2 +- app-config.production.yaml | 17 +++-------------- app-config.yaml | 19 +++++++++++++++++++ packages/backend/package.json | 2 +- yarn.lock | 4 ++-- 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/.github/workflows/cd-workflow.yaml b/.github/workflows/cd-workflow.yaml index 7fedea2..aaaae64 100644 --- a/.github/workflows/cd-workflow.yaml +++ b/.github/workflows/cd-workflow.yaml @@ -115,4 +115,4 @@ jobs: env_vars: | POSTGRES_HOST=/cloudsql/${{ secrets.GCP_SQL_CONNECTION_NAME }} POSTGRES_PORT=5432 - # BASE_URL=https://backstage.foundations-software-engineering.com + BASE_URL=https://backstage.foundations-software-engineering.com diff --git a/app-config.production.yaml b/app-config.production.yaml index 4b12949..5f20d5e 100644 --- a/app-config.production.yaml +++ b/app-config.production.yaml @@ -1,23 +1,12 @@ app: - baseUrl: https://backstage-deployment-1006240973223.europe-west10.run.app + baseUrl: https://backstage.foundations-software-engineering.com backend: - baseUrl: https://backstage-deployment-1006240973223.europe-west10.run.app + baseUrl: https://backstage.foundations-software-engineering.com cors: - origin: https://backstage-deployment-1006240973223.europe-west10.run.app + origin: https://backstage.foundations-software-engineering.com methods: [GET, HEAD, PATCH, POST, PUT, DELETE] credentials: true - database: - client: pg - connection: - host: ${POSTGRES_HOST} - port: ${POSTGRES_PORT} - user: ${POSTGRES_USER} - password: ${POSTGRES_PASSWORD} - plugin: - auth: - connection: - database: ${POSTGRES_DB} auth: environment: production diff --git a/app-config.yaml b/app-config.yaml index fd2544b..bf11ca3 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -16,6 +16,25 @@ backend: methods: [GET, HEAD, PATCH, POST, PUT, DELETE] credentials: true + database: + client: pg + connection: + host: ${POSTGRES_HOST} + port: ${POSTGRES_PORT} + user: ${POSTGRES_USER} + password: ${POSTGRES_PASSWORD} + knexConfig: + pool: + min: 15 + max: 30 + acquireTimeoutMillis: 60000 + createTimeoutMillis: 30000 + destroyTimeoutMillis: 5000 + idleTimeoutMillis: 60000 + reapIntervalMillis: 1000 + createRetryIntervalMillis: 200 + propagateCreateError: false + integrations: github: - host: github.com diff --git a/packages/backend/package.json b/packages/backend/package.json index d834a23..814a26b 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -49,7 +49,7 @@ "express": "^4.17.1", "express-promise-router": "^4.1.0", "node-gyp": "^9.0.0", - "pg": "^8.11.3" + "pg": "^8.13.1" }, "devDependencies": { "@backstage/cli": "^0.29.0", diff --git a/yarn.lock b/yarn.lock index 08d7e9c..9fa941b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15438,7 +15438,7 @@ __metadata: express: "npm:^4.17.1" express-promise-router: "npm:^4.1.0" node-gyp: "npm:^9.0.0" - pg: "npm:^8.11.3" + pg: "npm:^8.13.1" languageName: unknown linkType: soft @@ -28604,7 +28604,7 @@ __metadata: languageName: node linkType: hard -"pg@npm:^8.11.3": +"pg@npm:^8.11.3, pg@npm:^8.13.1": version: 8.13.1 resolution: "pg@npm:8.13.1" dependencies: From 97e7a952d108e833323a639359500c6d1351bf69 Mon Sep 17 00:00:00 2001 From: Yvette Nartey Date: Mon, 3 Feb 2025 20:13:20 +0100 Subject: [PATCH 4/7] UPD: techdocs config --- .github/workflows/cd-workflow.yaml | 2 +- .github/workflows/techdocs-gcs.yml | 55 ++++++++++++++++++++++++++++++ app-config.yaml | 5 ++- docs/CHANGELOG.md | 0 mkdocs.yml | 1 + 5 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/techdocs-gcs.yml create mode 100644 docs/CHANGELOG.md diff --git a/.github/workflows/cd-workflow.yaml b/.github/workflows/cd-workflow.yaml index aaaae64..a6b0743 100644 --- a/.github/workflows/cd-workflow.yaml +++ b/.github/workflows/cd-workflow.yaml @@ -113,6 +113,6 @@ jobs: --port=7007 --add-cloudsql-instances=${{ secrets.GCP_SQL_CONNECTION_NAME }} env_vars: | - POSTGRES_HOST=/cloudsql/${{ secrets.GCP_SQL_CONNECTION_NAME }} + POSTGRES_HOST=${{ secrets.POSTGRES_HOST }} POSTGRES_PORT=5432 BASE_URL=https://backstage.foundations-software-engineering.com diff --git a/.github/workflows/techdocs-gcs.yml b/.github/workflows/techdocs-gcs.yml new file mode 100644 index 0000000..0c98f6e --- /dev/null +++ b/.github/workflows/techdocs-gcs.yml @@ -0,0 +1,55 @@ +name: Build and Publish TechDocs to GCS + +on: + push: + branches: + - main + paths: + - 'docs/**' + - 'mkdocs.yml' + +jobs: + publish-techdocs-site: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: ['20.x'] + + env: + TECHDOCS_BUCKET_NAME: ${{ secrets.TECHDOCS_BUCKET_NAME }} + TECHDOCS_GCS_CREDENTIALS: ${{ secrets.TECHDOCS_GCS_CREDENTIALS }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Enable Corepack + run: corepack enable + + - name: Set Yarn Version + run: corepack prepare yarn@4.4.1 --activate + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install techdocs-cli + run: yarn global add @techdocs/cli + + - name: Install mkdocs and mkdocs-plugin + run: python -m pip install mkdocs-techdocs-core==1.** + + - name: Generate docs site + run: techdocs-cli generate --no-docker --verbose + + - name: Publish docs site + run: techdocs-cli publish --publisher-type googleGcs --storage-name ${{ env.TECHDOCS_BUCKET_NAME }} --gcs-credentials ${{ env.TECHDOCS_GCS_CREDENTIALS }} diff --git a/app-config.yaml b/app-config.yaml index bf11ca3..fe6ea59 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -44,8 +44,11 @@ integrations: - host: gitlab.com token: ${GITLAB_TOKEN} + techdocs: - builder: 'external' + builder: 'external' + generator: + runIn: 'local' publisher: type: 'googleGcs' googleGcs: diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/mkdocs.yml b/mkdocs.yml index 8cc095a..0894f74 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -8,6 +8,7 @@ nav: - Register Your Software Component: 'how-to-register-a-component.md' - Technical Documentation: - Publish Your Docs: 'how-to-publish-documentation.md' + - CHANGELOG: 'CHANGELOG.md' plugins: - techdocs-core From b52dfff6832e677ee4ad9fae93ec16ad0b3a25a9 Mon Sep 17 00:00:00 2001 From: Yvette Nartey Date: Mon, 3 Feb 2025 21:17:51 +0100 Subject: [PATCH 5/7] UPD: techdocs config --- .github/workflows/techdocs-gcs.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/techdocs-gcs.yml b/.github/workflows/techdocs-gcs.yml index 0c98f6e..fd53e0e 100644 --- a/.github/workflows/techdocs-gcs.yml +++ b/.github/workflows/techdocs-gcs.yml @@ -18,6 +18,9 @@ jobs: env: TECHDOCS_BUCKET_NAME: ${{ secrets.TECHDOCS_BUCKET_NAME }} TECHDOCS_GCS_CREDENTIALS: ${{ secrets.TECHDOCS_GCS_CREDENTIALS }} + ENTITY_NAMESPACE: 'default' + ENTITY_KIND: 'Component' + ENTITY_NAME: 'code-idp-docs' steps: - name: Checkout code @@ -32,7 +35,7 @@ jobs: run: corepack prepare yarn@4.4.1 --activate - name: Set up Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} cache: 'yarn' @@ -46,10 +49,10 @@ jobs: run: yarn global add @techdocs/cli - name: Install mkdocs and mkdocs-plugin - run: python -m pip install mkdocs-techdocs-core==1.** + run: python3 -m pip install mkdocs-techdocs-core==1.* - name: Generate docs site run: techdocs-cli generate --no-docker --verbose - name: Publish docs site - run: techdocs-cli publish --publisher-type googleGcs --storage-name ${{ env.TECHDOCS_BUCKET_NAME }} --gcs-credentials ${{ env.TECHDOCS_GCS_CREDENTIALS }} + run: techdocs-cli publish --publisher-type googleGcs --storage-name $TECHDOCS_BUCKET_NAME --entity $ENTITY_NAMESPACE/$ENTITY_KIND/$ENTITY_NAME From 7ae6e4a3f658511f1d79574312c0ab29610df2f6 Mon Sep 17 00:00:00 2001 From: Yvette Nartey Date: Mon, 3 Feb 2025 21:44:09 +0100 Subject: [PATCH 6/7] UPD: fix errors --- Dockerfile | 1 - app-config.production.yaml | 10 +--------- app-config.yaml | 18 ++++++------------ 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index c5fd1bc..1e175e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -120,7 +120,6 @@ ARG APP_ENV 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 -COPY --chown=node:node app-config.production.yaml ./app-config.production.yaml # This will include the examples, if you don't need these simply remove this line COPY --chown=node:node examples ./examples diff --git a/app-config.production.yaml b/app-config.production.yaml index 5f20d5e..c1be780 100644 --- a/app-config.production.yaml +++ b/app-config.production.yaml @@ -6,12 +6,4 @@ backend: cors: origin: https://backstage.foundations-software-engineering.com methods: [GET, HEAD, PATCH, POST, PUT, DELETE] - credentials: true - -auth: - environment: production - providers: - github: - production: - clientId: ${PROD_GITHUB_CLIENT_ID} - clientSecret: ${PROD_GITHUB_CLIENT_SECRET} + credentials: true \ No newline at end of file diff --git a/app-config.yaml b/app-config.yaml index fe6ea59..caedef2 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -23,17 +23,8 @@ backend: port: ${POSTGRES_PORT} user: ${POSTGRES_USER} password: ${POSTGRES_PASSWORD} - knexConfig: - pool: - min: 15 - max: 30 - acquireTimeoutMillis: 60000 - createTimeoutMillis: 30000 - destroyTimeoutMillis: 5000 - idleTimeoutMillis: 60000 - reapIntervalMillis: 1000 - createRetryIntervalMillis: 200 - propagateCreateError: false + cache: + store: memory integrations: github: @@ -87,9 +78,12 @@ auth: development: clientId: ${GOOGLE_CLIENT_ID} clientSecret: ${GOOGLE_CLIENT_SECRET} - + github: development: clientId: ${GITHUB_CLIENT_ID} clientSecret: ${GITHUB_CLIENT_SECRET} + production: + clientId: ${PROD_GITHUB_CLIENT_ID} + clientSecret: ${PROD_GITHUB_CLIENT_SECRET} \ No newline at end of file From 937311f2344c20cd6298adddbdb25eb033028278 Mon Sep 17 00:00:00 2001 From: Yvette Nartey Date: Mon, 3 Feb 2025 21:58:23 +0100 Subject: [PATCH 7/7] UPD: fix errors --- app-config.production.yaml | 10 +++++++++- app-config.yaml | 5 +---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app-config.production.yaml b/app-config.production.yaml index c1be780..5f20d5e 100644 --- a/app-config.production.yaml +++ b/app-config.production.yaml @@ -6,4 +6,12 @@ backend: cors: origin: https://backstage.foundations-software-engineering.com methods: [GET, HEAD, PATCH, POST, PUT, DELETE] - credentials: true \ No newline at end of file + credentials: true + +auth: + environment: production + providers: + github: + production: + clientId: ${PROD_GITHUB_CLIENT_ID} + clientSecret: ${PROD_GITHUB_CLIENT_SECRET} diff --git a/app-config.yaml b/app-config.yaml index caedef2..d1b8890 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -78,12 +78,9 @@ auth: development: clientId: ${GOOGLE_CLIENT_ID} clientSecret: ${GOOGLE_CLIENT_SECRET} - + github: development: clientId: ${GITHUB_CLIENT_ID} clientSecret: ${GITHUB_CLIENT_SECRET} - production: - clientId: ${PROD_GITHUB_CLIENT_ID} - clientSecret: ${PROD_GITHUB_CLIENT_SECRET} \ No newline at end of file