Skip to content

Instantly share code, notes, and snippets.

@uratmangun
Created October 9, 2024 03:02
Show Gist options
  • Save uratmangun/f151c63f99371978edc51b7e9312edb9 to your computer and use it in GitHub Desktop.
Save uratmangun/f151c63f99371978edc51b7e9312edb9 to your computer and use it in GitHub Desktop.
sharp nextjs docker
FROM oven/bun:alpine AS base
# Stage 1: Install dependencies
FROM base AS deps
WORKDIR /app
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile
# Stage 2: Build the application
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
RUN apk add --no-cache \
curl \
libstdc++ \
gcc \
g++ \
make \
python3 \
vips-dev \
build-base
COPY . .
RUN bun run build
# Stage 3: Production server
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
EXPOSE 3000
CMD ["bun", "run", "server.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment