fix: adicionar suporte a ASAAS_API_KEY via docker secrets no servidor
Build and Deploy (Gitea Actions) / build-and-deploy (push) Successful in 2m40s
Details
Build and Deploy (Gitea Actions) / build-and-deploy (push) Successful in 2m40s
Details
This commit is contained in:
parent
c71d557900
commit
167c462f3a
|
|
@ -34,9 +34,12 @@ services:
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: postgresql://agendapro_user:${DB_PASSWORD}@postgres-agendapro:5432/agendapro
|
DATABASE_URL: postgresql://agendapro_user:${DB_PASSWORD}@postgres-agendapro:5432/agendapro
|
||||||
JWT_SECRET_FILE: /run/secrets/jwt_secret
|
JWT_SECRET_FILE: /run/secrets/jwt_secret
|
||||||
|
ASAAS_API_KEY_FILE: /run/secrets/asaas_api_key
|
||||||
|
ASAAS_ENVIRONMENT: sandbox
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
secrets:
|
secrets:
|
||||||
- jwt_secret
|
- jwt_secret
|
||||||
|
- asaas_api_key
|
||||||
networks:
|
networks:
|
||||||
- agendapro-internal
|
- agendapro-internal
|
||||||
- network_public
|
- network_public
|
||||||
|
|
@ -61,10 +64,13 @@ services:
|
||||||
DATABASE_URL: postgresql://agendapro_user:${DB_PASSWORD}@postgres-agendapro:5432/agendapro
|
DATABASE_URL: postgresql://agendapro_user:${DB_PASSWORD}@postgres-agendapro:5432/agendapro
|
||||||
JWT_SECRET_FILE: /run/secrets/jwt_secret
|
JWT_SECRET_FILE: /run/secrets/jwt_secret
|
||||||
ADMIN_SECRET_FILE: /run/secrets/admin_secret
|
ADMIN_SECRET_FILE: /run/secrets/admin_secret
|
||||||
|
ASAAS_API_KEY_FILE: /run/secrets/asaas_api_key
|
||||||
|
ASAAS_ENVIRONMENT: sandbox
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
secrets:
|
secrets:
|
||||||
- jwt_secret
|
- jwt_secret
|
||||||
- admin_secret
|
- admin_secret
|
||||||
|
- asaas_api_key
|
||||||
networks:
|
networks:
|
||||||
- agendapro-internal
|
- agendapro-internal
|
||||||
- network_public
|
- network_public
|
||||||
|
|
@ -93,3 +99,5 @@ secrets:
|
||||||
external: true
|
external: true
|
||||||
admin_secret:
|
admin_secret:
|
||||||
external: true
|
external: true
|
||||||
|
asaas_api_key:
|
||||||
|
external: true
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,17 @@ export async function getTenantAsaasConfig(tenantId?: string): Promise<AsaasConf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let envApiKey = process.env.ASAAS_API_KEY;
|
||||||
|
if (!envApiKey && process.env.ASAAS_API_KEY_FILE) {
|
||||||
|
try {
|
||||||
|
envApiKey = require('fs').readFileSync(process.env.ASAAS_API_KEY_FILE, 'utf8').trim();
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to read Asaas API Key from file:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Scoped API Key and Webhook Secret per tenant, with fallback to environment variables for sandbox/dev
|
// Scoped API Key and Webhook Secret per tenant, with fallback to environment variables for sandbox/dev
|
||||||
const apiKey = settings.asaas_api_key || process.env.ASAAS_API_KEY;
|
const apiKey = settings.asaas_api_key || envApiKey;
|
||||||
const webhookSecret = settings.asaas_webhook_secret || process.env.ASAAS_WEBHOOK_SECRET;
|
const webhookSecret = settings.asaas_webhook_secret || process.env.ASAAS_WEBHOOK_SECRET;
|
||||||
|
|
||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue