Some checks failed
Main / build-and-push-docker-image (20.x) (push) Failing after 3m12s
35 lines
816 B
Docker
35 lines
816 B
Docker
# 1. Install dependencies and build the project
|
|
FROM ubuntu:latest AS builder
|
|
|
|
|
|
# Set Yarn to the latest stable version
|
|
RUN apt-get update && apt-get install -y nodejs yarn
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json yarn.lock ./
|
|
RUN yarn install --immutable
|
|
|
|
COPY . .
|
|
|
|
# Next.js standalone output copies only necessary files
|
|
RUN yarn build
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# 2. Production stage: use a minimal base image
|
|
FROM node:20-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
# Set the environment variable for standalone output directory
|
|
ENV NODE_ENV=production
|
|
# Next.js will copy the standalone files to /app/standalone/.next
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
|
|
EXPOSE 3000
|
|
|
|
CMD ["node", "server.js"]
|