Skip to content

Commit 00fa0da

Browse files
committed
Remove database choice from create-app command
Signed-off-by: Johan Haals <johan.haals@gmail.com>
1 parent 08e7fc5 commit 00fa0da

7 files changed

Lines changed: 29 additions & 33 deletions

File tree

.changeset/smart-ghosts-search.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@backstage/create-app': patch
3+
---
4+
5+
Removed the database choice from the `create-app` command.
6+
7+
This reduces the step from development to production by always installing the dependencies and templating the production configuration in `app-config.production.yaml`.
8+
9+
Added `app-config.local.yaml` to allow for local configuration overrides.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ site
130130

131131
# Local configuration files
132132
*.local.yaml
133+
!packages/create-app/templates/default-app/app-config.local.yaml
133134

134135
# Sensitive credentials
135136
*-credentials.yaml

packages/create-app/src/createApp.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,7 @@ export default async (opts: OptionValues): Promise<void> => {
5050
return true;
5151
},
5252
},
53-
{
54-
type: 'list',
55-
name: 'dbType',
56-
message: chalk.blue('Select database for the backend [required]'),
57-
choices: ['SQLite', 'PostgreSQL'],
58-
},
5953
]);
60-
answers.dbTypePG = answers.dbType === 'PostgreSQL';
61-
answers.dbTypeSqlite = answers.dbType === 'SQLite';
6254

6355
const templateDir = paths.resolveOwn('templates/default-app');
6456
const tempDir = resolvePath(os.tmpdir(), answers.name);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Backstage override configuration for your local development environment

packages/create-app/templates/default-app/app-config.production.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,18 @@ backend:
1717
# backend will bind on the interface that corresponds to the backend.baseUrl
1818
# hostname.
1919
host: 0.0.0.0
20+
21+
# config options: https://node-postgres.com/api/client
22+
database:
23+
client: pg
24+
connection:
25+
host: ${POSTGRES_HOST}
26+
port: ${POSTGRES_PORT}
27+
user: ${POSTGRES_USER}
28+
password: ${POSTGRES_PASSWORD}
29+
# https://node-postgres.com/features/ssl
30+
# you can set the sslmode configuration option via the `PGSSLMODE` environment variable
31+
# see https://www.postgresql.org/docs/current/libpq-ssl.html Table 33.1. SSL Mode Descriptions (e.g. require)
32+
# ssl:
33+
# ca: # if you have a CA file and want to verify it you can uncomment this section
34+
# $file: <file-path>/ca/server.crt

packages/create-app/templates/default-app/app-config.yaml.hbs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,11 @@ backend:
2626
origin: http://localhost:3000
2727
methods: [GET, POST, PUT, DELETE]
2828
credentials: true
29-
{{#if dbTypeSqlite}}
29+
# This is for local developement only, it is not recommended to use this in production
30+
# The production database configuration is stored in app-config.production.yaml
3031
database:
3132
client: better-sqlite3
3233
connection: ':memory:'
33-
{{/if}}
34-
{{#if dbTypePG}}
35-
# config options: https://node-postgres.com/api/client
36-
database:
37-
client: pg
38-
connection:
39-
host: ${POSTGRES_HOST}
40-
port: ${POSTGRES_PORT}
41-
user: ${POSTGRES_USER}
42-
password: ${POSTGRES_PASSWORD}
43-
# https://node-postgres.com/features/ssl
44-
# you can set the sslmode configuration option via the `PGSSLMODE` environment variable
45-
# see https://www.postgresql.org/docs/current/libpq-ssl.html Table 33.1. SSL Mode Descriptions (e.g. require)
46-
# ssl:
47-
# ca: # if you have a CA file and want to verify it you can uncomment this section
48-
# $file: <file-path>/ca/server.crt
49-
{{/if}}
5034
cache:
5135
store: memory
5236
# workingDirectory: /tmp # Use this to configure a working directory for the scaffolder, defaults to the OS temp-dir

packages/create-app/templates/default-app/packages/backend/package.json.hbs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,18 @@
3030
"@backstage/plugin-proxy-backend": "^{{version '@backstage/plugin-proxy-backend'}}",
3131
"@backstage/plugin-scaffolder-backend": "^{{version '@backstage/plugin-scaffolder-backend'}}",
3232
"@backstage/plugin-search-backend": "^{{version '@backstage/plugin-search-backend'}}",
33-
{{#if dbTypePG}}
3433
"@backstage/plugin-search-backend-module-pg": "^{{version '@backstage/plugin-search-backend-module-pg'}}",
35-
{{/if}}
3634
"@backstage/plugin-search-backend-node": "^{{version '@backstage/plugin-search-backend-node'}}",
3735
"@backstage/plugin-techdocs-backend": "^{{version '@backstage/plugin-techdocs-backend'}}",
3836
"dockerode": "^3.3.1",
3937
"express": "^4.17.1",
4038
"express-promise-router": "^4.1.0",
4139
"luxon": "^2.0.2",
42-
{{#if dbTypePG}}
4340
"pg": "^8.3.0",
44-
{{/if}}
45-
{{#if dbTypeSqlite}}
46-
"better-sqlite3": "^7.5.0",
47-
{{/if}}
4841
"winston": "^3.2.1"
4942
},
5043
"devDependencies": {
44+
"better-sqlite3": "^7.5.0",
5145
"@backstage/cli": "^{{version '@backstage/cli'}}",
5246
"@types/dockerode": "^3.3.0",
5347
"@types/express": "^4.17.6",

0 commit comments

Comments
 (0)