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