@flydotio/dockerfile
Advanced tools
Comparing version 0.2.16 to 0.3.0
42
fly.js
@@ -24,8 +24,5 @@ import crypto from 'node:crypto' | ||
// set secrets for AdonisJS apps | ||
if (this.adonisjs) this.flyAdonisJsSecrets(this.flyApp) | ||
// set up for deploy | ||
if (fs.existsSync('.github/workflows/deploy.yml')) { | ||
this.flyGitHubPrep() | ||
this.flyGithubPrep() | ||
} | ||
@@ -157,4 +154,4 @@ } | ||
// set various secrets | ||
flySetSecrets({ app, requiredSecrets, shouldSet = () => true }) { | ||
// set various secrets for Remix (and Epic Stack) applications | ||
flyRemixSecrets(app) { | ||
let secrets = this.flySecrets | ||
@@ -173,6 +170,12 @@ | ||
for (const name of requiredSecrets) { | ||
if (!secrets || secrets.includes(name)) continue | ||
if (!shouldSet(name)) continue | ||
const required = [ | ||
'SESSION_SECRET', | ||
'ENCRYPTION_SECRET', | ||
'INTERNAL_COMMAND_TOKEN' | ||
] | ||
for (const name of required) { | ||
if (secrets.includes(name)) return | ||
if (name !== 'SESSION_SECRET' && !this.epicStack) continue | ||
const value = crypto.randomBytes(32).toString('hex') | ||
@@ -188,21 +191,4 @@ | ||
// set various secrets for Remix (and Epic Stack) applications | ||
flyRemixSecrets(app) { | ||
this.flySetSecrets({ | ||
app, | ||
requiredSecrets: ['SESSION_SECRET', 'INTERNAL_COMMAND_TOKEN'], | ||
shouldSet: (name) => name === 'SESSION_SECRET' || this.epicStack | ||
}) | ||
} | ||
// set various secrets for AdonisJS applications | ||
flyAdonisJsSecrets(app) { | ||
this.flySetSecrets({ | ||
app, | ||
requiredSecrets: ['APP_KEY'] | ||
}) | ||
} | ||
// prep for deployment via GitHub actions, including setting up a staging app | ||
flyGitHubPrep() { | ||
// prep for deployment via github actions, inclusing settting up a staging app | ||
flyGithubPrep() { | ||
const deploy = fs.readFileSync('.github/workflows/deploy.yml', 'utf-8') | ||
@@ -209,0 +195,0 @@ |
48
gdf.js
@@ -88,21 +88,2 @@ import fs from 'node:fs' | ||
// Does this application use adonisjs? | ||
get adonisjs() { | ||
return !!this.#pj.dependencies?.['@adonisjs/core'] | ||
} | ||
get adonisjsFileUpload() { | ||
if (!fs.existsSync(path.join(this._appdir, 'config/drive.ts'))) { | ||
return false | ||
} | ||
const driveConfig = fs.readFileSync(path.join(this._appdir, 'config/drive.ts'), 'utf8') | ||
return driveConfig.includes("Application.tmpPath('uploads')") | ||
} | ||
// Does this application use postgres? | ||
get postgres() { | ||
return this.adonisjs && !!this.#pj.dependencies?.pg | ||
} | ||
// Does this application use nest? | ||
@@ -115,10 +96,2 @@ get nestjs() { | ||
get sqlite3() { | ||
if (this.prisma) { | ||
try { | ||
const schema = fs.readFileSync(path.join(this._appdir, 'prisma/schema.prisma'), 'utf-8') | ||
if (/^\s*provider\s*=\s*"sqlite"/m.test(schema)) return true | ||
} catch { | ||
} | ||
} | ||
return !!this.#pj.dependencies?.sqlite3 || | ||
@@ -141,3 +114,2 @@ !!this.#pj.dependencies?.['better-sqlite3'] || | ||
if (this.remix && this.sqlite3) packages.push('sqlite3') | ||
if (this.prisma) packages.push('openssl') | ||
@@ -252,7 +224,5 @@ return packages.sort() | ||
// optionally include dev dependencies | ||
if (this.devDependencies) { | ||
if (this.devDependencies && !this.pnpm) { | ||
if (this.yarn) { | ||
install += ' --production=false' | ||
} else if (this.pnpm) { | ||
install += ' --prod=false' | ||
} else { | ||
@@ -340,3 +310,2 @@ install += ' --include=dev' | ||
if (this.gatsby) runtime = 'Gatsby' | ||
if (this.adonisjs) runtime = 'AdonisJS' | ||
@@ -360,6 +329,2 @@ if (this.prisma) runtime += '/Prisma' | ||
if (this.adonisjs) { | ||
return ['node', '/app/build/server.js'] | ||
} | ||
if (this.gatsby) { | ||
@@ -383,3 +348,3 @@ return ['npx', 'gatsby', 'serve', '-H', '0.0.0.0'] | ||
get entrypoint() { | ||
return this.prisma || this.options.swap || this.adonisjs | ||
return this.prisma || this.options.swap | ||
} | ||
@@ -392,3 +357,3 @@ | ||
const entrypoint = path.join(this._appdir, 'docker-entrypoint.js') | ||
const entrypoint = path.join(this._appdir, 'docker-entrypoint') | ||
@@ -399,7 +364,7 @@ const stat = fs.statSync(entrypoint, { throwIfNoEntry: false }) | ||
if (this.options.windows || !(stat.mode & fs.constants.S_IXUSR)) { | ||
fixups.push('chmod +x ./docker-entrypoint.js') | ||
fixups.push('chmod +x ./docker-entrypoint') | ||
} | ||
if (this.options.windows || fs.readFileSync(entrypoint, 'utf-8').includes('\r')) { | ||
fixups.push('sed -i "s/\\r$//g" ./docker-entrypoint.js') | ||
fixups.push('sed -i "s/\\r$//g" ./docker-entrypoint') | ||
} | ||
@@ -412,4 +377,3 @@ | ||
get usingTabs() { | ||
// disable for now as remix isn't using this generator and it conflicts with eslint | ||
return false // this.remix | ||
return this.remix | ||
} | ||
@@ -416,0 +380,0 @@ |
{ | ||
"name": "@flydotio/dockerfile", | ||
"version": "0.2.16", | ||
"version": "0.3.0", | ||
"description": "Dockerfile generator", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
35996
670