@panoptic-it-solutions/coolify-setup 1.1.7 → 1.1.8
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/generator.js +45 -1
- package/dist/templates/dockerfile.js +2 -5
- package/package.json +1 -1
package/dist/generator.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'fs';
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync, readFileSync, renameSync, readdirSync } from 'fs';
|
|
2
2
|
import { join, dirname } from 'path';
|
|
3
3
|
import { execSync } from 'child_process';
|
|
4
4
|
import { generateDockerfile, generateDockerCompose, generateDockerComposeBuild, generateWorkflow, generateEntrypoint, generateMigrateScript, generateClaudeRules, } from './templates/index.js';
|
|
@@ -47,6 +47,48 @@ function addEsbuildToPackageJson(packageManager) {
|
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
+
function moveMigrationsToLibDb() {
|
|
51
|
+
const result = { movedMigrations: false, movedMigrateTs: false };
|
|
52
|
+
const cwd = process.cwd();
|
|
53
|
+
// Check if db/migrations exists at root level (sibling to lib)
|
|
54
|
+
const dbMigrationsPath = join(cwd, 'db/migrations');
|
|
55
|
+
const libDbMigrationsPath = join(cwd, 'lib/db/migrations');
|
|
56
|
+
if (existsSync(dbMigrationsPath) && !existsSync(libDbMigrationsPath)) {
|
|
57
|
+
// Ensure lib/db directory exists
|
|
58
|
+
ensureDir(join(libDbMigrationsPath, 'dummy'));
|
|
59
|
+
// Move the entire migrations folder
|
|
60
|
+
renameSync(dbMigrationsPath, libDbMigrationsPath);
|
|
61
|
+
result.movedMigrations = true;
|
|
62
|
+
console.log('Moved db/migrations → lib/db/migrations');
|
|
63
|
+
}
|
|
64
|
+
// Check if db/migrate.ts exists at root level
|
|
65
|
+
const dbMigrateTsPath = join(cwd, 'db/migrate.ts');
|
|
66
|
+
const libDbMigrateTsPath = join(cwd, 'lib/db/migrate.ts');
|
|
67
|
+
if (existsSync(dbMigrateTsPath) && !existsSync(libDbMigrateTsPath)) {
|
|
68
|
+
// Ensure lib/db directory exists
|
|
69
|
+
ensureDir(libDbMigrateTsPath);
|
|
70
|
+
// Move migrate.ts
|
|
71
|
+
renameSync(dbMigrateTsPath, libDbMigrateTsPath);
|
|
72
|
+
result.movedMigrateTs = true;
|
|
73
|
+
console.log('Moved db/migrate.ts → lib/db/migrate.ts');
|
|
74
|
+
}
|
|
75
|
+
// Clean up empty db directory if it exists and is empty
|
|
76
|
+
const dbPath = join(cwd, 'db');
|
|
77
|
+
if (existsSync(dbPath)) {
|
|
78
|
+
try {
|
|
79
|
+
const contents = readdirSync(dbPath);
|
|
80
|
+
if (contents.length === 0) {
|
|
81
|
+
// Remove empty directory
|
|
82
|
+
execSync(`rmdir "${dbPath}"`, { stdio: 'pipe' });
|
|
83
|
+
console.log('Removed empty db/ directory');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// Ignore errors when cleaning up
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
50
92
|
function excludeMigrateFromTsConfig(migratePath) {
|
|
51
93
|
const tsconfigPath = join(process.cwd(), 'tsconfig.json');
|
|
52
94
|
if (!existsSync(tsconfigPath)) {
|
|
@@ -117,6 +159,8 @@ export async function generateFiles(options) {
|
|
|
117
159
|
if (added) {
|
|
118
160
|
console.log('Added esbuild to devDependencies (required for migration bundling)');
|
|
119
161
|
}
|
|
162
|
+
// Move migrations from db/ to lib/db/ if they exist at the wrong location
|
|
163
|
+
moveMigrationsToLibDb();
|
|
120
164
|
// Write migrate.ts to lib/db/ for Next.js projects (will be bundled at build time)
|
|
121
165
|
const migratePath = 'lib/db/migrate.ts';
|
|
122
166
|
const existingMigratePath = join(process.cwd(), migratePath);
|
|
@@ -37,15 +37,12 @@ function generateNextjsDockerfile(options) {
|
|
|
37
37
|
|
|
38
38
|
# Build the migration bundle (single JS file with all deps baked in)
|
|
39
39
|
# This avoids module resolution issues in the standalone container
|
|
40
|
-
RUN ${esbuildCmd} lib/db/migrate.ts --bundle --platform=node --target=node22 --outfile=lib/db/migrate.bundle.js --external:dotenv
|
|
40
|
+
RUN ${esbuildCmd} lib/db/migrate.ts --bundle --platform=node --target=node22 --outfile=lib/db/migrate.bundle.js --external:dotenv` : '';
|
|
41
41
|
const migrationCopy = includePostgres ? `
|
|
42
42
|
|
|
43
43
|
# Copy database migrations and bundled migration script
|
|
44
44
|
COPY --from=builder --chown=nextjs:nodejs /app/lib/db/migrations ./lib/db/migrations
|
|
45
|
-
COPY --from=builder --chown=nextjs:nodejs /app/lib/db/migrate.bundle.js ./lib/db/migrate.bundle.js
|
|
46
|
-
|
|
47
|
-
# Copy postgres module for migration script (externalized from bundle)
|
|
48
|
-
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/.pnpm/postgres@*/node_modules/postgres ./node_modules/postgres` : '';
|
|
45
|
+
COPY --from=builder --chown=nextjs:nodejs /app/lib/db/migrate.bundle.js ./lib/db/migrate.bundle.js` : '';
|
|
49
46
|
return `# syntax=docker.io/docker/dockerfile:1
|
|
50
47
|
|
|
51
48
|
FROM node:22-alpine AS base
|