Yup. I understand why its not set in the template. But with a tut specifically for a dockerfile deploy it would be good to know (ts/next noob here, c# dev for years but ts is just so incredilby flaky in so many ways, an too much different ways to solve stuff)
It's expected to set it manually, we don't know will you use docker or not.
with the default payload 3.0 beta website template the next.config.js is missing the output: 'standalone' for this to work
Thanks to
@783838279580909578for the tutorial above! Here's some additional help for anyone deploying on Coolify
Make sure to change your future server URL in the .env file. Otherwise, you won't be able to upload media.
pnpm run dev
Upload the Dockerfile to Coolify, start it, create a user, and enjoy!
Explanation:
This Dockerfile creates a multi-stage image for a Next.js application. It starts with a base Node.js image and installs dependencies. Then it builds the application and finally sets it up for a production environment.
Dockerfile:
# Base image with Node.js
FROM node:20-alpine AS base
# Install dependencies
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Copy package manager files and install dependencies
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
if [ -f pnpm-lock.yaml ]; then \
corepack enable pnpm && pnpm i --frozen-lockfile; \
else \
echo "Lockfile not found." && exit 1; \
fi
# Build the Next.js application
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED 1
RUN \
if [ -f pnpm-lock.yaml ]; then \
corepack enable pnpm && pnpm run build; \
else \
echo "Lockfile not found." && exit 1; \
fi
# Final stage: Set up the runtime environment
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
# Create and set the application user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy the built files from the builder stage
COPY --from=builder /app/public ./public
# Change ownership of the public directory to the application user
RUN chown -R nextjs:nodejs ./public
# Setup directories and permissions for runtime
RUN mkdir .next
RUN chown nextjs:nodejs .next
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# Switch to non-root user
USER nextjs
# Expose the port the app runs on
EXPOSE 3000
ENV PORT 3000
# Command to run the application
CMD HOSTNAME="0.0.0.0" node server.js
1️⃣
Install the Latest Beta Versionnpx create-payload-app@beta
# Install pnpm
npm install -g pnpm
# Install the latest TypeScript version
pnpm add -D typescript
pnpm install
Star
Discord
online
Get dedicated engineering support directly from the Payload team.