Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vfarcic committed Sep 10, 2024
1 parent 6156bd6 commit e024f82
Show file tree
Hide file tree
Showing 70 changed files with 27,303 additions and 24 deletions.
21 changes: 14 additions & 7 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
dist-types
node_modules
packages/*/dist
packages/*/node_modules
plugins/*/dist
plugins/*/node_modules
*.local.yaml
backstage/dist-types
backstage/node_modules
backstage/packages/*/dist
backstage/packages/*/node_modules
backstage/plugins/*/dist
backstage/plugins/*/node_modules
backstage/*.local.yaml
.devbox
.git
.gitignore
.teller.yml
chart
devbox.*
kind.yaml
57 changes: 57 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: ci
run-name: ci
on:
push:
branches:
- main
jobs:
build-container-image:
runs-on: ubuntu-latest
env:
TAG: 0.0.${{ github.run_number }}
GITHUB_USER: vfarcic
steps:
- name: Checkout
uses: actions/checkout@v4
- name: xxx
run: env
# - name: Install Devbox
# uses: jetpack-io/[email protected]
# with:
# enable-cache: true
# project-path: .github/workflows
# - name: Plugins
# run: devbox run plugins
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# - name: Login to ghcr
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: vfarcic
# password: ${{ secrets.REGISTRY_PASSWORD }}
# - name: Build and Push
# run: devbox run build

# - name: Build and push
# run: |
# earthly --push \
# --secret cosignpassword="$COSIGN_PASSWORD" \
# --secret cosignkey="$COSIGN_PRIVATE_KEY" \
# --secret password="$REGISTRY_PASSWORD" \
# +all --tag $TAG
# env:
# COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
# COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
# REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
# - name: Commit changes
# run: |
# git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
# git config --local user.name "github-actions[bot]"
# git add .
# git commit -m "Release ${{ env.TAG }} [skip ci]"
# - name: Push changes
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# branch: ${{ github.ref }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/backstage
/backstage-demo*.tgz
20 changes: 7 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
FROM node:18-bookworm-slim AS packages

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

COPY packages packages
COPY backstage/packages packages

# Comment this out if you don't have any internal plugins
# COPY plugins plugins
Expand Down Expand Up @@ -36,7 +36,7 @@ COPY --from=packages --chown=node:node /app .
RUN --mount=type=cache,target=/home/node/.cache/yarn,sharing=locked,uid=1000,gid=1000 \
yarn install --frozen-lockfile --network-timeout 600000

COPY --chown=node:node . .
COPY --chown=node:node backstage/. .

RUN yarn tsc
RUN yarn --cwd packages/backend build
Expand Down Expand Up @@ -90,15 +90,9 @@ COPY --from=build --chown=node:node /app/packages/backend/dist/bundle/ ./
COPY --chown=node:node app-config*.yaml ./

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

# This switches many Node.js dependencies to production mode.
# FIXME: Remove
ENV NODE_ENV development
# FIXME: Uncomment
# ENV NODE_ENV production

# FIXME: Remove
CMD ["node", "packages/backend", "--config", "app-config.yaml"]
# FIXME: Uncomment
# CMD ["node", "packages/backend", "--config", "app-config.yaml", "--config", "app-config.production.yaml"]
ENV NODE_ENV production

CMD ["node", "packages/backend", "--config", "app-config.yaml", "--config", "app-config.ingress.yaml", "--config", "app-config.production.yaml"]
4 changes: 4 additions & 0 deletions app-config.ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
app:
baseUrl: ${BACKSTAGE_HOST}
backend:
baseUrl: ${BACKSTAGE_HOST}
8 changes: 8 additions & 0 deletions app-config.production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
backend:
database:
client: pg
connection:
host: ${DB_HOST}
port: 5432
user: ${user}
password: ${password}
5 changes: 3 additions & 2 deletions app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ backend:
port: 7007
csp:
connect-src: ["'self'", 'http:', 'https:']
upgrade-insecure-requests: false
cors:
origin: http://localhost:3000
methods: [GET, HEAD, PATCH, POST, PUT, DELETE]
Expand Down Expand Up @@ -51,7 +52,7 @@ catalog:
providers:
github:
catalogInfo:
organization: vfarcic
organization: ${GITHUB_USER}
catalogPath: /catalog-info.yaml
filters:
branch: main
Expand All @@ -60,7 +61,7 @@ catalog:
frequency: {minutes: 30}
timeout: {minutes: 3}
templates:
organization: vfarcic
organization: ${GITHUB_USER}
catalogPath: /backstage-template.yaml
filters:
branch: main
Expand Down
6 changes: 6 additions & 0 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: backstage-demo
description: Backstage Demo
type: application
version: "0.0.1"
appVersion: "0.0.1"
Empty file added chart/templates/NOTES.txt
Empty file.
62 changes: 62 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "backstage-demo.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "backstage-demo.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "backstage-demo.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "backstage-demo.labels" -}}
helm.sh/chart: {{ include "backstage-demo.chart" . }}
{{ include "backstage-demo.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "backstage-demo.selectorLabels" -}}
app.kubernetes.io/name: {{ include "backstage-demo.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "backstage-demo.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "backstage-demo.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions chart/templates/db.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if eq .Values.mode "production" -}}
---
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: {{ include "backstage-demo.fullname" . }}-db
labels:
{{- include "backstage-demo.labels" . | nindent 4 }}
spec:
instances: {{ .Values.db.instances }}
storage:
size: 1Gi
enableSuperuserAccess: true
{{- end -}}
48 changes: 48 additions & 0 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "backstage-demo.fullname" . }}
labels:
{{- include "backstage-demo.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "backstage-demo.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "backstage-demo.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 7007
env:
- name: NODE_ENV
value: development
- name: BACKSTAGE_HOST
value: http://{{ .Values.ingress.host }}
- name: DB_HOST
value: {{ include "backstage-demo.fullname" . }}-db-rw
envFrom:
{{- if eq .Values.mode "production" }}
- secretRef:
name: {{ include "backstage-demo.fullname" . }}-db-superuser
{{- end }}
- secretRef:
name: {{ include "backstage-demo.fullname" . }}
{{- if eq .Values.mode "development" }}
command: ["node", "packages/backend", "--config", "app-config.yaml", "--config", "app-config.ingress.yaml"]
{{- end }}
20 changes: 20 additions & 0 deletions chart/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "backstage-demo.fullname" . }}
labels:
{{- include "backstage-demo.labels" . | nindent 4 }}
spec:
ingressClassName: {{ .Values.ingress.className }}
rules:
- host: {{ .Values.ingress.host }}
http:
paths:
- backend:
service:
name: {{ include "backstage-demo.fullname" . }}
port:
number: 80
path: /
pathType: ImplementationSpecific
15 changes: 15 additions & 0 deletions chart/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "backstage-demo.fullname" . }}
labels:
{{- include "backstage-demo.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
name: http
selector:
{{- include "backstage-demo.selectorLabels" . | nindent 4 }}
9 changes: 9 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mode: production
image:
repository: ghcr.io/vfarcic/backstage-demo
tag: v0.0.1
db:
instances: 1
ingress:
className: nginx
host: backstage.127.0.0.1.nip.io
15 changes: 13 additions & 2 deletions devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]"
"[email protected]",
"[email protected]",
"[email protected]"
],
"shell": {
"init_hook": [],
"scripts": {}
"scripts": {
"plugins": [
"yarn --cwd src/packages/backend add @backstage/plugin-scaffolder-backend-module-github",
"yarn --cwd src/packages/backend add @backstage/plugin-catalog-backend-module-github",
"cp packages/backend/src/index.ts src/packages/backend/src/index.ts"
],
"build": [
"docker image build --tag ghcr.io/$GITHUB_USER/backstage-demo:$TAG ."
]
}
}
}
Loading

0 comments on commit e024f82

Please sign in to comment.