Spaces:
Build error
Build error
File size: 2,510 Bytes
09fa60b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | # ============================================
# AudioForge Frontend - Production Dockerfile
# ============================================
# Multi-stage build with optimized caching
# Production-ready Next.js deployment
FROM node:20-alpine AS base
# Install security updates
RUN apk upgrade --no-cache && \
apk add --no-cache libc6-compat curl
# ============================================
# Dependencies Stage
# ============================================
FROM base AS deps
WORKDIR /app
# Enable pnpm
RUN corepack enable && corepack prepare pnpm@9.1.0 --activate
# Copy dependency files
COPY package.json pnpm-lock.yaml* ./
# Install dependencies (allow lockfile update for flexibility)
RUN pnpm install --no-frozen-lockfile --prod=false
# ============================================
# Builder Stage
# ============================================
FROM base AS builder
WORKDIR /app
# Copy dependency files first for better caching
COPY package.json package-lock.json* ./
# Install ALL dependencies
RUN npm install
# Copy source code
COPY . .
# Remove test files and vitest config to avoid build conflicts
RUN rm -rf src/**/*.test.ts src/**/*.test.tsx src/test vitest.config.ts
# Set build environment variables
ENV NEXT_TELEMETRY_DISABLED=1 \
NODE_ENV=production
# Build application
RUN npm run build
# ============================================
# Production Runner Stage
# ============================================
FROM base AS runner
WORKDIR /app
# Set production environment
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1 \
PORT=3000 \
HOSTNAME="0.0.0.0"
# Create system user for security
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
# Copy built application
COPY --from=builder /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
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:3000/ || exit 1
# Expose port
EXPOSE 3000
# Labels for metadata
LABEL maintainer="AudioForge Team" \
version="1.0.0" \
description="AudioForge Frontend - Production Ready" \
org.opencontainers.image.source="https://github.com/audioforge/audioforge"
# Start application
CMD ["node", "server.js"]
|