Skip to content

Commit 957d84a

Browse files
committed
fix: add bun in Dockerfile
Signed-off-by: ItsNeil17 <neil@willofsteel.me>
1 parent 5a4e7fe commit 957d84a

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# syntax=docker.io/docker/dockerfile:1
2-
32
FROM node:18-alpine AS base
43

54
# Install dependencies only when needed
@@ -9,19 +8,23 @@ RUN apk add --no-cache libc6-compat
98
WORKDIR /app
109

1110
# Install dependencies based on the preferred package manager
12-
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* source.config.ts next.config.* ./
11+
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* bun.lockb* .npmrc* source.config.ts next.config.* ./
1312
RUN \
14-
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
13+
if [ -f bun.lockb ]; then \
14+
apk add --no-cache curl unzip && \
15+
curl -fsSL https://bun.sh/install | bash && \
16+
/root/.bun/bin/bun install --frozen-lockfile; \
17+
elif [ -f yarn.lock ]; then yarn --frozen-lockfile; \
1518
elif [ -f package-lock.json ]; then npm ci; \
1619
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
1720
else echo "Lockfile not found." && exit 1; \
1821
fi
1922

20-
2123
# Rebuild the source code only when needed
2224
FROM base AS builder
2325
WORKDIR /app
2426
COPY --from=deps /app/node_modules ./node_modules
27+
COPY --from=deps /root/.bun /root/.bun
2528
COPY . .
2629

2730
# Next.js collects completely anonymous telemetry data about general usage.
@@ -30,7 +33,8 @@ COPY . .
3033
# ENV NEXT_TELEMETRY_DISABLED=1
3134

3235
RUN \
33-
if [ -f yarn.lock ]; then yarn run build; \
36+
if [ -f bun.lockb ]; then /root/.bun/bin/bun run build; \
37+
elif [ -f yarn.lock ]; then yarn run build; \
3438
elif [ -f package-lock.json ]; then npm run build; \
3539
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
3640
else echo "Lockfile not found." && exit 1; \
@@ -57,7 +61,6 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
5761
USER nextjs
5862

5963
EXPOSE 8080
60-
6164
ENV PORT=8080
6265

6366
# server.js is created by next build from the standalone output

0 commit comments

Comments
 (0)