From 18f1ea59fd9e1521b2ed6e2306a200ee002309f3 Mon Sep 17 00:00:00 2001 From: TheMaddax Date: Sun, 14 Dec 2025 21:11:43 -0700 Subject: [PATCH] Update Dockerfile and .dockerignore for proper source build --- .dockerignore | 3 ++- Dockerfile | 26 ++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.dockerignore b/.dockerignore index e50c8dd..9ca0378 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,4 +4,5 @@ node_modules .env.local .env.development external-code/ - +public/images/mark-old-2024.jpg +public/images/mark-old.jpg diff --git a/Dockerfile b/Dockerfile index 02c6ee1..7b63c9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,30 +6,36 @@ RUN corepack enable && corepack prepare pnpm@latest --activate # Set working directory WORKDIR /app +FROM base AS deps # Copy package files COPY package.json pnpm-lock.yaml* ./ - -FROM base AS deps RUN pnpm install --frozen-lockfile FROM base AS builder +# Copy node_modules from deps stage COPY --from=deps /app/node_modules ./node_modules + +# Copy all source files COPY . . -# Explicitly run PostCSS/Tailwind build before Next.js build -RUN pnpm dlx tailwindcss -i ./src/styles/globals.css -o ./src/styles/output.css +# Build the Next.js application RUN pnpm build FROM base AS runner ENV NODE_ENV=production ENV PORT=805 -ENV HOSTNAME "0.0.0.0" +ENV HOSTNAME="0.0.0.0" -# Copy necessary files -COPY --from=builder /app/public ./public -COPY --from=builder /app/.next/standalone ./ -COPY --from=builder /app/.next/static ./.next/static -COPY --from=builder /app/src/styles/output.css ./src/styles/output.css +# Create non-root user +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +# 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