Skip to content

Commit

Permalink
Kubernetes
Browse files Browse the repository at this point in the history
  • Loading branch information
vfarcic committed Oct 8, 2024
1 parent cf00e52 commit 109abf9
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 35 deletions.
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ FROM node:20-bookworm-slim AS packages
WORKDIR /app
ARG SRC=backstage
COPY $SRC/package.json $SRC/yarn.lock ./
COPY $SRC/.yarn ./.yarn
COPY $SRC/.yarnrc.yml ./
COPY $SRC/packages packages
RUN find packages \! -name "package.json" -mindepth 2 -maxdepth 2 -exec rm -rf {} \+

Expand All @@ -13,16 +15,18 @@ 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/*
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 libsqlite3-dev
USER node
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 ./
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
ARG SRC=backstage
COPY --chown=node:node $SRC/. .
RUN yarn tsc
Expand All @@ -45,12 +49,15 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get install -y --no-install-recommends libsqlite3-dev
USER node
WORKDIR /app
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/yarn.lock /app/package.json /app/packages/backend/dist/skeleton/ ./
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 --from=build --chown=node:node /app/packages/backend/dist/bundle/ ./
COPY --chown=node:node app-config*.yaml ./
ARG SRC=backstage
COPY --chown=node:node $SRC/examples ./examples
ENV NODE_ENV=production
ENV NODE_OPTIONS="--no-node-snapshot"
CMD ["node", "packages/backend", "--config", "app-config.yaml", "--config", "app-config.ingress.yaml", "--config", "app-config.production.yaml"]
5 changes: 3 additions & 2 deletions app-config.production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ catalog:
catalogInfo:
filters:
branch: main
repository: "*"
repository: ".*"
templates:
filters:
repository: "*"
branch: main
repository: ".*"
2 changes: 1 addition & 1 deletion devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json",
"packages": [
"nodejs@20.17.0",
"yarn@1.22.22",
"yarn@latest",
"zellij@0.40.1",
"yq-go@4.44.3",
"teller@2.0.7",
Expand Down
54 changes: 27 additions & 27 deletions devbox.lock
Original file line number Diff line number Diff line change
Expand Up @@ -97,68 +97,68 @@
}
}
},
"nodejs@22.5.1": {
"last_modified": "2024-08-14T11:41:26Z",
"nodejs@20.17.0": {
"last_modified": "2024-09-10T15:01:03Z",
"plugin_version": "0.0.2",
"resolved": "github:NixOS/nixpkgs/0cb2fd7c59fed0cd82ef858cbcbdb552b9a33465#nodejs_22",
"resolved": "github:NixOS/nixpkgs/5ed627539ac84809c78b2dd6d26a5cebeb5ae269#nodejs_20",
"source": "devbox-search",
"version": "22.5.1",
"version": "20.17.0",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/vbbk37g24vayjad0jzi7jyf92rbadz7l-nodejs-22.5.1",
"path": "/nix/store/hxl1k8qgmrm1vfq5f419iv4wybz9szqq-nodejs-20.17.0",
"default": true
},
{
"name": "libv8",
"path": "/nix/store/yz4k4kg5spvnr5hfl0zam0180qmi82nk-nodejs-22.5.1-libv8"
"path": "/nix/store/baf3p9zf8dn2arp6wjkdi3v0g2xgfd6y-nodejs-20.17.0-libv8"
}
],
"store_path": "/nix/store/vbbk37g24vayjad0jzi7jyf92rbadz7l-nodejs-22.5.1"
"store_path": "/nix/store/hxl1k8qgmrm1vfq5f419iv4wybz9szqq-nodejs-20.17.0"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/85ngdpilv2mdhb8b5fmqzrbnkhin7jwn-nodejs-22.5.1",
"path": "/nix/store/vc64zpxndmp3xh9699yb2vpbl81pxbk0-nodejs-20.17.0",
"default": true
},
{
"name": "libv8",
"path": "/nix/store/12a20901b329n3zj9b1a0c5swcm37yvy-nodejs-22.5.1-libv8"
"path": "/nix/store/0c57mzp5bqf0pp4a0pdj8wynphsgi92c-nodejs-20.17.0-libv8"
}
],
"store_path": "/nix/store/85ngdpilv2mdhb8b5fmqzrbnkhin7jwn-nodejs-22.5.1"
"store_path": "/nix/store/vc64zpxndmp3xh9699yb2vpbl81pxbk0-nodejs-20.17.0"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/nzjjzxmab6ph0s4dprqw1b6v9piancsi-nodejs-22.5.1",
"path": "/nix/store/lgyrki1i0205nwh51c1h22bhl95x0nyd-nodejs-20.17.0",
"default": true
},
{
"name": "libv8",
"path": "/nix/store/xnxcqr676ffb62gkz3nwh4zyiarla7hi-nodejs-22.5.1-libv8"
"path": "/nix/store/n4xvswmgb3ql2440bkl8xk4i3b11w46x-nodejs-20.17.0-libv8"
}
],
"store_path": "/nix/store/nzjjzxmab6ph0s4dprqw1b6v9piancsi-nodejs-22.5.1"
"store_path": "/nix/store/lgyrki1i0205nwh51c1h22bhl95x0nyd-nodejs-20.17.0"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/kxy4210mqs50ribr9dj2y6r03mbmjifj-nodejs-22.5.1",
"path": "/nix/store/w78sh036dyn14f29w8za9ni9syrmwm3q-nodejs-20.17.0",
"default": true
},
{
"name": "libv8",
"path": "/nix/store/ii07lzp5c0h21g1cm681bimak86np677-nodejs-22.5.1-libv8"
"path": "/nix/store/bsqha32xvv1j20bwkhr2wsnclk4qsi3a-nodejs-20.17.0-libv8"
}
],
"store_path": "/nix/store/kxy4210mqs50ribr9dj2y6r03mbmjifj-nodejs-22.5.1"
"store_path": "/nix/store/w78sh036dyn14f29w8za9ni9syrmwm3q-nodejs-20.17.0"
}
}
},
Expand Down Expand Up @@ -258,51 +258,51 @@
}
}
},
"yarn@1.22.22": {
"last_modified": "2024-08-14T11:41:26Z",
"resolved": "github:NixOS/nixpkgs/0cb2fd7c59fed0cd82ef858cbcbdb552b9a33465#yarn",
"yarn@latest": {
"last_modified": "2024-09-10T15:01:03Z",
"resolved": "github:NixOS/nixpkgs/5ed627539ac84809c78b2dd6d26a5cebeb5ae269#yarn",
"source": "devbox-search",
"version": "1.22.22",
"systems": {
"aarch64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/vaylrlzgx5mykq3naphkabgf2vgz51yn-yarn-1.22.22",
"path": "/nix/store/6j0fflbrszc5k5kd7m36mn9ga6ds8zmr-yarn-1.22.22",
"default": true
}
],
"store_path": "/nix/store/vaylrlzgx5mykq3naphkabgf2vgz51yn-yarn-1.22.22"
"store_path": "/nix/store/6j0fflbrszc5k5kd7m36mn9ga6ds8zmr-yarn-1.22.22"
},
"aarch64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/b3lwjiijfrjpq6gsb5zy2wb1f412wgc0-yarn-1.22.22",
"path": "/nix/store/d1f5qfjkc24v2ng46x0qjsbiwrdfa6d3-yarn-1.22.22",
"default": true
}
],
"store_path": "/nix/store/b3lwjiijfrjpq6gsb5zy2wb1f412wgc0-yarn-1.22.22"
"store_path": "/nix/store/d1f5qfjkc24v2ng46x0qjsbiwrdfa6d3-yarn-1.22.22"
},
"x86_64-darwin": {
"outputs": [
{
"name": "out",
"path": "/nix/store/s5jv8v5g12mp4xzwlkdcqw72s4nq1zp3-yarn-1.22.22",
"path": "/nix/store/vfi9zsfiwq5yia28nx04zdmr9ij6nhi3-yarn-1.22.22",
"default": true
}
],
"store_path": "/nix/store/s5jv8v5g12mp4xzwlkdcqw72s4nq1zp3-yarn-1.22.22"
"store_path": "/nix/store/vfi9zsfiwq5yia28nx04zdmr9ij6nhi3-yarn-1.22.22"
},
"x86_64-linux": {
"outputs": [
{
"name": "out",
"path": "/nix/store/si89wdnns2qvm0ji57d4ghkcm3wxah2p-yarn-1.22.22",
"path": "/nix/store/9yd6frl42syv6vncdy619zblj2vg406g-yarn-1.22.22",
"default": true
}
],
"store_path": "/nix/store/si89wdnns2qvm0ji57d4ghkcm3wxah2p-yarn-1.22.22"
"store_path": "/nix/store/9yd6frl42syv6vncdy619zblj2vg406g-yarn-1.22.22"
}
}
},
Expand Down
28 changes: 26 additions & 2 deletions setup/kubernetes.nu
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#!/usr/bin/env nu

rm --force .env

rm --recursive --force backstage

print $"We are about to create a new (ansi yellow_bold)Backstage app(ansi reset). Make sure to respond with the enter key to keep the default value (ansi yellow_bold)backstage(ansi reset) when asked to name the app.
Press (ansi yellow_bold)any key(ansi reset) to continue.
"
input

npx @backstage/create-app@latest

(
yarn --cwd backstage/packages/backend add
@backstage/plugin-scaffolder-backend-module-github
Expand All @@ -25,7 +36,7 @@ if "GITHUB_TOKEN" not-in $env {
$"export GITHUB_TOKEN=($github_token)\n" | save --append .env

mut github_user = ""
if "GITHUB_TOKEN" not-in $env {
if "GITHUB_USER" not-in $env {
$github_user = input $"(ansi green_bold)Enter GitHub user or organization where you forked the repo:(ansi reset)"
} else {
$github_user = $env.GITHUB_USER
Expand Down Expand Up @@ -56,4 +67,17 @@ kind create cluster --config kind.yaml

start $"https://github.com/($github_user)/backstage-demo/settings/actions"

print $"Select (ansi yellow_bold)Read and write permissions(ansi reset) from the (ansi yellow_bold)Workflow permissions(ansi reset) section in browser, and click the (ansi yellow_bold)Save(ansi reset) button."
print ""
print $"
Select (ansi yellow_bold)Read and write permissions(ansi reset) from the (ansi yellow_bold)Workflow permissions(ansi reset) section in browser, and click the (ansi yellow_bold)Save(ansi reset) button.
Press (ansi yellow_bold)any key(ansi reset) to continue.
"
input

start $"https://github.com/($github_user)/backstage-demo/actions"

print $"
(ansi yellow_bold)Enable(ansi reset) GitHub Actions.
Press (ansi yellow_bold)any key(ansi reset) to continue.
"
input

0 comments on commit 109abf9

Please sign in to comment.