mirror of
https://github.com/M4X809/list-of-lp.git
synced 2025-12-25 19:12:48 +00:00
- Modified the Dockerfile to install dependencies with the `--production=false` flag, allowing for the inclusion of devDependencies during the build process.
53 lines
1,003 B
Docker
53 lines
1,003 B
Docker
# Use bun as the base image
|
|
FROM oven/bun:1 AS base
|
|
|
|
# Install dependencies only when needed
|
|
FROM base AS deps
|
|
WORKDIR /app
|
|
|
|
# Copy dependency files
|
|
COPY package.json ./
|
|
COPY bun.lock* ./
|
|
|
|
# Install dependencies including devDependencies
|
|
RUN bun install --production=false
|
|
|
|
# Build the application
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
|
|
# Copy dependencies from deps stage
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# Build Next.js application
|
|
RUN bun run build
|
|
|
|
# Production image
|
|
FROM base AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
# Create a non-root user
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
# Copy necessary files
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
|
|
# Set ownership to nextjs user
|
|
RUN chown -R nextjs:nodejs /app
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
# Start the application
|
|
CMD ["bun", "run", "start"]
|
|
|