77
Some checks failed
Publish / docker (push) Failing after 1m57s

This commit is contained in:
Lee 2023-10-15 04:07:36 +01:00
parent a504051d7f
commit acc107baff

@ -1,56 +1,42 @@
FROM fascinated/docker-images:node-pnpm-latest as main FROM fascinated/docker-images:node-pnpm-latest AS base
# Install dependencies only when needed # Install depends
FROM main AS deps 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
#RUN apk add libc6-compat
WORKDIR /app WORKDIR /app
COPY package.json* pnpm-lock.yaml* ./
RUN pnpm install --production --frozen-lockfile --quiet
# Install dependencies based on the preferred package manager # Build from source
COPY package.json pnpm-lock.yaml* ./ FROM base AS builder
# Install node modules
RUN pnpm install --production
# Rebuild the source code only when needed
FROM main AS builder
WORKDIR /app WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
ENV NEXT_TELEMETRY_DISABLED 1 ENV NEXT_TELEMETRY_DISABLED 1
RUN pnpm build
# Build the project # Run the app
RUN pnpm build FROM base AS runner
# Production image, copy all the files and run next
FROM main AS runner
WORKDIR /app WORKDIR /app
ENV NODE_ENV production ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1 ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup -g 1001 -S nodejs RUN addgroup --system --gid 1001 nodejs
RUN adduser -S nextjs -u 1001 RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public RUN mkdir .next
RUN chown nextjs:nodejs .next
# Automatically leverage output traces to reduce image size COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
# https://nextjs.org/docs/advanced-features/output-file-tracing COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
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/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/public ./.next/static
RUN pnpm setup
RUN pnpm i -g @beam-australia/react-env RUN pnpm i -g @beam-australia/react-env
RUN chown -R nextjs:nodejs /app
USER nextjs USER nextjs
EXPOSE 3000 EXPOSE 3000
ENV HOSTNAME "0.0.0.0"
ENV PORT 3000 ENV PORT 3000
CMD npx react-env --env APP_ENV && pnpm start
CMD npx react-env --env APP_ENV && yarn start