Vincula variáveis de ambiente e ativa MiniMax oficial em produção

This commit is contained in:
2026-08-31 21:43:00 +00:00
parent ca2ba82b3f
commit b35f817e45
2 changed files with 145 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
const { Client } = require('pg');
const fs = require('fs');
const dotenv = require('dotenv');
const crypto = require('crypto');
async function syncCoolifyEnv() {
const envConfig = dotenv.parse(fs.readFileSync('/root/Apps/Camila/.env', 'utf-8'));
// Conectar ao coolify-db via docker exec ou porta local
// Vamos usar o psql via child_process ou pg conectado ao container
console.log('Variáveis encontradas no .env:', Object.keys(envConfig));
const client = new Client({
host: '127.0.0.1',
port: 5432,
user: 'coolify',
password: process.env.COOLIFY_DB_PASSWORD || '',
database: 'coolify'
});
// Como o coolify-db pode estar em rede docker interna, vamos gerar as queries SQL
const applicationId = 39;
const queries = [];
for (const [key, value] of Object.entries(envConfig)) {
if (!key || !value) continue;
const uuid = crypto.randomBytes(12).toString('hex');
const safeKey = key.replace(/'/g, "''");
const safeVal = value.replace(/'/g, "''");
// Inserir ou atualizar se já existir
const sql = `
INSERT INTO environment_variables (
key, value, resourceable_type, resourceable_id, is_runtime, is_buildtime, is_preview, is_shown_once, is_multiline, is_literal, is_required, is_shared, version, uuid, created_at, updated_at
) VALUES (
'${safeKey}', '${safeVal}', 'App\\\\Models\\\\Application', ${applicationId}, true, true, false, false, false, false, false, false, '4.0.0-beta.239', '${uuid}', NOW(), NOW()
) ON CONFLICT DO NOTHING;
`;
queries.push(sql);
}
const fullSql = `
DELETE FROM environment_variables WHERE resourceable_id = ${applicationId} AND key != 'NIXPACKS_NODE_VERSION';
${queries.join('\n')}
`;
fs.writeFileSync('/root/Apps/Camila/scratch/sync_env.sql', fullSql);
console.log('Script SQL gerado com sucesso em /root/Apps/Camila/scratch/sync_env.sql');
}
syncCoolifyEnv();
+94
View File
@@ -0,0 +1,94 @@
DELETE FROM environment_variables WHERE resourceable_id = 39 AND key != 'NIXPACKS_NODE_VERSION';
INSERT INTO environment_variables (
key, value, resourceable_type, resourceable_id, is_runtime, is_buildtime, is_preview, is_shown_once, is_multiline, is_literal, is_required, is_shared, version, uuid, created_at, updated_at
) VALUES (
'PORT', '3000', 'App\\Models\\Application', 39, true, true, false, false, false, false, false, false, '4.0.0-beta.239', '93f7d974fb3880c2e56c0439', NOW(), NOW()
) ON CONFLICT DO NOTHING;
INSERT INTO environment_variables (
key, value, resourceable_type, resourceable_id, is_runtime, is_buildtime, is_preview, is_shown_once, is_multiline, is_literal, is_required, is_shared, version, uuid, created_at, updated_at
) VALUES (
'ACCESS_PASSWORD', 'puglindo26', 'App\\Models\\Application', 39, true, true, false, false, false, false, false, false, '4.0.0-beta.239', 'ddb72dd0f944cfd26c87be25', NOW(), NOW()
) ON CONFLICT DO NOTHING;
INSERT INTO environment_variables (
key, value, resourceable_type, resourceable_id, is_runtime, is_buildtime, is_preview, is_shown_once, is_multiline, is_literal, is_required, is_shared, version, uuid, created_at, updated_at
) VALUES (
'OPENROUTER_API_KEY', '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', 'App\\Models\\Application', 39, true, true, false, false, false, false, false, false, '4.0.0-beta.239', 'e9a5940f96ef354585d9d5cd', NOW(), NOW()
) ON CONFLICT DO NOTHING;
INSERT INTO environment_variables (
key, value, resourceable_type, resourceable_id, is_runtime, is_buildtime, is_preview, is_shown_once, is_multiline, is_literal, is_required, is_shared, version, uuid, created_at, updated_at
) VALUES (
'OPENROUTER_MODEL', 'openai/gpt-4.1-nano', 'App\\Models\\Application', 39, true, true, false, false, false, false, false, false, '4.0.0-beta.239', '952970dc5a70c751aa4fa9ca', NOW(), NOW()
) ON CONFLICT DO NOTHING;
INSERT INTO environment_variables (
key, value, resourceable_type, resourceable_id, is_runtime, is_buildtime, is_preview, is_shown_once, is_multiline, is_literal, is_required, is_shared, version, uuid, created_at, updated_at
) VALUES (
'SESSION_SECRET', 'pedagog-secret-key-321123', 'App\\Models\\Application', 39, true, true, false, false, false, false, false, false, '4.0.0-beta.239', '82db51351a05337471c32639', NOW(), NOW()
) ON CONFLICT DO NOTHING;
INSERT INTO environment_variables (
key, value, resourceable_type, resourceable_id, is_runtime, is_buildtime, is_preview, is_shown_once, is_multiline, is_literal, is_required, is_shared, version, uuid, created_at, updated_at
) VALUES (
'MINIMAX_API_KEY', 'sk-cp-siEwoNh9WA3Prxe6frpJ2HsXPje-gjt5jObhHloqqoO0FX0i9yP54N3zhY492GKu18l9XiANDiCoECU3t0uMtRODvkzzi93A2Rmtco6MjATrKNOEDR_bxa4', 'App\\Models\\Application', 39, true, true, false, false, false, false, false, false, '4.0.0-beta.239', '669e7bd2f2ff11bd87932c54', NOW(), NOW()
) ON CONFLICT DO NOTHING;
INSERT INTO environment_variables (
key, value, resourceable_type, resourceable_id, is_runtime, is_buildtime, is_preview, is_shown_once, is_multiline, is_literal, is_required, is_shared, version, uuid, created_at, updated_at
) VALUES (
'MINIMAX_API_BASE', 'https://api.minimax.io/v1', 'App\\Models\\Application', 39, true, true, false, false, false, false, false, false, '4.0.0-beta.239', '510c37f52ea6d053f3a7cabe', NOW(), NOW()
) ON CONFLICT DO NOTHING;
INSERT INTO environment_variables (
key, value, resourceable_type, resourceable_id, is_runtime, is_buildtime, is_preview, is_shown_once, is_multiline, is_literal, is_required, is_shared, version, uuid, created_at, updated_at
) VALUES (
'GROQ_API_KEY', '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', 'App\\Models\\Application', 39, true, true, false, false, false, false, false, false, '4.0.0-beta.239', '717a9c70823db24809bfabd5', NOW(), NOW()
) ON CONFLICT DO NOTHING;
INSERT INTO environment_variables (
key, value, resourceable_type, resourceable_id, is_runtime, is_buildtime, is_preview, is_shown_once, is_multiline, is_literal, is_required, is_shared, version, uuid, created_at, updated_at
) VALUES (
'GROQ_MODEL', 'openai/gpt-oss-120b', 'App\\Models\\Application', 39, true, true, false, false, false, false, false, false, '4.0.0-beta.239', '2fd18b3070398727dc832fa4', NOW(), NOW()
) ON CONFLICT DO NOTHING;
INSERT INTO environment_variables (
key, value, resourceable_type, resourceable_id, is_runtime, is_buildtime, is_preview, is_shown_once, is_multiline, is_literal, is_required, is_shared, version, uuid, created_at, updated_at
) VALUES (
'GOOGLE_AI_API_KEY', 'AIzaSyACelmI6-Bxc7TZ0sAzzgLd_F8VBexOjcQ', 'App\\Models\\Application', 39, true, true, false, false, false, false, false, false, '4.0.0-beta.239', 'd8b6b008cc53c2aa2565faf4', NOW(), NOW()
) ON CONFLICT DO NOTHING;
INSERT INTO environment_variables (
key, value, resourceable_type, resourceable_id, is_runtime, is_buildtime, is_preview, is_shown_once, is_multiline, is_literal, is_required, is_shared, version, uuid, created_at, updated_at
) VALUES (
'GOOGLE_AI_MODEL', 'gemini-2.5-flash', 'App\\Models\\Application', 39, true, true, false, false, false, false, false, false, '4.0.0-beta.239', '0b5a0cacb217b11ff7d0b3ea', NOW(), NOW()
) ON CONFLICT DO NOTHING;
INSERT INTO environment_variables (
key, value, resourceable_type, resourceable_id, is_runtime, is_buildtime, is_preview, is_shown_once, is_multiline, is_literal, is_required, is_shared, version, uuid, created_at, updated_at
) VALUES (
'DATABASE_URL', 'postgresql://postgres:Xz0oyb6ArGYG5uAVTVwcvJxRrMuT7EIJ@supabase-db-h0oggskgs0ws0sco8kc4s8ws:5432/postgres', 'App\\Models\\Application', 39, true, true, false, false, false, false, false, false, '4.0.0-beta.239', '1b67af42721bec98cf163bcd', NOW(), NOW()
) ON CONFLICT DO NOTHING;
INSERT INTO environment_variables (
key, value, resourceable_type, resourceable_id, is_runtime, is_buildtime, is_preview, is_shown_once, is_multiline, is_literal, is_required, is_shared, version, uuid, created_at, updated_at
) VALUES (
'MINIMAX_MODEL', 'MiniMax-M3', 'App\\Models\\Application', 39, true, true, false, false, false, false, false, false, '4.0.0-beta.239', 'e36620572f5a87537eef95a4', NOW(), NOW()
) ON CONFLICT DO NOTHING;