Switch to pnpm
All checks were successful
Build and Push Docker Image / docker (push) Successful in 2m22s

This commit is contained in:
Lukas Reichart
2024-12-30 00:08:07 +01:00
parent 74fb993478
commit 24283fe60d
5 changed files with 3562 additions and 5885 deletions

View File

@@ -1,35 +1,19 @@
# Step 1: Set the base image to Node.js
FROM node:18-alpine AS build
# Step 2: Set the working directory inside the container
FROM node:22-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app
# Step 3: Copy the package.json and package-lock.json (or yarn.lock) for dependency installation
COPY package.json package-lock.json ./
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
# Step 4: Install dependencies
RUN npm install
FROM base AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build
# Step 5: Copy the rest of the project files into the container
COPY . .
# Step 6: Build the Next.js app
RUN npm run build
# Step 7: Create the final image (production stage)
FROM node:18-alpine
# Set the working directory inside the container for production
WORKDIR /app
# Copy the necessary files from the build stage
COPY --from=build /app ./
# Step 8: Install production dependencies only (optional)
RUN npm install --production
# Step 9: Expose the default Next.js port
FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/.next /app/.next
EXPOSE 3000
# Step 10: Set the command to run the Next.js app
CMD ["npm", "start"]
CMD [ "pnpm", "start" ]