2023-10-15 03:07:36 +00:00
|
|
|
FROM fascinated/docker-images:node-pnpm-latest AS base
|
2023-10-15 02:59:34 +00:00
|
|
|
|
2023-10-15 03:07:36 +00:00
|
|
|
# Install depends
|
|
|
|
FROM base AS deps
|
|
|
|
RUN apk add --no-cache libc6-compat
|
2022-10-26 11:15:56 +00:00
|
|
|
WORKDIR /app
|
2023-10-15 03:07:36 +00:00
|
|
|
COPY package.json* pnpm-lock.yaml* ./
|
|
|
|
RUN pnpm install --production --frozen-lockfile --quiet
|
2022-10-26 11:15:56 +00:00
|
|
|
|
2023-10-15 03:07:36 +00:00
|
|
|
# Build from source
|
|
|
|
FROM base AS builder
|
2022-10-29 15:05:29 +00:00
|
|
|
WORKDIR /app
|
2022-10-29 15:09:03 +00:00
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
2022-10-29 15:05:29 +00:00
|
|
|
COPY . .
|
2022-10-26 11:28:48 +00:00
|
|
|
ENV NEXT_TELEMETRY_DISABLED 1
|
2023-10-15 03:07:36 +00:00
|
|
|
RUN pnpm build
|
2022-10-26 11:15:56 +00:00
|
|
|
|
2023-10-15 03:07:36 +00:00
|
|
|
# Run the app
|
|
|
|
FROM base AS runner
|
2022-10-26 11:15:56 +00:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
ENV NODE_ENV production
|
2022-10-26 12:02:09 +00:00
|
|
|
ENV NEXT_TELEMETRY_DISABLED 1
|
2022-10-26 11:15:56 +00:00
|
|
|
|
2023-10-15 03:07:36 +00:00
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
|
|
RUN adduser --system --uid 1001 nextjs
|
2022-10-26 11:15:56 +00:00
|
|
|
|
2023-10-15 03:07:36 +00:00
|
|
|
RUN mkdir .next
|
|
|
|
RUN chown nextjs:nodejs .next
|
2022-10-26 11:15:56 +00:00
|
|
|
|
2023-10-15 03:07:36 +00:00
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json
|
2022-10-26 11:15:56 +00:00
|
|
|
|
2023-10-15 02:59:34 +00:00
|
|
|
RUN pnpm i -g @beam-australia/react-env
|
2022-10-29 15:13:45 +00:00
|
|
|
|
2022-10-26 11:15:56 +00:00
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
2023-10-15 03:07:36 +00:00
|
|
|
ENV HOSTNAME "0.0.0.0"
|
2022-10-26 11:15:56 +00:00
|
|
|
ENV PORT 3000
|
2023-10-15 03:07:36 +00:00
|
|
|
CMD npx react-env --env APP_ENV && pnpm start
|