vinzscam / backstage-chart

Backstage Helm Chart
27 stars 10 forks source link

Module sqlite is missing #6

Open cmoulliard opened 2 years ago

cmoulliard commented 2 years ago

Issue

When we deploy the helm chart

DOMAIN_NAME="192.168.1.90.nip.io"
cat <<EOF > $HOME/demo-backstage/my-values.yml
backstage:
  image:
    registry: "docker.io/library"
    repository: "backstage"
    tag: "dev"
EOF

helm repo add backstage https://vinzscam.github.io/backstage-chart
helm install -f $HOME/demo-backstage/my-values.yml  --create-namespace -n backstage my-backstage

from a project created using npx @backstage/create-app

npx @backstage/create-app
...
yarn dev
yarn build
yarn build-image -t backstage:dev
kind load docker-image backstage:dev

then we got the following error as by default the module better-sqlite3 is not packaged within the node application when we build it

Log of the backend pod

...
Backend failed to start up, Error: Knex: run
$ npm install @vscode/sqlite3 --save
Cannot find module 'better-sqlite3'
Require stack:
- /app/node_modules/knex/lib/dialects/better-sqlite3/index.js
- /app/node_modules/knex/lib/knex-builder/internal/config-resolver.js
- /app/node_modules/knex/lib/knex-builder/Knex.js
- /app/node_modules/knex/lib/index.js
- /app/node_modules/knex/knex.js
- /app/node_modules/@backstage/backend-common/dist/index.cjs.js
- /app/packages/backend/dist/index.cjs.js

The documentation page should include a warning message to explain how the image should be created and which packages should be packaged

ChrisJBurns commented 2 years ago

So, as far as I'm aware this was because of the following bits of code in the Dockerfile that you can see on the backstage docs:

# install sqlite3 dependencies, you can skip this if you don't use sqlite3 in the image
RUN apt-get update && \
    apt-get install -y --no-install-recommends libsqlite3-dev python3 build-essential && \
    rm -rf /var/lib/apt/lists/* && \
    yarn config set python /usr/bin/python3

I had the same error until I remove that part from the Dockerfile and also made sure to change the database engine to postgres and not sqlite.

cmoulliard commented 2 years ago

Previously the process to create an application was asking which DB the user wanted to use and the package was installed by the BuildAppTask but this option is gone since versions >= 1.2.

As the npx @backstage/create-app will not anymore package the dependencies of the DB, I suggest then to document part of this Helm documentation that additional packages should be added using the command yarn add --cwd packages/backend better-sqlite3, etc before to build the image.

WDYT ? @ChrisJBurns @vinzscam

ChrisJBurns commented 2 years ago

To be honest, I don't even think it's worth mentioning. The backstage docs themselves say that sqlite are for local setups and local testing and that users should focus on using postgres for their real setup. Since the Helm Chart will be dealing with official deployments of Backstage in Kubernetes, I think we just completely drop the mentioning of sqlite across the board and only offer the ability to add config for external databases OR using the postgres offered by the subchart (as this will be a popular implementation method for those who want to use Backstage in hermetic environments (some banking firms, governments etc etc) and want to have their postgres instance inside of Kubernetes.

cmoulliard commented 2 years ago

Since the Helm Chart will be dealing with official deployments of Backstage in Kubernetes, I think we just completely drop the mentioning of sqlite across the board and only offer the ability to add config for external databases OR using the postgres offered by the subchart (as this will be a popular implementation method for those who want to use Backstage in hermetic environments (some banking firms, governments etc etc) and want to have their postgres instance inside of Kubernetes.

So it is time that we include the helm postgresql sub-chart or dependency of this backstage helm chart to have a backstage application working on k8s ;-)

ChrisJBurns commented 2 years ago

I agree! I've pushed up the newest changes on the weekend, let me know if all looks well :+1: