Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dockerfile #275

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
893 changes: 893 additions & 0 deletions 42manito/.yarn/releases/yarn-sources.cjs

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions 42manito/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile 참고


FROM node:18-alpine AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR ./42manito

# Install dependencies based on the preferred package manager
# COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
# RUN \
# if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
# elif [ -f package-lock.json ]; then npm ci; \
# elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
# else echo "Lockfile not found." && exit 1; \
# fi
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
# RUN yarn --production;
RUN yarn --production && rm -rf ./.next/cache


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR ./42manito
COPY --from=deps ./42manito/node_modules ./node_modules
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN yarn build

# If using npm comment out above and use below instead
# RUN npm run build

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR ./42manito

ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder ./42manito/public ./public

# 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 --chown=nextjs:nodejs ./42manito/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs ./42manito/.next/static ./.next/static

USER nextjs

EXPOSE 3000

# ENV PORT 3000
# # set hostname to localhost
# ENV HOSTNAME "0.0.0.0"

CMD ["node", "server.js"]
8 changes: 7 additions & 1 deletion 42manito/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ const nextConfig = {
},
};

module.exports = nextConfig;
// standalone 상태로 export 하면 프로덕션 배포에 필요한 파일들만 추출해서 독립 실행 가능한 폴더 만들어준다구 해여
// 근데 원래 쓰던 게 있어서 ... 일단 주석처리하고 도커 빌드 되게 해뒀습니다

// module.exports = nextConfig;
module.exports = {
output: "standalone",
};