@smi-digital/create-smi-app 2.7.5 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -504,6 +504,14 @@ async function createApps(projectRoot, targets) {
504
504
  `Could not normalize config/plugins.ts: ${error instanceof Error ? error.message : String(error)}`
505
505
  );
506
506
  }
507
+ await runStep(
508
+ "Adding Postgres driver (pg) for production",
509
+ async () => runCommandQuiet(
510
+ "npm",
511
+ ["install", "pg"],
512
+ join4(projectRoot, target.directory)
513
+ )
514
+ );
507
515
  }
508
516
  await runSequentially(index + 1);
509
517
  };
@@ -590,7 +598,14 @@ async function createIntegrations(options, projectRoot, templatesDir) {
590
598
  api_token_salt: generateSecret(),
591
599
  admin_jwt_secret: generateSecret(),
592
600
  transfer_token_salt: generateSecret(),
593
- jwt_secret: generateSecret()
601
+ jwt_secret: generateSecret(),
602
+ // Postgres identifier derived from app_name (hyphens -> underscores), so
603
+ // the role/database name needs no quoting.
604
+ db_name: String(options.integrationInputs?.app_name ?? "").replaceAll(
605
+ "-",
606
+ "_"
607
+ ),
608
+ db_password: generateSecret()
594
609
  /* eslint-enable camelcase */
595
610
  };
596
611
  return copyTemplateFile(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smi-digital/create-smi-app",
3
- "version": "2.7.5",
3
+ "version": "2.8.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -13,6 +13,9 @@ jobs:
13
13
  project_domain: __PROJECT_DOMAIN__
14
14
  backend_domain: __BACKEND_DOMAIN__
15
15
  app_name: __APP_NAME__
16
+ # Optional: 301-redirect extra domains to project_domain (space-separated).
17
+ # Each must have DNS pointing at the server so Traefik can issue its cert.
18
+ # redirect_domains: "old-domain.com www.old-domain.com"
16
19
  secrets:
17
20
  # Per-repo secrets (Settings → Secrets and variables → Actions).
18
21
  # WEBSERVER_SSH_KEY and ZOT_PASSWORD are shared across all projects;
@@ -0,0 +1,15 @@
1
+ # Databases this project needs on the shared Postgres instance.
2
+ # The deploy provisions each one (login role + database) automatically — no
3
+ # manual step, no SSH. This file is the GitOps source of truth for the project's
4
+ # databases; passwords live (encrypted) in production.backend.env.
5
+ #
6
+ # - name: the database AND login-role name (Postgres-safe identifier)
7
+ # - password_env: the variable in production.backend.env holding its password
8
+ #
9
+ # To add an app-managed database (e.g. a separate dataset the site reads), add an
10
+ # entry here and its connection vars to production.backend.env:
11
+ # - name: my_dataset
12
+ # password_env: MY_DATASET_DATABASE_PASSWORD
13
+ databases:
14
+ - name: __DB_NAME__
15
+ password_env: DATABASE_PASSWORD
@@ -6,9 +6,9 @@ services:
6
6
  restart: unless-stopped
7
7
  env_file:
8
8
  - ./backend.env
9
- volumes:
9
+ volumes:
10
+ # Uploads stay on local disk for now; DB lives in Postgres (no sqlite volume).
10
11
  - ./data/uploads:/opt/app/public/uploads
11
- - ./data/database:/opt/app/.tmp
12
12
  networks:
13
13
  - agency_shared_network
14
14
  healthcheck:
@@ -27,7 +27,10 @@ services:
27
27
  - "traefik.http.services.__APP_NAME__-strapi.loadbalancer.server.port=1337"
28
28
  # Strapi requires larger body sizes for media uploads (25MB)
29
29
  - "traefik.http.middlewares.__APP_NAME__-strapi-limit.buffering.maxRequestBodyBytes=25000000"
30
- - "traefik.http.routers.__APP_NAME__-strapi.middlewares=__APP_NAME__-strapi-limit"
30
+ # Global middlewares (defined in webhosting-infra/traefik/dynamic) + the local
31
+ # body-size limit. rate-limit first so abusive traffic is dropped early; this
32
+ # matters most on the public Strapi admin/API.
33
+ - "traefik.http.routers.__APP_NAME__-strapi.middlewares=rate-limit@file,secure-headers@file,__APP_NAME__-strapi-limit"
31
34
 
32
35
  __APP_NAME__-astro:
33
36
  container_name: __APP_NAME__-astro
@@ -75,6 +78,8 @@ services:
75
78
  # Listen on both www and non-www
76
79
  - "traefik.http.routers.__APP_NAME__-astro.rule=Host(`__PROJECT_DOMAIN__`) || Host(`www.__PROJECT_DOMAIN__`)"
77
80
  - "traefik.http.routers.__APP_NAME__-astro.tls.certresolver=letsencrypt"
81
+ # Global middlewares (defined in webhosting-infra/traefik/dynamic)
82
+ - "traefik.http.routers.__APP_NAME__-astro.middlewares=secure-headers@file,rate-limit@file"
78
83
  # Route traffic to the Nginx Cache (Port 80) instead of Astro directly
79
84
  - "traefik.http.services.__APP_NAME__-astro.loadbalancer.server.port=80"
80
85
 
@@ -29,12 +29,6 @@
29
29
  "default": "my-new-client",
30
30
  "required": true,
31
31
  "validate": "slug"
32
- },
33
- {
34
- "key": "include_www",
35
- "message": "Include www domain?",
36
- "type": "confirm",
37
- "default": false
38
32
  }
39
33
  ]
40
34
  },
@@ -90,6 +84,10 @@
90
84
  {
91
85
  "template": "production.backend.env.template",
92
86
  "target": "production.backend.env"
87
+ },
88
+ {
89
+ "template": "databases.yml.template",
90
+ "target": "databases.yml"
93
91
  }
94
92
  ]
95
93
  }
@@ -17,6 +17,17 @@ ADMIN_JWT_SECRET=__ADMIN_JWT_SECRET__
17
17
  TRANSFER_TOKEN_SALT=__TRANSFER_TOKEN_SALT__
18
18
  JWT_SECRET=__JWT_SECRET__
19
19
 
20
+ # Database — production uses Postgres (local dev defaults to SQLite).
21
+ # A matching role + database must exist on the shared Postgres instance,
22
+ # reachable as DATABASE_HOST on the agency_shared_network.
23
+ DATABASE_CLIENT=postgres
24
+ DATABASE_HOST=postgres
25
+ DATABASE_PORT=5432
26
+ DATABASE_NAME=__DB_NAME__
27
+ DATABASE_USERNAME=__DB_NAME__
28
+ DATABASE_PASSWORD=__DB_PASSWORD__
29
+ DATABASE_SSL=false
30
+
20
31
  # Production Settings
21
32
  HOST=0.0.0.0
22
33
  PORT=1337