mirror of
https://github.com/coollabsio/coolify-examples.git
synced 2026-02-18 21:38:58 +00:00
Create Dockerfile.next
This commit is contained in:
84
dockerfile/Dockerfile.next
Normal file
84
dockerfile/Dockerfile.next
Normal file
@@ -0,0 +1,84 @@
|
||||
FROM node:20 AS nodeenv
|
||||
|
||||
ENV PNPM_HOME="/pnpm"
|
||||
ENV PATH="$PNPM_HOME:$PATH"
|
||||
|
||||
ENV BROWSERLESS_URL=$BROWSERLESS_URL
|
||||
ENV DATABASE_URL=$DATABASE_URL
|
||||
ENV GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID
|
||||
ENV GOOGLE_CLIENT_SECRET=$GOOGLE_CLIENT_SECRET
|
||||
ENV MAGIC_SK=$MAGIC_SK
|
||||
ENV NEXT_PUBLIC_MAGIC_PK=$NEXT_PUBLIC_MAGIC_PK
|
||||
ENV NEXT_PUBLIC_UMAMI_SCRIPT_URL=$NEXT_PUBLIC_UMAMI_SCRIPT_URL
|
||||
ENV NEXT_PUBLIC_UMAMI_WEBSITE_ID=$NEXT_PUBLIC_UMAMI_WEBSITE_ID
|
||||
ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET
|
||||
ENV NEXTAUTH_URL=$NEXTAUTH_URL
|
||||
ENV REDIS_URL=$REDIS_URL
|
||||
ENV S3_UPLOAD_BUCKET=$S3_UPLOAD_BUCKET
|
||||
ENV S3_UPLOAD_KEY=$S3_UPLOAD_KEY
|
||||
ENV S3_UPLOAD_REGION=$S3_UPLOAD_REGION
|
||||
ENV S3_UPLOAD_SECRET=$S3_UPLOAD_SECRET
|
||||
ENV VERCEL_URL=$VERCEL_URL
|
||||
ENV WEBSNAP_URL=$WEBSNAP_URL
|
||||
ENV WIREIT_LOGGER="simple"
|
||||
|
||||
# Start with the official Node.js image.
|
||||
FROM nodeenv AS deps
|
||||
RUN corepack enable
|
||||
|
||||
# Set the working directory.
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json and pnpm-lock.yaml before other files
|
||||
# Utilise Docker cache to save re-installing dependencies if unchanged
|
||||
COPY package.json ./
|
||||
COPY pnpm-lock.yaml ./
|
||||
|
||||
# Install dependencies
|
||||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
|
||||
|
||||
# Build the Next.js app
|
||||
FROM nodeenv AS builder
|
||||
RUN corepack enable
|
||||
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy all files
|
||||
COPY . .
|
||||
|
||||
# Copy the previously installed dependencies
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
|
||||
# print the env variables
|
||||
# with a "ENVIRONMENT VARIABLES" title in a different color
|
||||
RUN echo -e "\e[1;33mENVIRONMENT VARIABLES\e[0m"
|
||||
RUN env
|
||||
|
||||
# Build the Next.js app
|
||||
ENV NODE_ENV production
|
||||
RUN pnpm run build:next
|
||||
|
||||
# Only copy over the Next.js pieces we need
|
||||
FROM nodeenv AS runner
|
||||
RUN corepack enable
|
||||
|
||||
ENV NODE_ENV production
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/.next/ ./.next/
|
||||
COPY --from=builder /app/node_modules/ ./node_modules/
|
||||
COPY --from=builder /app/prisma/ ./prisma/
|
||||
COPY --from=builder /app/public/ ./public/
|
||||
|
||||
COPY --from=builder /app/src/env.mjs ./src/env.mjs
|
||||
COPY --from=builder /app/next.config.mjs ./next.config.mjs
|
||||
COPY --from=builder /app/package.json ./package.json
|
||||
|
||||
# Expose the listening port
|
||||
EXPOSE 3000
|
||||
ENV PORT 3000
|
||||
|
||||
# Run pnpm start to launch the app
|
||||
CMD ["pnpm", "start:next"]
|
||||
Reference in New Issue
Block a user