2023-11-18 13:54:58 +09:00
|
|
|
FROM node:21-alpine AS base
|
2023-11-10 18:34:35 +09:00
|
|
|
|
|
|
|
FROM base AS deps
|
2023-11-18 13:54:58 +09:00
|
|
|
RUN apk add --no-cache libc6-compat
|
2023-11-10 18:34:35 +09:00
|
|
|
WORKDIR /app
|
2023-11-18 13:54:58 +09:00
|
|
|
COPY package.json yarn.lock ./
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED 0
|
|
|
|
RUN yarn --frozen-lockfile
|
|
|
|
|
2023-11-10 18:34:35 +09:00
|
|
|
|
|
|
|
FROM base AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY . .
|
2023-11-18 13:54:58 +09:00
|
|
|
COPY .env.prod.sample .env
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED 0
|
|
|
|
RUN yarn upgrade
|
2023-11-10 18:34:35 +09:00
|
|
|
RUN npx prisma generate
|
2023-11-18 13:54:58 +09:00
|
|
|
RUN yarn build
|
|
|
|
RUN npm prune --production
|
|
|
|
COPY ./script/start.sh .
|
|
|
|
RUN chmod +x start.sh
|
2023-11-10 18:34:35 +09:00
|
|
|
|
|
|
|
FROM alpine AS runner
|
2023-11-18 13:54:58 +09:00
|
|
|
RUN apk add --no-cache nodejs npm
|
|
|
|
RUN npm install npx -g
|
2023-11-10 18:34:35 +09:00
|
|
|
WORKDIR /app
|
2023-11-18 13:54:58 +09:00
|
|
|
|
2023-11-10 18:34:35 +09:00
|
|
|
ENV NODE_ENV production
|
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/next.config.js ./
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
2023-11-18 13:54:58 +09:00
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/start.sh .
|
2023-11-10 18:34:35 +09:00
|
|
|
|
|
|
|
USER nextjs
|
2023-11-18 13:12:19 +09:00
|
|
|
EXPOSE 3100
|
|
|
|
ENV PORT 3100
|
2023-11-10 18:34:35 +09:00
|
|
|
|
2023-11-18 13:54:58 +09:00
|
|
|
CMD ["sh", "start.sh"]
|