@getstrata/starter 2.2.47 → 2.2.48
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/cli.js +222 -216
- package/dist/templates/package.json +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -212,6 +212,35 @@ function dockerLayerForNeeded(layers, enabled) {
|
|
|
212
212
|
return { enabled: true, services: enableDockerServices(needed) };
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
// src/databaseDefaults.ts
|
|
216
|
+
var GENERATED_POSTGRES_APP_ROLE = "strata_app";
|
|
217
|
+
var GENERATED_POSTGRES_APP_PASSWORD = "dev-strata-app-change-me";
|
|
218
|
+
var GENERATED_POSTGRES_SUPERUSER_PASSWORD = "dev-postgres-change-me";
|
|
219
|
+
var GENERATED_MYSQL_ROOT_PASSWORD = "dev-mysql-change-me";
|
|
220
|
+
function appDatabaseName(projectName) {
|
|
221
|
+
return projectName.replace(/[^A-Za-z0-9_]/g, "_");
|
|
222
|
+
}
|
|
223
|
+
function usesComposePostgres(layers) {
|
|
224
|
+
return selectedDockerServices(layers).includes("postgres");
|
|
225
|
+
}
|
|
226
|
+
function defaultDatabaseUrl(layers, projectName) {
|
|
227
|
+
if (layers.database === "sqlite") {
|
|
228
|
+
return "sqlite:./storage/app.sqlite";
|
|
229
|
+
}
|
|
230
|
+
const database = appDatabaseName(projectName);
|
|
231
|
+
if (layers.database === "mysql") {
|
|
232
|
+
return `mysql://root:${GENERATED_MYSQL_ROOT_PASSWORD}@localhost:3306/${database}`;
|
|
233
|
+
}
|
|
234
|
+
return `postgresql://${GENERATED_POSTGRES_APP_ROLE}:${GENERATED_POSTGRES_APP_PASSWORD}@localhost:5432/${database}`;
|
|
235
|
+
}
|
|
236
|
+
function defaultMigrationDatabaseUrl(layers, projectName) {
|
|
237
|
+
if (layers.database !== "postgres") {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
const database = appDatabaseName(projectName);
|
|
241
|
+
return `postgresql://postgres:${GENERATED_POSTGRES_SUPERUSER_PASSWORD}@localhost:5432/${database}`;
|
|
242
|
+
}
|
|
243
|
+
|
|
215
244
|
// src/presets.ts
|
|
216
245
|
var noneExtras = {
|
|
217
246
|
mfa: false,
|
|
@@ -2696,6 +2725,149 @@ export default authProvider;
|
|
|
2696
2725
|
`;
|
|
2697
2726
|
}
|
|
2698
2727
|
|
|
2728
|
+
// src/renderDocker.ts
|
|
2729
|
+
function renderServiceHealthcheck(test) {
|
|
2730
|
+
return ` healthcheck:
|
|
2731
|
+
test: ${JSON.stringify(test)}
|
|
2732
|
+
interval: 2s
|
|
2733
|
+
timeout: 3s
|
|
2734
|
+
retries: 60
|
|
2735
|
+
start_period: 5s`;
|
|
2736
|
+
}
|
|
2737
|
+
function renderDockerCompose(projectName, layers) {
|
|
2738
|
+
const selected = selectedDockerServices(layers);
|
|
2739
|
+
if (selected.length === 0) {
|
|
2740
|
+
return null;
|
|
2741
|
+
}
|
|
2742
|
+
const selectedSet = new Set(selected);
|
|
2743
|
+
const services = [];
|
|
2744
|
+
if (selectedSet.has("postgres")) {
|
|
2745
|
+
const database = appDatabaseName(projectName);
|
|
2746
|
+
services.push(` postgres:
|
|
2747
|
+
image: postgres:16-alpine
|
|
2748
|
+
environment:
|
|
2749
|
+
POSTGRES_USER: postgres
|
|
2750
|
+
POSTGRES_PASSWORD: ${GENERATED_POSTGRES_SUPERUSER_PASSWORD}
|
|
2751
|
+
POSTGRES_DB: ${database}
|
|
2752
|
+
${renderServiceHealthcheck(["CMD-SHELL", 'PGPASSWORD="$$POSTGRES_PASSWORD" psql -h 127.0.0.1 -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" -tAc "SELECT 1" >/dev/null'])}
|
|
2753
|
+
ports:
|
|
2754
|
+
# Localhost only. Do not publish this port on a production host.
|
|
2755
|
+
- "127.0.0.1:5432:5432"
|
|
2756
|
+
volumes:
|
|
2757
|
+
- pgdata:/var/lib/postgresql/data
|
|
2758
|
+
- ./docker/postgres-init:/docker-entrypoint-initdb.d:ro`);
|
|
2759
|
+
}
|
|
2760
|
+
if (selectedSet.has("mysql")) {
|
|
2761
|
+
const database = appDatabaseName(projectName);
|
|
2762
|
+
services.push(` mysql:
|
|
2763
|
+
image: mysql:8.4
|
|
2764
|
+
environment:
|
|
2765
|
+
MYSQL_ROOT_PASSWORD: ${GENERATED_MYSQL_ROOT_PASSWORD}
|
|
2766
|
+
MYSQL_DATABASE: ${database}
|
|
2767
|
+
${renderServiceHealthcheck(["CMD-SHELL", 'MYSQL_PWD="$$MYSQL_ROOT_PASSWORD" mysql --protocol=tcp -h 127.0.0.1 -u root -D "$$MYSQL_DATABASE" -N -e "SELECT 1" >/dev/null'])}
|
|
2768
|
+
ports:
|
|
2769
|
+
- "127.0.0.1:3306:3306"
|
|
2770
|
+
volumes:
|
|
2771
|
+
- mysqldata:/var/lib/mysql`);
|
|
2772
|
+
}
|
|
2773
|
+
if (selectedSet.has("adminer")) {
|
|
2774
|
+
const server = selectedSet.has("mysql") ? "mysql" : "postgres";
|
|
2775
|
+
services.push(` adminer:
|
|
2776
|
+
image: adminer:5.4.2
|
|
2777
|
+
profiles:
|
|
2778
|
+
- debug
|
|
2779
|
+
environment:
|
|
2780
|
+
ADMINER_DEFAULT_SERVER: ${server}
|
|
2781
|
+
depends_on:
|
|
2782
|
+
${server}:
|
|
2783
|
+
condition: service_healthy
|
|
2784
|
+
${renderServiceHealthcheck(["CMD", "php", "-r", "exit(@file_get_contents('http://127.0.0.1:8080/') === false ? 1 : 0);"])}
|
|
2785
|
+
ports:
|
|
2786
|
+
- "127.0.0.1:8080:8080"`);
|
|
2787
|
+
}
|
|
2788
|
+
if (selectedSet.has("redis")) {
|
|
2789
|
+
services.push(` redis:
|
|
2790
|
+
image: redis:7-alpine
|
|
2791
|
+
environment:
|
|
2792
|
+
REDIS_PASSWORD: "\${REDIS_PASSWORD:-dev-redis-change-me}"
|
|
2793
|
+
${renderServiceHealthcheck(["CMD-SHELL", 'REDISCLI_AUTH="$$REDIS_PASSWORD" redis-cli --no-auth-warning ping | grep -qx PONG'])}
|
|
2794
|
+
command: ["redis-server", "--requirepass", "\${REDIS_PASSWORD:-dev-redis-change-me}"]
|
|
2795
|
+
ports:
|
|
2796
|
+
- "127.0.0.1:6379:6379"`);
|
|
2797
|
+
}
|
|
2798
|
+
if (selectedSet.has("mailpit")) {
|
|
2799
|
+
services.push(` mailpit:
|
|
2800
|
+
image: axllent/mailpit:latest
|
|
2801
|
+
${renderServiceHealthcheck(["CMD", "/mailpit", "readyz"])}
|
|
2802
|
+
ports:
|
|
2803
|
+
- "127.0.0.1:1025:1025"
|
|
2804
|
+
- "127.0.0.1:8025:8025"`);
|
|
2805
|
+
}
|
|
2806
|
+
const volumes = [];
|
|
2807
|
+
if (selectedSet.has("postgres")) {
|
|
2808
|
+
volumes.push(" pgdata:");
|
|
2809
|
+
}
|
|
2810
|
+
if (selectedSet.has("mysql")) {
|
|
2811
|
+
volumes.push(" mysqldata:");
|
|
2812
|
+
}
|
|
2813
|
+
return `services:
|
|
2814
|
+
${services.join(`
|
|
2815
|
+
|
|
2816
|
+
`)}
|
|
2817
|
+
${volumes.length > 0 ? `
|
|
2818
|
+
volumes:
|
|
2819
|
+
${volumes.join(`
|
|
2820
|
+
`)}
|
|
2821
|
+
` : ""}`;
|
|
2822
|
+
}
|
|
2823
|
+
function renderDockerfile(layers) {
|
|
2824
|
+
const frontend = needsFrontendBuild(layers.frontend);
|
|
2825
|
+
const lines = [
|
|
2826
|
+
'# Production image. Build once, run with env from your platform; see README "Deploy".',
|
|
2827
|
+
"FROM oven/bun:1.4.3 AS deps",
|
|
2828
|
+
"WORKDIR /app",
|
|
2829
|
+
"COPY package.json bun.lock ./",
|
|
2830
|
+
"RUN bun install --frozen-lockfile --production",
|
|
2831
|
+
""
|
|
2832
|
+
];
|
|
2833
|
+
if (frontend) {
|
|
2834
|
+
lines.push("FROM oven/bun:1.4.3 AS frontend", "WORKDIR /app/frontend", "COPY --from=deps /app/node_modules /app/node_modules", "ARG SPA_PREFIX", "ENV SPA_PREFIX=$SPA_PREFIX", "COPY frontend/package.json frontend/bun.lock ./", "RUN bun install --frozen-lockfile", "COPY frontend/ ./", "RUN bun run build", "");
|
|
2835
|
+
}
|
|
2836
|
+
lines.push("FROM oven/bun:1.4.3-slim AS runtime", "WORKDIR /app", "ENV APP_ENV=production", "ENV AUTH_DEV_HEADERS=false", "ENV PORT=3000", "COPY --from=deps /app/node_modules ./node_modules", "COPY . .");
|
|
2837
|
+
if (frontend) {
|
|
2838
|
+
lines.push("COPY --from=frontend /app/frontend/dist ./frontend/dist");
|
|
2839
|
+
}
|
|
2840
|
+
lines.push("RUN mkdir -p storage && chown -R bun:bun /app", "USER bun", "EXPOSE 3000");
|
|
2841
|
+
if (layers.database === "sqlite") {
|
|
2842
|
+
lines.push("# SQLite lives in storage/; mount a volume there or the data dies with the container.", 'VOLUME ["/app/storage"]');
|
|
2843
|
+
}
|
|
2844
|
+
lines.push("# Readiness: anonymous dependency/schema probe; use a separate process check for liveness.", `HEALTHCHECK --interval=30s --timeout=3s --start-period=10s CMD ["bun", "-e", "fetch('http://127.0.0.1:' + process.env.PORT + '/health').then((r) => process.exit(r.ok ? 0 : 1), () => process.exit(1))"]`, 'CMD ["bun", "./node_modules/.bin/strata", "start"]');
|
|
2845
|
+
return `${lines.join(`
|
|
2846
|
+
`)}
|
|
2847
|
+
`;
|
|
2848
|
+
}
|
|
2849
|
+
function renderDockerignore(layers) {
|
|
2850
|
+
const lines = [
|
|
2851
|
+
".git",
|
|
2852
|
+
"node_modules",
|
|
2853
|
+
".env",
|
|
2854
|
+
".env.*",
|
|
2855
|
+
"!.env.example",
|
|
2856
|
+
"storage/*.sqlite",
|
|
2857
|
+
"storage/*.sqlite-journal",
|
|
2858
|
+
"storage/*.sqlite-wal",
|
|
2859
|
+
"storage/*.sqlite-shm",
|
|
2860
|
+
"coverage",
|
|
2861
|
+
"docker-compose.yml"
|
|
2862
|
+
];
|
|
2863
|
+
if (needsFrontendBuild(layers.frontend)) {
|
|
2864
|
+
lines.push("frontend/node_modules", "frontend/dist");
|
|
2865
|
+
}
|
|
2866
|
+
return `${lines.join(`
|
|
2867
|
+
`)}
|
|
2868
|
+
`;
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2699
2871
|
// ../../src/core/runtime/appEnv.ts
|
|
2700
2872
|
var NON_PRODUCTION_APP_ENVS = new Set(["local", "development", "dev", "test", "testing", "ci"]);
|
|
2701
2873
|
|
|
@@ -2852,36 +3024,57 @@ function generatedRlsBootstrapSql(tables, userOwnedTables = []) {
|
|
|
2852
3024
|
`);
|
|
2853
3025
|
}
|
|
2854
3026
|
|
|
2855
|
-
// src/
|
|
2856
|
-
function
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
}
|
|
2866
|
-
|
|
2867
|
-
return
|
|
3027
|
+
// src/renderSupportingTools.ts
|
|
3028
|
+
function localEnvVars(services) {
|
|
3029
|
+
const vars = [];
|
|
3030
|
+
for (const name of services) {
|
|
3031
|
+
if (name === "postgres" || name === "mysql") {
|
|
3032
|
+
vars.push("DATABASE_URL");
|
|
3033
|
+
} else if (name === "redis") {
|
|
3034
|
+
vars.push("REDIS_URL");
|
|
3035
|
+
} else if (name === "mailpit") {
|
|
3036
|
+
vars.push("MAIL_HOST");
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
return [...new Set(vars)];
|
|
2868
3040
|
}
|
|
2869
|
-
function
|
|
2870
|
-
|
|
2871
|
-
|
|
3041
|
+
function renderSupportingToolsReadme(projectName, layers) {
|
|
3042
|
+
const needed = neededDockerServices(layers);
|
|
3043
|
+
if (needed.length === 0) {
|
|
3044
|
+
return "";
|
|
2872
3045
|
}
|
|
2873
|
-
const
|
|
2874
|
-
|
|
2875
|
-
|
|
3046
|
+
const dockerOn = selectedDockerServices(layers);
|
|
3047
|
+
const dockerSet = new Set(dockerOn);
|
|
3048
|
+
const localOn = needed.filter((name) => !dockerSet.has(name));
|
|
3049
|
+
const lines = ["## Supporting tools", ""];
|
|
3050
|
+
if (dockerOn.length > 0) {
|
|
3051
|
+
const names = dockerOn.map((name) => DOCKER_SERVICE_LABELS[name]).join(", ");
|
|
3052
|
+
lines.push(`Docker Compose includes ${names}.`, "", "```bash", dockerComposeUpCommand(layers), "```", "", "Wait for this command to succeed before migrating. It waits up to 180 seconds for selected services to be healthy; inspect `docker compose ps` and `docker compose logs` if it fails. Increasing `--wait-timeout` can accommodate a slow first initialization. These checks do not run application migrations.", "");
|
|
3053
|
+
if (dockerSet.has("adminer")) {
|
|
3054
|
+
const mysql = layers.database === "mysql";
|
|
3055
|
+
const system = mysql ? "MySQL" : "PostgreSQL";
|
|
3056
|
+
const server = mysql ? "mysql" : "postgres";
|
|
3057
|
+
const username = mysql ? "root" : "postgres";
|
|
3058
|
+
const password = mysql ? GENERATED_MYSQL_ROOT_PASSWORD : GENERATED_POSTGRES_SUPERUSER_PASSWORD;
|
|
3059
|
+
lines.push(`Adminer: http://localhost:8080 (${system}, server \`${server}\`, username \`${username}\`, password \`${password}\`, database \`${appDatabaseName(projectName)}\`).`, "", "Adminer is optional development tooling in the `debug` profile; plain `docker compose up -d` does not start Adminer. Use the profile command above to start it with the database.", "");
|
|
3060
|
+
if (!mysql) {
|
|
3061
|
+
lines.push("Adminer uses the Compose `postgres` superuser, which skips FORCE RLS. Application traffic should use `strata_app`.", "");
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
2876
3064
|
}
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
return null;
|
|
3065
|
+
if (localOn.length > 0) {
|
|
3066
|
+
const names = localOn.map((name) => DOCKER_SERVICE_LABELS[name]).join(", ");
|
|
3067
|
+
const envVars = localEnvVars(localOn).map((name) => `\`${name}\``).join(", ");
|
|
3068
|
+
lines.push(`Use local installs for ${names}. Point ${envVars} in \`.env\` at services on this machine.`, "");
|
|
2882
3069
|
}
|
|
2883
|
-
|
|
2884
|
-
|
|
3070
|
+
return `${lines.join(`
|
|
3071
|
+
`)}
|
|
3072
|
+
`;
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
// src/renderEnv.ts
|
|
3076
|
+
function envFlag(value) {
|
|
3077
|
+
return value ? "true" : "false";
|
|
2885
3078
|
}
|
|
2886
3079
|
function postgresAppRoleEnvNotes(layers) {
|
|
2887
3080
|
if (layers.database !== "postgres") {
|
|
@@ -3075,100 +3268,6 @@ function renderEnvExample(projectName, layers) {
|
|
|
3075
3268
|
`)}
|
|
3076
3269
|
`;
|
|
3077
3270
|
}
|
|
3078
|
-
function renderServiceHealthcheck(test) {
|
|
3079
|
-
return ` healthcheck:
|
|
3080
|
-
test: ${JSON.stringify(test)}
|
|
3081
|
-
interval: 2s
|
|
3082
|
-
timeout: 3s
|
|
3083
|
-
retries: 60
|
|
3084
|
-
start_period: 5s`;
|
|
3085
|
-
}
|
|
3086
|
-
function renderDockerCompose(projectName, layers) {
|
|
3087
|
-
const selected = selectedDockerServices(layers);
|
|
3088
|
-
if (selected.length === 0) {
|
|
3089
|
-
return null;
|
|
3090
|
-
}
|
|
3091
|
-
const selectedSet = new Set(selected);
|
|
3092
|
-
const services = [];
|
|
3093
|
-
if (selectedSet.has("postgres")) {
|
|
3094
|
-
const database = appDatabaseName(projectName);
|
|
3095
|
-
services.push(` postgres:
|
|
3096
|
-
image: postgres:16-alpine
|
|
3097
|
-
environment:
|
|
3098
|
-
POSTGRES_USER: postgres
|
|
3099
|
-
POSTGRES_PASSWORD: ${GENERATED_POSTGRES_SUPERUSER_PASSWORD}
|
|
3100
|
-
POSTGRES_DB: ${database}
|
|
3101
|
-
${renderServiceHealthcheck(["CMD-SHELL", 'PGPASSWORD="$$POSTGRES_PASSWORD" psql -h 127.0.0.1 -U "$$POSTGRES_USER" -d "$$POSTGRES_DB" -tAc "SELECT 1" >/dev/null'])}
|
|
3102
|
-
ports:
|
|
3103
|
-
# Localhost only. Do not publish this port on a production host.
|
|
3104
|
-
- "127.0.0.1:5432:5432"
|
|
3105
|
-
volumes:
|
|
3106
|
-
- pgdata:/var/lib/postgresql/data
|
|
3107
|
-
- ./docker/postgres-init:/docker-entrypoint-initdb.d:ro`);
|
|
3108
|
-
}
|
|
3109
|
-
if (selectedSet.has("mysql")) {
|
|
3110
|
-
const database = appDatabaseName(projectName);
|
|
3111
|
-
services.push(` mysql:
|
|
3112
|
-
image: mysql:8.4
|
|
3113
|
-
environment:
|
|
3114
|
-
MYSQL_ROOT_PASSWORD: ${GENERATED_MYSQL_ROOT_PASSWORD}
|
|
3115
|
-
MYSQL_DATABASE: ${database}
|
|
3116
|
-
${renderServiceHealthcheck(["CMD-SHELL", 'MYSQL_PWD="$$MYSQL_ROOT_PASSWORD" mysql --protocol=tcp -h 127.0.0.1 -u root -D "$$MYSQL_DATABASE" -N -e "SELECT 1" >/dev/null'])}
|
|
3117
|
-
ports:
|
|
3118
|
-
- "127.0.0.1:3306:3306"
|
|
3119
|
-
volumes:
|
|
3120
|
-
- mysqldata:/var/lib/mysql`);
|
|
3121
|
-
}
|
|
3122
|
-
if (selectedSet.has("adminer")) {
|
|
3123
|
-
const server = selectedSet.has("mysql") ? "mysql" : "postgres";
|
|
3124
|
-
services.push(` adminer:
|
|
3125
|
-
image: adminer:5.4.2
|
|
3126
|
-
profiles:
|
|
3127
|
-
- debug
|
|
3128
|
-
environment:
|
|
3129
|
-
ADMINER_DEFAULT_SERVER: ${server}
|
|
3130
|
-
depends_on:
|
|
3131
|
-
${server}:
|
|
3132
|
-
condition: service_healthy
|
|
3133
|
-
${renderServiceHealthcheck(["CMD", "php", "-r", "exit(@file_get_contents('http://127.0.0.1:8080/') === false ? 1 : 0);"])}
|
|
3134
|
-
ports:
|
|
3135
|
-
- "127.0.0.1:8080:8080"`);
|
|
3136
|
-
}
|
|
3137
|
-
if (selectedSet.has("redis")) {
|
|
3138
|
-
services.push(` redis:
|
|
3139
|
-
image: redis:7-alpine
|
|
3140
|
-
environment:
|
|
3141
|
-
REDIS_PASSWORD: "\${REDIS_PASSWORD:-dev-redis-change-me}"
|
|
3142
|
-
${renderServiceHealthcheck(["CMD-SHELL", 'REDISCLI_AUTH="$$REDIS_PASSWORD" redis-cli --no-auth-warning ping | grep -qx PONG'])}
|
|
3143
|
-
command: ["redis-server", "--requirepass", "\${REDIS_PASSWORD:-dev-redis-change-me}"]
|
|
3144
|
-
ports:
|
|
3145
|
-
- "127.0.0.1:6379:6379"`);
|
|
3146
|
-
}
|
|
3147
|
-
if (selectedSet.has("mailpit")) {
|
|
3148
|
-
services.push(` mailpit:
|
|
3149
|
-
image: axllent/mailpit:latest
|
|
3150
|
-
${renderServiceHealthcheck(["CMD", "/mailpit", "readyz"])}
|
|
3151
|
-
ports:
|
|
3152
|
-
- "127.0.0.1:1025:1025"
|
|
3153
|
-
- "127.0.0.1:8025:8025"`);
|
|
3154
|
-
}
|
|
3155
|
-
const volumes = [];
|
|
3156
|
-
if (selectedSet.has("postgres")) {
|
|
3157
|
-
volumes.push(" pgdata:");
|
|
3158
|
-
}
|
|
3159
|
-
if (selectedSet.has("mysql")) {
|
|
3160
|
-
volumes.push(" mysqldata:");
|
|
3161
|
-
}
|
|
3162
|
-
return `services:
|
|
3163
|
-
${services.join(`
|
|
3164
|
-
|
|
3165
|
-
`)}
|
|
3166
|
-
${volumes.length > 0 ? `
|
|
3167
|
-
volumes:
|
|
3168
|
-
${volumes.join(`
|
|
3169
|
-
`)}
|
|
3170
|
-
` : ""}`;
|
|
3171
|
-
}
|
|
3172
3271
|
function renderGitignore() {
|
|
3173
3272
|
return `node_modules
|
|
3174
3273
|
.env
|
|
@@ -3183,62 +3282,15 @@ coverage
|
|
|
3183
3282
|
*.tsbuildinfo
|
|
3184
3283
|
`;
|
|
3185
3284
|
}
|
|
3186
|
-
function renderDockerfile(layers) {
|
|
3187
|
-
const frontend = needsFrontendBuild(layers.frontend);
|
|
3188
|
-
const lines = [
|
|
3189
|
-
'# Production image. Build once, run with env from your platform; see README "Deploy".',
|
|
3190
|
-
"FROM oven/bun:1.4.3 AS deps",
|
|
3191
|
-
"WORKDIR /app",
|
|
3192
|
-
"COPY package.json bun.lock ./",
|
|
3193
|
-
"RUN bun install --frozen-lockfile --production",
|
|
3194
|
-
""
|
|
3195
|
-
];
|
|
3196
|
-
if (frontend) {
|
|
3197
|
-
lines.push("FROM oven/bun:1.4.3 AS frontend", "WORKDIR /app/frontend", "COPY --from=deps /app/node_modules /app/node_modules", "ARG SPA_PREFIX", "ENV SPA_PREFIX=$SPA_PREFIX", "COPY frontend/package.json frontend/bun.lock ./", "RUN bun install --frozen-lockfile", "COPY frontend/ ./", "RUN bun run build", "");
|
|
3198
|
-
}
|
|
3199
|
-
lines.push("FROM oven/bun:1.4.3-slim AS runtime", "WORKDIR /app", "ENV APP_ENV=production", "ENV AUTH_DEV_HEADERS=false", "ENV PORT=3000", "COPY --from=deps /app/node_modules ./node_modules", "COPY . .");
|
|
3200
|
-
if (frontend) {
|
|
3201
|
-
lines.push("COPY --from=frontend /app/frontend/dist ./frontend/dist");
|
|
3202
|
-
}
|
|
3203
|
-
lines.push("RUN mkdir -p storage && chown -R bun:bun /app", "USER bun", "EXPOSE 3000");
|
|
3204
|
-
if (layers.database === "sqlite") {
|
|
3205
|
-
lines.push("# SQLite lives in storage/; mount a volume there or the data dies with the container.", 'VOLUME ["/app/storage"]');
|
|
3206
|
-
}
|
|
3207
|
-
lines.push("# Readiness: anonymous dependency/schema probe; use a separate process check for liveness.", `HEALTHCHECK --interval=30s --timeout=3s --start-period=10s CMD ["bun", "-e", "fetch('http://127.0.0.1:' + process.env.PORT + '/health').then((r) => process.exit(r.ok ? 0 : 1), () => process.exit(1))"]`, 'CMD ["bun", "./node_modules/.bin/strata", "start"]');
|
|
3208
|
-
return `${lines.join(`
|
|
3209
|
-
`)}
|
|
3210
|
-
`;
|
|
3211
|
-
}
|
|
3212
|
-
function renderDockerignore(layers) {
|
|
3213
|
-
const lines = [
|
|
3214
|
-
".git",
|
|
3215
|
-
"node_modules",
|
|
3216
|
-
".env",
|
|
3217
|
-
".env.*",
|
|
3218
|
-
"!.env.example",
|
|
3219
|
-
"storage/*.sqlite",
|
|
3220
|
-
"storage/*.sqlite-journal",
|
|
3221
|
-
"storage/*.sqlite-wal",
|
|
3222
|
-
"storage/*.sqlite-shm",
|
|
3223
|
-
"coverage",
|
|
3224
|
-
"docker-compose.yml"
|
|
3225
|
-
];
|
|
3226
|
-
if (needsFrontendBuild(layers.frontend)) {
|
|
3227
|
-
lines.push("frontend/node_modules", "frontend/dist");
|
|
3228
|
-
}
|
|
3229
|
-
return `${lines.join(`
|
|
3230
|
-
`)}
|
|
3231
|
-
`;
|
|
3232
|
-
}
|
|
3233
3285
|
function renderPackageJson(projectName, options = {}) {
|
|
3234
3286
|
const coreDeps = options.workspaceDependencies ? {
|
|
3235
3287
|
"@getstrata/bootstrap": "workspace:*",
|
|
3236
3288
|
"@getstrata/cli": "workspace:*",
|
|
3237
3289
|
"@getstrata/core": "workspace:*"
|
|
3238
3290
|
} : {
|
|
3239
|
-
"@getstrata/bootstrap": "^2.2.
|
|
3240
|
-
"@getstrata/cli": "^2.2.
|
|
3241
|
-
"@getstrata/core": "^2.2.
|
|
3291
|
+
"@getstrata/bootstrap": "^2.2.48",
|
|
3292
|
+
"@getstrata/cli": "^2.2.48",
|
|
3293
|
+
"@getstrata/core": "^2.2.48"
|
|
3242
3294
|
};
|
|
3243
3295
|
coreDeps.eta = "^4.6.0";
|
|
3244
3296
|
if (options.layers?.database === "mysql") {
|
|
@@ -3295,52 +3347,6 @@ function renderLayersManifest(projectName, layers) {
|
|
|
3295
3347
|
}, null, 2)}
|
|
3296
3348
|
`;
|
|
3297
3349
|
}
|
|
3298
|
-
function localEnvVars(services) {
|
|
3299
|
-
const vars = [];
|
|
3300
|
-
for (const name of services) {
|
|
3301
|
-
if (name === "postgres" || name === "mysql") {
|
|
3302
|
-
vars.push("DATABASE_URL");
|
|
3303
|
-
} else if (name === "redis") {
|
|
3304
|
-
vars.push("REDIS_URL");
|
|
3305
|
-
} else if (name === "mailpit") {
|
|
3306
|
-
vars.push("MAIL_HOST");
|
|
3307
|
-
}
|
|
3308
|
-
}
|
|
3309
|
-
return [...new Set(vars)];
|
|
3310
|
-
}
|
|
3311
|
-
function renderSupportingToolsReadme(projectName, layers) {
|
|
3312
|
-
const needed = neededDockerServices(layers);
|
|
3313
|
-
if (needed.length === 0) {
|
|
3314
|
-
return "";
|
|
3315
|
-
}
|
|
3316
|
-
const dockerOn = selectedDockerServices(layers);
|
|
3317
|
-
const dockerSet = new Set(dockerOn);
|
|
3318
|
-
const localOn = needed.filter((name) => !dockerSet.has(name));
|
|
3319
|
-
const lines = ["## Supporting tools", ""];
|
|
3320
|
-
if (dockerOn.length > 0) {
|
|
3321
|
-
const names = dockerOn.map((name) => DOCKER_SERVICE_LABELS[name]).join(", ");
|
|
3322
|
-
lines.push(`Docker Compose includes ${names}.`, "", "```bash", dockerComposeUpCommand(layers), "```", "", "Wait for this command to succeed before migrating. It waits up to 180 seconds for selected services to be healthy; inspect `docker compose ps` and `docker compose logs` if it fails. Increasing `--wait-timeout` can accommodate a slow first initialization. These checks do not run application migrations.", "");
|
|
3323
|
-
if (dockerSet.has("adminer")) {
|
|
3324
|
-
const mysql = layers.database === "mysql";
|
|
3325
|
-
const system = mysql ? "MySQL" : "PostgreSQL";
|
|
3326
|
-
const server = mysql ? "mysql" : "postgres";
|
|
3327
|
-
const username = mysql ? "root" : "postgres";
|
|
3328
|
-
const password = mysql ? GENERATED_MYSQL_ROOT_PASSWORD : GENERATED_POSTGRES_SUPERUSER_PASSWORD;
|
|
3329
|
-
lines.push(`Adminer: http://localhost:8080 (${system}, server \`${server}\`, username \`${username}\`, password \`${password}\`, database \`${appDatabaseName(projectName)}\`).`, "", "Adminer is optional development tooling in the `debug` profile; plain `docker compose up -d` does not start Adminer. Use the profile command above to start it with the database.", "");
|
|
3330
|
-
if (!mysql) {
|
|
3331
|
-
lines.push("Adminer uses the Compose `postgres` superuser, which skips FORCE RLS. Application traffic should use `strata_app`.", "");
|
|
3332
|
-
}
|
|
3333
|
-
}
|
|
3334
|
-
}
|
|
3335
|
-
if (localOn.length > 0) {
|
|
3336
|
-
const names = localOn.map((name) => DOCKER_SERVICE_LABELS[name]).join(", ");
|
|
3337
|
-
const envVars = localEnvVars(localOn).map((name) => `\`${name}\``).join(", ");
|
|
3338
|
-
lines.push(`Use local installs for ${names}. Point ${envVars} in \`.env\` at services on this machine.`, "");
|
|
3339
|
-
}
|
|
3340
|
-
return `${lines.join(`
|
|
3341
|
-
`)}
|
|
3342
|
-
`;
|
|
3343
|
-
}
|
|
3344
3350
|
function renderApiDocs(projectName, layers) {
|
|
3345
3351
|
const rows = ["| Method | Path | Notes |", "| --- | --- | --- |"];
|
|
3346
3352
|
rows.push("| `GET` | `/health` | Plain text `ok` (200) when configured database/Redis checks succeed and `notes` is readable (zero rows is still 200). This infrastructure probe runs outside API auth/tenancy admission, never selects a tenant or bypasses RLS, and returns no rows. `degraded` (503) when a dependency or schema check fails. Docker HEALTHCHECK uses this path. |", '| `GET` | `/ready` | JSON from the framework: `{"status":"ready","checks":{"database":"ok","redis":"skipped"}}` (200) or `not_ready` (503). `redis` is `ok` or `error` when `REDIS_URL` is set and `skipped` otherwise. It does not check the schema, so use `/health` as the deploy gate. |');
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"check": "tsc --noEmit"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@getstrata/bootstrap": "^2.2.
|
|
16
|
-
"@getstrata/cli": "^2.2.
|
|
17
|
-
"@getstrata/core": "^2.2.
|
|
15
|
+
"@getstrata/bootstrap": "^2.2.48",
|
|
16
|
+
"@getstrata/cli": "^2.2.48",
|
|
17
|
+
"@getstrata/core": "^2.2.48",
|
|
18
18
|
"eta": "^4.6.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|