-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
dist-types | ||
node_modules | ||
packages/*/dist | ||
packages/*/node_modules | ||
plugins/*/dist | ||
plugins/*/node_modules | ||
*.local.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Stage 1 - Create yarn install skeleton layer | ||
FROM node:18-bookworm-slim AS packages | ||
|
||
WORKDIR /app | ||
COPY package.json yarn.lock ./ | ||
|
||
COPY packages packages | ||
|
||
# Comment this out if you don't have any internal plugins | ||
# COPY plugins plugins | ||
|
||
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 | ||
|
||
# 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 | ||
|
||
# Install sqlite3 dependencies. You can skip this if you don't use sqlite3 in the image, | ||
# in which case you should also move better-sqlite3 to "devDependencies" in package.json. | ||
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 . | ||
|
||
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 . . | ||
|
||
RUN yarn tsc | ||
RUN yarn --cwd packages/backend build | ||
# If you have not yet migrated to package roles, use the following command instead: | ||
# RUN yarn --cwd packages/backend backstage-cli backend:bundle --build-dependencies | ||
|
||
RUN mkdir packages/backend/dist/skeleton packages/backend/dist/bundle \ | ||
&& tar xzf packages/backend/dist/skeleton.tar.gz -C packages/backend/dist/skeleton \ | ||
&& 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 | ||
|
||
# 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 | ||
|
||
# Install sqlite3 dependencies. You can skip this if you don't use sqlite3 in the image, | ||
# in which case you should also move better-sqlite3 to "devDependencies" in package.json. | ||
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 | ||
|
||
# From here on we use the least-privileged `node` user to run the backend. | ||
USER node | ||
|
||
# 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`. | ||
# If this occurs, then ensure BuildKit is enabled (`DOCKER_BUILDKIT=1`) | ||
# so the app dir is correctly created as `node`. | ||
WORKDIR /app | ||
|
||
# Copy the install dependencies from the build stage and context | ||
COPY --from=build --chown=node:node /app/yarn.lock /app/package.json /app/packages/backend/dist/skeleton/ ./ | ||
# Note: The skeleton bundle only includes package.json files -- if your app has | ||
# plugins that define a `bin` export, the bin files need to be copied as well to | ||
# be linked in node_modules/.bin during yarn install. | ||
|
||
RUN --mount=type=cache,target=/home/node/.cache/yarn,sharing=locked,uid=1000,gid=1000 \ | ||
yarn install --frozen-lockfile --production --network-timeout 600000 | ||
|
||
# Copy the built packages from the build stage | ||
COPY --from=build --chown=node:node /app/packages/backend/dist/bundle/ ./ | ||
|
||
# Copy any other files that we need at runtime | ||
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 | ||
|
||
# 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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Hi! | ||
* | ||
* Note that this is an EXAMPLE Backstage backend. Please check the README. | ||
* | ||
* Happy hacking! | ||
*/ | ||
|
||
import { createBackend } from '@backstage/backend-defaults'; | ||
|
||
const backend = createBackend(); | ||
|
||
backend.add(import('@backstage/plugin-app-backend/alpha')); | ||
backend.add(import('@backstage/plugin-proxy-backend/alpha')); | ||
backend.add(import('@backstage/plugin-scaffolder-backend/alpha')); | ||
backend.add(import('@backstage/plugin-techdocs-backend/alpha')); | ||
backend.add(import('@backstage/plugin-scaffolder-backend-module-github')); | ||
backend.add(import('@backstage/plugin-catalog-backend-module-github/alpha')); | ||
|
||
// auth plugin | ||
backend.add(import('@backstage/plugin-auth-backend')); | ||
// See https://backstage.io/docs/backend-system/building-backends/migrating#the-auth-plugin | ||
backend.add(import('@backstage/plugin-auth-backend-module-guest-provider')); | ||
// See https://backstage.io/docs/auth/guest/provider | ||
|
||
// catalog plugin | ||
backend.add(import('@backstage/plugin-catalog-backend/alpha')); | ||
backend.add( | ||
import('@backstage/plugin-catalog-backend-module-scaffolder-entity-model'), | ||
); | ||
|
||
// See https://backstage.io/docs/features/software-catalog/configuration#subscribing-to-catalog-errors | ||
backend.add(import('@backstage/plugin-catalog-backend-module-logs')); | ||
|
||
// permission plugin | ||
backend.add(import('@backstage/plugin-permission-backend/alpha')); | ||
// See https://backstage.io/docs/permissions/getting-started for how to create your own permission policy | ||
backend.add( | ||
import('@backstage/plugin-permission-backend-module-allow-all-policy'), | ||
); | ||
|
||
// search plugin | ||
backend.add(import('@backstage/plugin-search-backend/alpha')); | ||
|
||
// search engine | ||
// See https://backstage.io/docs/features/search/search-engines | ||
backend.add(import('@backstage/plugin-search-backend-module-pg/alpha')); | ||
|
||
// search collators | ||
backend.add(import('@backstage/plugin-search-backend-module-catalog/alpha')); | ||
backend.add(import('@backstage/plugin-search-backend-module-techdocs/alpha')); | ||
|
||
// kubernetes | ||
backend.add(import('@backstage/plugin-kubernetes-backend/alpha')); | ||
|
||
backend.start(); |