@flydotio/dockerfile
Advanced tools
Comparing version 0.2.14 to 0.2.15
35
fly.js
@@ -24,2 +24,5 @@ import crypto from 'node:crypto' | ||
// set secrets for adonisjs apps | ||
if (this.adonisjs) this.flyAdonisJsSecrets(this.flyApp) | ||
// set up for deploy | ||
@@ -171,3 +174,2 @@ if (fs.existsSync('.github/workflows/deploy.yml')) { | ||
'SESSION_SECRET', | ||
'ENCRYPTION_SECRET', | ||
'INTERNAL_COMMAND_TOKEN' | ||
@@ -190,2 +192,33 @@ ] | ||
flyAdonisJsSecrets(app) { | ||
let secrets = this.flySecrets | ||
if (app !== this.flyApp) { | ||
// get a list of secrets for selected app | ||
try { | ||
secrets = JSON.parse( | ||
execSync(`${this.flyctl} secrets list --app ${app} --json`, { encoding: 'utf8' }) | ||
).map(secret => secret.Name) | ||
} catch { | ||
return // likely got an error like "Could not find App" | ||
} | ||
} | ||
const required = [ | ||
'APP_KEY' | ||
] | ||
for (const name of required) { | ||
if (secrets.includes(name)) return | ||
const value = crypto.randomBytes(32).toString('hex') | ||
console.log(`${chalk.bold.green('execute'.padStart(11))} flyctl secrets set ${name}`) | ||
execSync( | ||
`${this.flyctl} secrets set ${name}=${value} --app ${app}`, | ||
{ stdio: 'inherit' } | ||
) | ||
} | ||
} | ||
// prep for deployment via github actions, inclusing settting up a staging app | ||
@@ -192,0 +225,0 @@ flyGithubPrep() { |
36
gdf.js
@@ -88,2 +88,22 @@ import fs from 'node:fs' | ||
// Does this application use adonisjs? | ||
get adonisjs() { | ||
return !!this.#pj.dependencies?.['@adonisjs/core'] | ||
} | ||
get adonisjsFileUpload() { | ||
console.log('adonisjsFileUpload', fs.existsSync(path.join(this._appdir, 'config/drive.ts'))) | ||
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? | ||
@@ -309,2 +329,3 @@ get nestjs() { | ||
if (this.gatsby) runtime = 'Gatsby' | ||
if (this.adonisjs) runtime = 'AdonisJS' | ||
@@ -328,2 +349,6 @@ if (this.prisma) runtime += '/Prisma' | ||
if (this.adonisjs) { | ||
return ['node', '/app/build/server.js'] | ||
} | ||
if (this.gatsby) { | ||
@@ -347,3 +372,3 @@ return ['npx', 'gatsby', 'serve', '-H', '0.0.0.0'] | ||
get entrypoint() { | ||
return this.prisma || this.options.swap | ||
return this.prisma || this.options.swap || this.adonisjs | ||
} | ||
@@ -356,3 +381,3 @@ | ||
const entrypoint = path.join(this._appdir, 'docker-entrypoint') | ||
const entrypoint = path.join(this._appdir, 'docker-entrypoint.js') | ||
@@ -363,7 +388,7 @@ const stat = fs.statSync(entrypoint, { throwIfNoEntry: false }) | ||
if (this.options.windows || !(stat.mode & fs.constants.S_IXUSR)) { | ||
fixups.push('chmod +x ./docker-entrypoint') | ||
fixups.push('chmod +x ./docker-entrypoint.js') | ||
} | ||
if (this.options.windows || fs.readFileSync(entrypoint, 'utf-8').includes('\r')) { | ||
fixups.push('sed -i "s/\\r$//g" ./docker-entrypoint') | ||
fixups.push('sed -i "s/\\r$//g" ./docker-entrypoint.js') | ||
} | ||
@@ -376,3 +401,4 @@ | ||
get usingTabs() { | ||
return this.remix | ||
// disable for now as remix isn't using this generator and it conflicts with eslint | ||
return false // this.remix | ||
} | ||
@@ -379,0 +405,0 @@ |
{ | ||
"name": "@flydotio/dockerfile", | ||
"version": "0.2.14", | ||
"version": "0.2.15", | ||
"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
39276
719