업데이트
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -13,13 +13,7 @@ node_modules
|
||||
logs
|
||||
*.log
|
||||
|
||||
# Database
|
||||
database/*.db
|
||||
database/*.db-shm
|
||||
database/*.db-wal
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
.fleet
|
||||
.idea
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
# 운영 환경변수로 빌드
|
||||
COPY .env.prod .env
|
||||
RUN npm run build
|
||||
|
||||
FROM node:20-alpine
|
||||
@@ -29,6 +31,9 @@ COPY --from=builder /app/.output /app/.output
|
||||
COPY --from=builder /app/package*.json /app/
|
||||
RUN npm ci --omit=dev
|
||||
|
||||
# 운영 환경변수 복사
|
||||
COPY .env.prod /app/.env
|
||||
|
||||
# 비root 사용자
|
||||
RUN addgroup -g 1001 -S nodejs \
|
||||
&& adduser -S nuxt -u 1001 -G nodejs \
|
||||
@@ -40,4 +45,5 @@ EXPOSE 3000
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/ || exit 1
|
||||
|
||||
CMD ["node", ".output/server/index.mjs"]
|
||||
# .env 로드 후 실행
|
||||
CMD ["sh", "-c", "export $(grep -v '^#' .env | xargs) && node .output/server/index.mjs"]
|
||||
|
||||
@@ -13,7 +13,7 @@ let pool: pg.Pool | null = null
|
||||
*/
|
||||
export function getPool(): pg.Pool {
|
||||
if (!pool) {
|
||||
pool = new Pool({
|
||||
const config = {
|
||||
host: process.env.DB_HOST || 'localhost',
|
||||
port: parseInt(process.env.DB_PORT || '5432'),
|
||||
database: process.env.DB_NAME || 'osolit_monitor',
|
||||
@@ -22,7 +22,11 @@ export function getPool(): pg.Pool {
|
||||
max: 10,
|
||||
idleTimeoutMillis: 30000,
|
||||
connectionTimeoutMillis: 2000,
|
||||
})
|
||||
}
|
||||
|
||||
console.log(`[DB] Connecting to ${config.host}:${config.port}/${config.database}`)
|
||||
|
||||
pool = new Pool(config)
|
||||
|
||||
pool.on('error', (err) => {
|
||||
console.error('[DB] Unexpected pool error:', err)
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# This file ensures the database directory is included in git
|
||||
# The actual .db files are ignored in .gitignore
|
||||
@@ -43,44 +43,25 @@ export default defineNuxtConfig({
|
||||
// 서버 설정
|
||||
nitro: {
|
||||
preset: 'node-server',
|
||||
// WebSocket 실험적 기능 활성화
|
||||
experimental: {
|
||||
websocket: true
|
||||
},
|
||||
// 네이티브 모듈은 번들링하지 않고 외부 모듈로 처리
|
||||
externals: {
|
||||
inline: []
|
||||
},
|
||||
// rollup에서 external로 처리
|
||||
rollupConfig: {
|
||||
external: ['pg']
|
||||
},
|
||||
// 플러그인 등록
|
||||
plugins: [
|
||||
'~/backend/plugins/pubnet-init.ts',
|
||||
'~/backend/plugins/privnet-init.ts'
|
||||
]
|
||||
},
|
||||
|
||||
// Vite 설정 (네이티브 모듈)
|
||||
// Vite 설정
|
||||
vite: {
|
||||
optimizeDeps: {
|
||||
exclude: ['pg']
|
||||
}
|
||||
},
|
||||
|
||||
// 환경변수 설정
|
||||
runtimeConfig: {
|
||||
// 서버 전용 (NUXT_로 시작하는 환경변수 자동 로드)
|
||||
dbHost: process.env.DB_HOST || 'localhost',
|
||||
dbPort: process.env.DB_PORT || '5432',
|
||||
dbName: process.env.DB_NAME || 'osolit_monitor',
|
||||
dbUser: process.env.DB_USER || 'postgres',
|
||||
dbPassword: process.env.DB_PASSWORD || '',
|
||||
autoStartScheduler: process.env.AUTO_START_SCHEDULER || 'false',
|
||||
// 클라이언트 공개
|
||||
public: {
|
||||
nodeEnv: process.env.NODE_ENV || 'development'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user