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.development
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
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