diff --git a/.dockerignore b/.dockerignore index 6d3affb..7a58b66 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,4 +4,7 @@ Dockerfile local_db_data local_redis_data +node_modules +.next +config diff --git a/Dockerfile b/Dockerfile index 88b0dbf..fe89047 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker.io/docker/dockerfile:1 -FROM node:20-alpine AS base +FROM node:22-alpine AS base # Install dependencies only when needed FROM base AS deps @@ -33,32 +33,25 @@ WORKDIR /app ENV NODE_ENV=production # Uncomment the following line in case you want to disable telemetry during runtime. -# ENV NEXT_TELEMETRY_DISABLED=1 +ENV NEXT_TELEMETRY_DISABLED=1 RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs -# Set the correct permission for prerender cache -RUN mkdir .next -RUN chown nextjs:nodejs .next - -# Automatically leverage output traces to reduce image size -# https://nextjs.org/docs/advanced-features/output-file-tracing -COPY --from=builder /app/public ./public -COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ -COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static -COPY --chown=nextjs:nodejs prisma ./prisma +COPY --from=builder --chown=nextjs:nodejs /app/public ./public +COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules +COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next +COPY --chown=nextjs:nodejs package.json . COPY --chown=nextjs:nodejs package-lock.json . +COPY --chown=nextjs:nodejs prisma ./prisma USER nextjs -RUN npm install prisma + EXPOSE 3000 ENV PORT=3000 -# server.js is created by next build from the standalone output -# https://nextjs.org/docs/pages/api-reference/next-config-js/output ENV HOSTNAME="0.0.0.0" CMD ["npm", "run", "start:docker"] \ No newline at end of file diff --git a/next.config.ts b/next.config.ts index 78da825..0308549 100644 --- a/next.config.ts +++ b/next.config.ts @@ -2,7 +2,6 @@ import type { NextConfig } from 'next'; import 'reflect-metadata'; const nextConfig: NextConfig = { - output: 'standalone', eslint: { ignoreDuringBuilds: true, }, diff --git a/package.json b/package.json index b5e0a6a..7076d7a 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,8 @@ "scripts": { "dev": "source config/local_dev.env && next dev", "build": "npm run lint && next build", - "start": "next start", - "start:local": "source config/local_env.env && next start", - "start:docker": "prisma migrate deploy && node server.js", + "start": "source config/local_dev.env && next start", + "start:docker": "prisma migrate deploy && next start", "lint": "eslint ./src", "format": "prettier --write ./src", "prisma": "source config/local_dev.env && prisma migrate dev", diff --git a/src/app/api/db/create-question/route.ts b/src/app/api/db/create-question/route.ts index 07a0dc6..e0a8b35 100644 --- a/src/app/api/db/create-question/route.ts +++ b/src/app/api/db/create-question/route.ts @@ -17,7 +17,7 @@ export async function POST(req: NextRequest) { const token = req.cookies.get('jwtToken')?.value; const tokenPayload = await verifyToken(token) .then((payload) => payload) - .catch(() => {}); + .catch(() => { }); if (tokenPayload) { const limiter = RateLimiterService.getLimiter(); const limited = await limiter.limit(`create-question-${tokenPayload.handle}`, { @@ -102,7 +102,7 @@ export async function POST(req: NextRequest) { } else { // 알림 전송 const url = `${process.env.WEB_URL}/main/questions`; - sendNotify(questionee_user, newQuestion.question, url); + sendNotify(questionee_user, data.questioner, newQuestion.question, url); } // notify send 기다라지 않고 200반환 @@ -112,7 +112,7 @@ export async function POST(req: NextRequest) { } } -async function sendNotify(questionee: user, question: string, url: string): Promise { +async function sendNotify(questionee: user, questioner: string | null, question: string, url: string): Promise { const notify_host = process.env.NOTI_HOST; logger.log(`try to send notification to ${questionee.handle}`); try { @@ -125,7 +125,7 @@ async function sendNotify(questionee: user, question: string, url: string): Prom body: JSON.stringify({ visibleUserIds: [questionee.userId], visibility: 'specified', - text: `${questionee.handle} <네오-퀘스돈> 새로운 질문이에요!\nQ. ${question}\n ${url}`, + text: `${questionee.handle} <네오-퀘스돈> 새로운 질문이에요!\n질문자: ${questioner ? `\`${questioner}\`` : '익명의 질문자'}\nQ. ${question}\n ${url}`, }), }); if (!res.ok) {