updated database config
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 6m6s

This commit is contained in:
liquidrinu 2025-05-24 14:05:35 +02:00
parent fe6ceb5b39
commit fda611d249
4 changed files with 54 additions and 5 deletions

@ -24,6 +24,4 @@ spec:
- name: {{ $key }}
value: "{{ $val }}"
{{- end }}
- name: POSTGRES_HOSTNAME
value: "{{ .Values.backend.env.POSTGRES_HOST }}"
restartPolicy: Never

@ -10,9 +10,42 @@ data:
host all all ::1/128 trust
host all all 0.0.0.0/0 md5
postgresql.conf: |
# Connection Settings
listen_addresses = '*'
max_connections = 100
# Memory Settings
shared_buffers = 128MB
dynamic_shared_memory_type = posix
work_mem = 4MB
maintenance_work_mem = 64MB
# Write Ahead Log
max_wal_size = 1GB
min_wal_size = 80MB
checkpoint_timeout = 5min
checkpoint_completion_target = 0.9
# Query Planner
random_page_cost = 1.1
effective_cache_size = 4GB
# Autovacuum
autovacuum = on
autovacuum_max_workers = 3
autovacuum_naptime = 1min
autovacuum_vacuum_threshold = 50
autovacuum_analyze_threshold = 50
# Logging
log_min_duration_statement = 1000
log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
log_temp_files = 0
log_autovacuum_min_duration = 0
# Other Settings
dynamic_shared_memory_type = posix
effective_io_concurrency = 200
default_statistics_target = 100

@ -27,7 +27,7 @@ backend:
cpu: "500m"
memory: "512Mi"
env:
POSTGRES_HOST: postgres-service
POSTGRES_HOSTNAME: postgres-service
POSTGRES_PORT: "5432"
POSTGRES_NAME: fusero-db
POSTGRES_USER: prod_admin
@ -65,3 +65,5 @@ postgres:
cpu: "500m"
memory: "512Mi"
password: "<POSTGRES_PASSWORD>"
user: "prod_admin"
dbName: "fusero-db"

@ -3,12 +3,21 @@ import { PostgreSqlDriver } from '@mikro-orm/postgresql';
import { Migrator } from '@mikro-orm/migrations';
import dotenv from 'dotenv';
// Load environment variables if not in Kubernetes
if (process.env.KUBERNETES_SERVICE_HOST === undefined) {
dotenv.config({ override: true });
}
const isProduction = process.env.NODE_ENV === 'production';
// Validate required environment variables
const requiredEnvVars = ['POSTGRES_NAME', 'POSTGRES_USER', 'POSTGRES_PASSWORD'];
const missingEnvVars = requiredEnvVars.filter(envVar => !process.env[envVar]);
if (missingEnvVars.length > 0 && isProduction) {
throw new Error(`Missing required environment variables: ${missingEnvVars.join(', ')}`);
}
const config: Options = {
driver: PostgreSqlDriver,
entities: [
@ -43,6 +52,13 @@ const config: Options = {
snapshot: true,
emit: 'ts',
},
// Add connection pool settings
pool: {
min: 2,
max: 10,
idleTimeoutMillis: 30000,
acquireTimeoutMillis: 30000,
},
};
export default config;