mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
fix infisical deploy
This commit is contained in:
parent
1b8fbf8b0f
commit
73da40932b
@ -2,7 +2,7 @@ module.exports = {
|
||||
apps: [
|
||||
{
|
||||
name: "main_api",
|
||||
script: "./infisical-run.sh",
|
||||
script: "./dist/index.js",
|
||||
instances: "max",
|
||||
exec_mode: "cluster",
|
||||
env: {
|
||||
@ -12,7 +12,7 @@ module.exports = {
|
||||
},
|
||||
{
|
||||
name: "music_api",
|
||||
script: "./infisical-run.sh",
|
||||
script: "./dist/index.js",
|
||||
instances: "max",
|
||||
exec_mode: "cluster",
|
||||
env: {
|
||||
@ -22,7 +22,7 @@ module.exports = {
|
||||
},
|
||||
{
|
||||
name: "file_api",
|
||||
script: "./infisical-run.sh",
|
||||
script: "./dist/index.js",
|
||||
instances: "max",
|
||||
exec_mode: "cluster",
|
||||
env: {
|
||||
@ -32,7 +32,7 @@ module.exports = {
|
||||
},
|
||||
{
|
||||
name: "marketplace_api",
|
||||
script: "./infisical-run.sh",
|
||||
script: "./dist/index.js",
|
||||
instances: "max",
|
||||
exec_mode: "cluster",
|
||||
env: {
|
||||
@ -42,7 +42,7 @@ module.exports = {
|
||||
},
|
||||
{
|
||||
name: "chat_api",
|
||||
script: "./infisical-run.sh",
|
||||
script: "./dist/index.js",
|
||||
instances: "max",
|
||||
exec_mode: "cluster",
|
||||
env: {
|
||||
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/bin/infisical run -- npm run:prod
|
@ -1,13 +1,12 @@
|
||||
require("dotenv").config()
|
||||
|
||||
if (typeof process.env.NODE_ENV === "undefined") {
|
||||
process.env.NODE_ENV = "development"
|
||||
}
|
||||
|
||||
global.isProduction = process.env.NODE_ENV === "production"
|
||||
|
||||
import { webcrypto as crypto } from "crypto"
|
||||
import path from "path"
|
||||
import { registerBaseAliases } from "linebridge/dist/server"
|
||||
import infisical from "infisical-node"
|
||||
|
||||
require("dotenv").config()
|
||||
|
||||
global.isProduction = process.env.NODE_ENV === "production"
|
||||
|
||||
globalThis["__root"] = path.resolve(__dirname)
|
||||
|
||||
@ -34,6 +33,8 @@ global.b64Encode = (data) => {
|
||||
return Buffer.from(data, "utf-8").toString("base64")
|
||||
}
|
||||
|
||||
global.nanoid = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce(((t, e) => t += (e &= 63) < 36 ? e.toString(36) : e < 62 ? (e - 26).toString(36).toUpperCase() : e > 62 ? "-" : "_"), "");
|
||||
|
||||
Array.prototype.updateFromObjectKeys = function (obj) {
|
||||
this.forEach((value, index) => {
|
||||
if (obj[value] !== undefined) {
|
||||
@ -59,9 +60,60 @@ global.toBoolean = (value) => {
|
||||
import API from "./api"
|
||||
|
||||
async function main() {
|
||||
const api = new API()
|
||||
if (process.env.INFISICAL_TOKEN) {
|
||||
const client = new infisical({
|
||||
token: process.env.INFISICAL_TOKEN,
|
||||
})
|
||||
|
||||
await api.initialize()
|
||||
const secrets = await client.getAllSecrets()
|
||||
|
||||
// inject to process.env
|
||||
secrets.forEach((secret) => {
|
||||
process.env[secret.secretName] = secret.secretValue
|
||||
})
|
||||
}
|
||||
|
||||
const instance = new API()
|
||||
|
||||
await instance.initialize()
|
||||
|
||||
// kill on process exit
|
||||
process.on("exit", () => {
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
// kill on ctrl+c
|
||||
process.on("SIGINT", () => {
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
// kill on uncaught exceptions
|
||||
process.on("uncaughtException", (error) => {
|
||||
console.error(`🆘 [FATAL ERROR] >`, error)
|
||||
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
// kill on unhandled rejections
|
||||
process.on("unhandledRejection", (error) => {
|
||||
console.error(`🆘 [FATAL ERROR] >`, error)
|
||||
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/bin/infisical run -- npm run:prod
|
@ -1,9 +1,12 @@
|
||||
require("dotenv").config()
|
||||
global.isProduction = process.env.NODE_ENV === "production"
|
||||
|
||||
import { webcrypto as crypto } from "crypto"
|
||||
import path from "path"
|
||||
import { registerBaseAliases } from "linebridge/dist/server"
|
||||
import infisical from "infisical-node"
|
||||
|
||||
require("dotenv").config()
|
||||
|
||||
global.isProduction = process.env.NODE_ENV === "production"
|
||||
|
||||
globalThis["__root"] = path.resolve(__dirname)
|
||||
|
||||
@ -57,35 +60,60 @@ global.toBoolean = (value) => {
|
||||
import API from "./api"
|
||||
|
||||
async function main() {
|
||||
if (process.env.INFISICAL_TOKEN) {
|
||||
const client = new infisical({
|
||||
token: process.env.INFISICAL_TOKEN,
|
||||
})
|
||||
|
||||
const secrets = await client.getAllSecrets()
|
||||
|
||||
// inject to process.env
|
||||
secrets.forEach((secret) => {
|
||||
process.env[secret.secretName] = secret.secretValue
|
||||
})
|
||||
}
|
||||
|
||||
const instance = new API()
|
||||
|
||||
await instance.initialize()
|
||||
|
||||
// // kill on process exit
|
||||
// process.on("exit", () => {
|
||||
// instance.server.close()
|
||||
// process.exit(0)
|
||||
// })
|
||||
// kill on process exit
|
||||
process.on("exit", () => {
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
// // kill on ctrl+c
|
||||
// process.on("SIGINT", () => {
|
||||
// instance.server.close()
|
||||
// process.exit(0)
|
||||
// })
|
||||
// kill on ctrl+c
|
||||
process.on("SIGINT", () => {
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
// // kill on uncaught exceptions
|
||||
// process.on("uncaughtException", (error) => {
|
||||
// console.error(`🆘 [FATAL ERROR] >`, error)
|
||||
// instance.server.close()
|
||||
// process.exit(1)
|
||||
// })
|
||||
// kill on uncaught exceptions
|
||||
process.on("uncaughtException", (error) => {
|
||||
console.error(`🆘 [FATAL ERROR] >`, error)
|
||||
|
||||
// // kill on unhandled rejections
|
||||
// process.on("unhandledRejection", (error) => {
|
||||
// console.error(`🆘 [FATAL ERROR] >`, error)
|
||||
// instance.server.close()
|
||||
// process.exit(1)
|
||||
// })
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
// kill on unhandled rejections
|
||||
process.on("unhandledRejection", (error) => {
|
||||
console.error(`🆘 [FATAL ERROR] >`, error)
|
||||
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/bin/infisical run -- npm run:prod
|
@ -1,9 +1,12 @@
|
||||
require("dotenv").config()
|
||||
global.isProduction = process.env.NODE_ENV === "production"
|
||||
|
||||
import { webcrypto as crypto } from "crypto"
|
||||
import path from "path"
|
||||
import { registerBaseAliases } from "linebridge/dist/server"
|
||||
import infisical from "infisical-node"
|
||||
|
||||
require("dotenv").config()
|
||||
|
||||
global.isProduction = process.env.NODE_ENV === "production"
|
||||
|
||||
globalThis["__root"] = path.resolve(__dirname)
|
||||
|
||||
@ -57,33 +60,58 @@ global.toBoolean = (value) => {
|
||||
import API from "./api"
|
||||
|
||||
async function main() {
|
||||
if (process.env.INFISICAL_TOKEN) {
|
||||
const client = new infisical({
|
||||
token: process.env.INFISICAL_TOKEN,
|
||||
})
|
||||
|
||||
const secrets = await client.getAllSecrets()
|
||||
|
||||
// inject to process.env
|
||||
secrets.forEach((secret) => {
|
||||
process.env[secret.secretName] = secret.secretValue
|
||||
})
|
||||
}
|
||||
|
||||
const instance = new API()
|
||||
|
||||
await instance.initialize()
|
||||
|
||||
// kill on process exit
|
||||
process.on("exit", () => {
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
// kill on ctrl+c
|
||||
process.on("SIGINT", () => {
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
// kill on uncaught exceptions
|
||||
process.on("uncaughtException", (error) => {
|
||||
console.error(`🆘 [FATAL ERROR] >`, error)
|
||||
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
// kill on unhandled rejections
|
||||
process.on("unhandledRejection", (error) => {
|
||||
console.error(`🆘 [FATAL ERROR] >`, error)
|
||||
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/bin/infisical run -- npm run:prod
|
@ -1,13 +1,12 @@
|
||||
require("dotenv").config()
|
||||
|
||||
if (typeof process.env.NODE_ENV === "undefined") {
|
||||
process.env.NODE_ENV = "development"
|
||||
}
|
||||
|
||||
global.isProduction = process.env.NODE_ENV === "production"
|
||||
|
||||
import { webcrypto as crypto } from "crypto"
|
||||
import path from "path"
|
||||
import { registerBaseAliases } from "linebridge/dist/server"
|
||||
import infisical from "infisical-node"
|
||||
|
||||
require("dotenv").config()
|
||||
|
||||
global.isProduction = process.env.NODE_ENV === "production"
|
||||
|
||||
globalThis["__root"] = path.resolve(__dirname)
|
||||
|
||||
@ -34,6 +33,8 @@ global.b64Encode = (data) => {
|
||||
return Buffer.from(data, "utf-8").toString("base64")
|
||||
}
|
||||
|
||||
global.nanoid = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce(((t, e) => t += (e &= 63) < 36 ? e.toString(36) : e < 62 ? (e - 26).toString(36).toUpperCase() : e > 62 ? "-" : "_"), "");
|
||||
|
||||
Array.prototype.updateFromObjectKeys = function (obj) {
|
||||
this.forEach((value, index) => {
|
||||
if (obj[value] !== undefined) {
|
||||
@ -59,33 +60,58 @@ global.toBoolean = (value) => {
|
||||
import API from "./api"
|
||||
|
||||
async function main() {
|
||||
const api = new API()
|
||||
if (process.env.INFISICAL_TOKEN) {
|
||||
const client = new infisical({
|
||||
token: process.env.INFISICAL_TOKEN,
|
||||
})
|
||||
|
||||
await api.initialize()
|
||||
const secrets = await client.getAllSecrets()
|
||||
|
||||
// inject to process.env
|
||||
secrets.forEach((secret) => {
|
||||
process.env[secret.secretName] = secret.secretValue
|
||||
})
|
||||
}
|
||||
|
||||
const instance = new API()
|
||||
|
||||
await instance.initialize()
|
||||
|
||||
// kill on process exit
|
||||
process.on("exit", () => {
|
||||
api.server.close()
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
// kill on ctrl+c
|
||||
process.on("SIGINT", () => {
|
||||
api.server.close()
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
// kill on uncaught exceptions
|
||||
process.on("uncaughtException", (error) => {
|
||||
console.error(`🆘 [FATAL ERROR] >`, error)
|
||||
api.server.close()
|
||||
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
// kill on unhandled rejections
|
||||
process.on("unhandledRejection", (error) => {
|
||||
console.error(`🆘 [FATAL ERROR] >`, error)
|
||||
api.server.close()
|
||||
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/bin/infisical run -- npm run:prod
|
@ -5,8 +5,7 @@
|
||||
"scripts": {
|
||||
"build": "corenode-cli build",
|
||||
"dev": "cross-env NODE_ENV=development nodemon --ignore dist/ --exec corenode-node ./src/index.js",
|
||||
"run:prod": "cross-env NODE_ENV=production node ./dist/index.js",
|
||||
"run:infisical:prod": "infisical run -- npm run run:prod"
|
||||
"run:prod": "cross-env NODE_ENV=production node ./dist/index.js"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@ -26,6 +25,7 @@
|
||||
"dotenv": "^16.0.3",
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"formidable": "^2.1.1",
|
||||
"infisical-node": "^1.2.1",
|
||||
"jimp": "^0.16.2",
|
||||
"jsonwebtoken": "^9.0.0",
|
||||
"linebridge": "0.15.13",
|
||||
|
@ -1,16 +1,24 @@
|
||||
require("dotenv").config()
|
||||
global.isProduction = process.env.NODE_ENV === "production"
|
||||
|
||||
import { webcrypto as crypto } from "crypto"
|
||||
import path from "path"
|
||||
import { registerBaseAliases } from "linebridge/dist/server"
|
||||
import infisical from "infisical-node"
|
||||
|
||||
require("dotenv").config()
|
||||
|
||||
global.isProduction = process.env.NODE_ENV === "production"
|
||||
|
||||
globalThis["__root"] = path.resolve(__dirname)
|
||||
|
||||
const customAliases = {
|
||||
"root": globalThis["__root"],
|
||||
"@shared-classes": path.resolve(__dirname, "_shared/classes"),
|
||||
"@services": path.resolve(__dirname, "services"),
|
||||
}
|
||||
|
||||
if (!global.isProduction) {
|
||||
customAliases["comty.js"] = path.resolve(__dirname, "../../comty.js/src")
|
||||
customAliases["@shared-classes"] = path.resolve(__dirname, "shared-classes")
|
||||
}
|
||||
|
||||
registerBaseAliases(undefined, customAliases)
|
||||
@ -52,9 +60,60 @@ global.toBoolean = (value) => {
|
||||
import API from "./api"
|
||||
|
||||
async function main() {
|
||||
const mainAPI = new API()
|
||||
if (process.env.INFISICAL_TOKEN) {
|
||||
const client = new infisical({
|
||||
token: process.env.INFISICAL_TOKEN,
|
||||
})
|
||||
|
||||
await mainAPI.initialize()
|
||||
const secrets = await client.getAllSecrets()
|
||||
|
||||
// inject to process.env
|
||||
secrets.forEach((secret) => {
|
||||
process.env[secret.secretName] = secret.secretValue
|
||||
})
|
||||
}
|
||||
|
||||
const instance = new API()
|
||||
|
||||
await instance.initialize()
|
||||
|
||||
// kill on process exit
|
||||
process.on("exit", () => {
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
// kill on ctrl+c
|
||||
process.on("SIGINT", () => {
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
// kill on uncaught exceptions
|
||||
process.on("uncaughtException", (error) => {
|
||||
console.error(`🆘 [FATAL ERROR] >`, error)
|
||||
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
// kill on unhandled rejections
|
||||
process.on("unhandledRejection", (error) => {
|
||||
console.error(`🆘 [FATAL ERROR] >`, error)
|
||||
|
||||
if (typeof instance.server.close === "function") {
|
||||
instance.server.close()
|
||||
}
|
||||
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
|
@ -1,3 +1,5 @@
|
||||
require("dotenv").config()
|
||||
|
||||
const path = require("path")
|
||||
const fs = require("fs")
|
||||
const child_process = require("child_process")
|
||||
@ -26,7 +28,6 @@ async function main() {
|
||||
}
|
||||
|
||||
// copy entire shared folder
|
||||
// shared/* => /_shared/*
|
||||
fs.mkdirSync(sharedPath, { recursive: true })
|
||||
|
||||
await child_process.execSync(`cp -r ${sharedRootPath}/* ${sharedPath} && echo Shared lib copied`, {
|
||||
@ -39,6 +40,19 @@ async function main() {
|
||||
cwd: packagePath,
|
||||
stdio: "inherit"
|
||||
})
|
||||
|
||||
if (process.env.INFISICAL_TOKEN) {
|
||||
// write env
|
||||
const envPath = path.resolve(packagePath, ".env")
|
||||
|
||||
if (fs.existsSync(envPath)) {
|
||||
fs.unlinkSync(envPath)
|
||||
}
|
||||
|
||||
const envData = `INFISICAL_TOKEN="${process.env.INFISICAL_TOKEN}"`
|
||||
|
||||
await fs.writeFileSync(envPath, envData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user