Docker 런타임 환경 변수 우선 적용

This commit is contained in:
2026-05-14 13:48:23 +09:00
parent 4862b52b3a
commit 1b035de16c
17 changed files with 84 additions and 24 deletions

View File

@@ -1,4 +1,5 @@
import postgres from 'postgres'
import { getRuntimeEnvValue } from '../utils/runtime-env'
let client = null
@@ -13,9 +14,9 @@ const isProductionRuntime = () => process.env.NODE_ENV === 'production'
* @returns {ReturnType<typeof postgres> | null} PostgreSQL 클라이언트
*/
export const getPostgresClient = () => {
const config = useRuntimeConfig()
const databaseUrl = getRuntimeEnvValue('DATABASE_URL', 'databaseUrl').trim()
if (!config.databaseUrl) {
if (!databaseUrl) {
if (isProductionRuntime()) {
throw new Error('DATABASE_URL_REQUIRED')
}
@@ -24,7 +25,7 @@ export const getPostgresClient = () => {
}
if (!client) {
client = postgres(config.databaseUrl, {
client = postgres(databaseUrl, {
max: 5,
idle_timeout: 20,
connect_timeout: 10