diff --git a/Dockerfile b/Dockerfile index 6a4ffd4..6acc917 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,5 @@ FROM node:22-slim - -COPY bokca.pem /usr/local/share/ca-certificates/bokca.crt -ENV NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/bokca.crt -ENV HTTP_PROXY=http://10.16.57.123:31443 \ - HTTPS_PROXY=http://10.16.57.123:31443 \ - NO_PROXY=localhost,127.0.0.1 -RUN npm config set cafile /usr/local/share/ca-certificates/bokca.crt - WORKDIR /app -COPY package*.json ./ -RUN npm ci || npm install COPY . . - EXPOSE 3000 CMD ["npm", "start"] diff --git a/package.json b/package.json index f9fadbc..b5342a2 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,6 @@ "description": "Coolify 배포 테스트 사이트", "main": "server.js", "scripts": { - "start": "node server.js", - "dev": "node --watch server.js" + "start": "node server.js" } } diff --git a/server.js b/server.js index 68a568a..315c0de 100644 --- a/server.js +++ b/server.js @@ -1,86 +1,8 @@ const http = require('http'); -const fs = require('fs'); -const path = require('path'); -const PORT = process.env.PORT || 3000; -const PUBLIC_DIR = path.join(__dirname, 'public'); - -const MIME_TYPES = { - '.html': 'text/html; charset=utf-8', - '.css': 'text/css', - '.js': 'text/javascript', - '.png': 'image/png', - '.jpg': 'image/jpeg', - '.ico': 'image/x-icon', -}; - -function serveStatic(res, filePath) { - fs.readFile(filePath, (err, data) => { - if (err) { - res.writeHead(404); - res.end('Not Found'); - return; - } - const ext = path.extname(filePath); - res.writeHead(200, { 'Content-Type': MIME_TYPES[ext] || 'application/octet-stream' }); - res.end(data); - }); -} - -function sendJson(res, status, body) { - res.writeHead(status, { 'Content-Type': 'application/json' }); - res.end(JSON.stringify(body)); -} - -function readBody(req) { - return new Promise((resolve) => { - let body = ''; - req.on('data', chunk => { body += chunk; }); - req.on('end', () => { - try { resolve(JSON.parse(body)); } - catch { resolve({}); } - }); - }); -} - -const server = http.createServer(async (req, res) => { - const url = new URL(req.url, `http://localhost`); - const pathname = url.pathname; - - // API routes - if (pathname === '/api/greeting' && req.method === 'GET') { - const greetings = ['안녕하세요! 👋', '반갑습니다! 😊', '어서오세요! 🌸', '좋은 하루예요! ☀️', '환영합니다! 🎉']; - sendJson(res, 200, { message: greetings[Math.floor(Math.random() * greetings.length)] }); - return; - } - - if (pathname === '/api/stats' && req.method === 'GET') { - sendJson(res, 200, { - uptime: Math.floor(process.uptime()), - nodeVersion: process.version, - platform: process.platform, - deployedAt: new Date().toISOString(), - }); - return; - } - - if (pathname === '/api/echo' && req.method === 'POST') { - const { text } = await readBody(req); - if (!text) { sendJson(res, 400, { error: '텍스트를 입력해주세요.' }); return; } - sendJson(res, 200, { echo: text, length: text.length }); - return; - } - - // Static files - const filePath = path.join(PUBLIC_DIR, pathname === '/' ? 'index.html' : pathname); - const ext = path.extname(filePath); - if (ext) { - serveStatic(res, filePath); - } else { - serveStatic(res, path.join(PUBLIC_DIR, 'index.html')); - } +const server = http.createServer((req, res) => { + res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' }); + res.end('
node ' + process.version + '
'); }); -server.listen(PORT, () => { - console.log(`서버 실행 중: http://localhost:${PORT}`); -}); +server.listen(3000, () => console.log('listening on 3000'));