Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
50 lines
1.1 KiB
Docker
50 lines
1.1 KiB
Docker
# Multi-stage Dockerfile for Next.js frontend
|
|
# Stage 1: Install dependencies and build the application
|
|
FROM node:20-alpine AS builder
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json package-lock.json ./
|
|
COPY pnpm-lock.yaml ./
|
|
|
|
# Install pnpm and dependencies
|
|
RUN npm install -g pnpm
|
|
RUN pnpm install --no-frozen-lockfile
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN pnpm build
|
|
|
|
# Stage 2: Production image
|
|
FROM node:20-alpine AS runner
|
|
|
|
# Set environment variables
|
|
ENV NODE_ENV=production
|
|
|
|
# Create app directory
|
|
WORKDIR /app
|
|
|
|
# Create non-root user
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
# Copy built application from builder stage
|
|
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
|
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 port
|
|
EXPOSE 3001
|
|
|
|
# Set environment variable for port
|
|
ENV PORT=3001
|
|
|
|
# Start the application
|
|
CMD ["node", "server.js"]
|