Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
yunochi committed Nov 23, 2024
2 parents 08760e0 + 0e7d9fb commit ea9c1e5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
Dockerfile
local_db_data
local_redis_data
node_modules
.next
config

23 changes: 8 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"]
1 change: 0 additions & 1 deletion next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { NextConfig } from 'next';
import 'reflect-metadata';

const nextConfig: NextConfig = {
output: 'standalone',
eslint: {
ignoreDuringBuilds: true,
},
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/app/api/db/create-question/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`, {
Expand Down Expand Up @@ -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반환
Expand All @@ -112,7 +112,7 @@ export async function POST(req: NextRequest) {
}
}

async function sendNotify(questionee: user, question: string, url: string): Promise<void> {
async function sendNotify(questionee: user, questioner: string | null, question: string, url: string): Promise<void> {
const notify_host = process.env.NOTI_HOST;
logger.log(`try to send notification to ${questionee.handle}`);
try {
Expand All @@ -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) {
Expand Down

0 comments on commit ea9c1e5

Please sign in to comment.