Update Dockerfile and .dockerignore for proper source build

This commit is contained in:
TheMaddax 2025-12-14 21:11:43 -07:00
parent 5e0b3c3d29
commit 18f1ea59fd
2 changed files with 18 additions and 11 deletions

View file

@ -4,4 +4,5 @@ node_modules
.env.local .env.local
.env.development .env.development
external-code/ external-code/
public/images/mark-old-2024.jpg
public/images/mark-old.jpg

View file

@ -6,30 +6,36 @@ RUN corepack enable && corepack prepare pnpm@latest --activate
# Set working directory # Set working directory
WORKDIR /app WORKDIR /app
FROM base AS deps
# Copy package files # Copy package files
COPY package.json pnpm-lock.yaml* ./ COPY package.json pnpm-lock.yaml* ./
FROM base AS deps
RUN pnpm install --frozen-lockfile RUN pnpm install --frozen-lockfile
FROM base AS builder FROM base AS builder
# Copy node_modules from deps stage
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
# Copy all source files
COPY . . COPY . .
# Explicitly run PostCSS/Tailwind build before Next.js build # Build the Next.js application
RUN pnpm dlx tailwindcss -i ./src/styles/globals.css -o ./src/styles/output.css
RUN pnpm build RUN pnpm build
FROM base AS runner FROM base AS runner
ENV NODE_ENV=production ENV NODE_ENV=production
ENV PORT=805 ENV PORT=805
ENV HOSTNAME "0.0.0.0" ENV HOSTNAME="0.0.0.0"
# Copy necessary files # Create non-root user
COPY --from=builder /app/public ./public RUN addgroup --system --gid 1001 nodejs
COPY --from=builder /app/.next/standalone ./ RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/src/styles/output.css ./src/styles/output.css # Copy necessary files from builder
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
USER nextjs
EXPOSE 805 EXPOSE 805