test new file
Some checks failed
Main / build-and-push-docker-image (20.x) (push) Failing after 3m23s
Some checks failed
Main / build-and-push-docker-image (20.x) (push) Failing after 3m23s
This commit is contained in:
36
Dockerfile
36
Dockerfile
@@ -1,28 +1,30 @@
|
|||||||
FROM node:lts-slim AS base
|
# 1. Install dependencies and build the project
|
||||||
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
# Create app directory
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Enable Corepack
|
|
||||||
RUN corepack enable
|
|
||||||
|
|
||||||
# Set Yarn to the latest stable version
|
|
||||||
RUN yarn set version stable
|
|
||||||
|
|
||||||
# Files required by yarn install
|
|
||||||
COPY package.json yarn.lock ./
|
COPY package.json yarn.lock ./
|
||||||
|
|
||||||
# Install app dependencies
|
|
||||||
RUN yarn install --immutable
|
RUN yarn install --immutable
|
||||||
|
|
||||||
# Type check app
|
COPY . .
|
||||||
# RUN yarn typecheck
|
|
||||||
|
|
||||||
# Build app
|
# Next.js standalone output copies only necessary files
|
||||||
RUN yarn build
|
RUN yarn build
|
||||||
|
ENV NEXT_TELEMETRY_DISABLED 1
|
||||||
|
|
||||||
USER node
|
# 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
|
||||||
|
|
||||||
# Start the app
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
CMD ["yarn", "start"]
|
|
||||||
|
CMD ["node", "server.js"]
|
||||||
|
|||||||
Reference in New Issue
Block a user