Skip to content

Commit 84a3dd7

Browse files
Transfer to Bun (#38)
* bun * should always be fast * bun in docker * change test -> vitest since bun has its own test lib * trailing comma --------- Co-authored-by: Adeeb Shihadeh <[email protected]>
1 parent e799701 commit 84a3dd7

File tree

8 files changed

+21
-4116
lines changed

8 files changed

+21
-4116
lines changed

.github/actions/setup-pnpm/action.yaml

-35
This file was deleted.

.github/workflows/deploy.yml

+4-20
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Deploy to Pages
22

33
on:
44
push:
5-
branches: ["master"]
65
workflow_dispatch:
76

87
permissions:
@@ -22,31 +21,15 @@ jobs:
2221
steps:
2322
- name: Checkout
2423
uses: actions/checkout@v4
25-
- name: Install pnpm
26-
uses: pnpm/[email protected]
27-
- name: Setup Node
28-
uses: actions/setup-node@v4
29-
with:
30-
node-version: "20"
31-
cache: "pnpm"
24+
- uses: oven-sh/setup-bun@v1
3225
- name: Setup Pages
3326
uses: actions/configure-pages@v4
3427
with:
3528
static_site_generator: next
36-
- name: Restore cache
37-
uses: actions/cache@v4
38-
with:
39-
path: |
40-
.next/cache
41-
# Generate a new cache whenever packages or source files change.
42-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
43-
# If source files changed but packages didn't, rebuild from a prior cache.
44-
restore-keys: |
45-
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
4629
- name: Install dependencies
47-
run: pnpm install
30+
run: bun install
4831
- name: Build with Next.js
49-
run: pnpm run build
32+
run: bun run build
5033
- name: Upload artifact
5134
uses: actions/upload-pages-artifact@v3
5235
with:
@@ -57,6 +40,7 @@ jobs:
5740
name: github-pages
5841
url: ${{ steps.deployment.outputs.page_url }}
5942
runs-on: ubuntu-latest
43+
if: github.ref == 'refs/heads/master'
6044
needs: build
6145
steps:
6246
- name: Deploy to GitHub Pages

.github/workflows/main.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
runs-on: ubuntu-latest
1616
timeout-minutes: 9
1717
steps:
18-
- uses: actions/checkout@v3
19-
- uses: ./.github/actions/setup-pnpm
18+
- uses: actions/checkout@v4
19+
- uses: oven-sh/setup-bun@v1
2020

21-
- run: pnpm install
22-
- run: pnpm lint
23-
- run: pnpm test
21+
- run: bun install
22+
- run: bun lint
23+
- run: bun vitest

Dockerfile

+8-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
FROM node:18-alpine AS base
1+
FROM oven/bun:1 AS base
22

33
# Install dependencies only when needed
44
FROM base AS deps
5-
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
6-
RUN apk add --no-cache libc6-compat
75
WORKDIR /app
86

97
# Install dependencies based on the preferred package manager
10-
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
8+
COPY package.json bun.lockb ./
119
RUN \
12-
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
13-
elif [ -f package-lock.json ]; then npm ci; \
14-
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
10+
if [ -f bun.lockb ]; then bun install --frozen-lockfile; \
1511
else echo "Lockfile not found." && exit 1; \
1612
fi
1713

@@ -26,30 +22,29 @@ ENV NEXT_TELEMETRY_DISABLED 1
2622
ARG NEXT_PUBLIC_GIT_SHA
2723
ENV NEXT_PUBLIC_GIT_SHA $NEXT_PUBLIC_GIT_SHA
2824

29-
RUN yarn build
25+
RUN bun run build
3026

3127

3228
# Production image, copy all the files and run next
3329
FROM base AS runner
3430
WORKDIR /app
3531

36-
ENV NODE_ENV production
3732
ENV NEXT_TELEMETRY_DISABLED 1
3833

39-
RUN addgroup --system --gid 1001 nodejs
34+
RUN addgroup --system --gid 1001 bunjs
4035
RUN adduser --system --uid 1001 nextjs
4136

4237
#COPY --from=builder /app/public ./public
4338

4439
# Automatically leverage output traces to reduce image size
4540
# https://nextjs.org/docs/advanced-features/output-file-tracing
46-
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
47-
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
41+
COPY --from=builder --chown=nextjs:bunjs /app/.next/standalone ./
42+
COPY --from=builder --chown=nextjs:bunjs /app/.next/static ./.next/static
4843

4944
USER nextjs
5045

5146
EXPOSE 3000
5247

5348
ENV PORT 3000
5449

55-
CMD ["node", "server.js"]
50+
CMD ["bun", "server.js"]

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ This tool allows you to flash AGNOS onto your comma device. Uses a fork of [fast
99
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
1010

1111
```bash
12-
pnpm install
13-
pnpm dev
12+
bun install
13+
bun dev
1414
```
1515

1616
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

bun.lockb

234 KB
Binary file not shown.

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
"dev": "next dev",
77
"build": "next build",
88
"start": "next start",
9-
"lint": "next lint",
10-
"test": "vitest"
9+
"lint": "next lint"
1110
},
12-
"packageManager": "[email protected]",
11+
"packageManager": "bun",
1312
"engines": {
1413
"node": ">=18.0.0"
1514
},

0 commit comments

Comments
 (0)