Skip to content

Commit

Permalink
Migrate to Bun
Browse files Browse the repository at this point in the history
  • Loading branch information
petervmeijgaard committed Feb 5, 2025
1 parent b2b5e3b commit 1f04eb3
Show file tree
Hide file tree
Showing 10 changed files with 1,081 additions and 5,135 deletions.
1 change: 1 addition & 0 deletions .bun-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.2.2
3 changes: 1 addition & 2 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"configMigration": true,
"extends": ["config:recommended"],
"labels": ["Dependencies"],
"rangeStrategy": "bump",
"postUpdateOptions": ["pnpmDedupe"]
"rangeStrategy": "bump"
}
28 changes: 10 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,17 @@ jobs:
with:
fetch-depth: 0

- name: ▫️ Setup pnpm
uses: pnpm/[email protected]

- name: ⎔ Setup node
uses: actions/[email protected]
- name: 🥟 Setup Bun
uses: oven-sh/[email protected]
with:
node-version-file: .nvmrc
cache: "pnpm"
bun-version-file: ".bun-version"

- name: 📥 Install dependencies
shell: bash
run: pnpm install --frozen-lockfile
run: bun install --frozen-lockfile

- name: 🔬 Lint
run: pnpm run lint
run: bun run lint

format:
name: 🎨 Prettier
Expand All @@ -45,18 +41,14 @@ jobs:
with:
fetch-depth: 0

- name: ▫️ Setup pnpm
uses: pnpm/[email protected]

- name: ⎔ Setup node
uses: actions/[email protected]
- name: 🥟 Setup Bun
uses: oven-sh/[email protected]
with:
node-version-file: .nvmrc
cache: "pnpm"
bun-version-file: ".bun-version"

- name: 📥 Install dependencies
shell: bash
run: pnpm install --frozen-lockfile
run: bun install --frozen-lockfile

- name: 🎨 Format
run: pnpm run format
run: bun run format
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env sh

pnpm lint-staged
bun lint-staged
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pnpm-lock.yaml
bun.lock
52 changes: 19 additions & 33 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,39 @@
# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=22.13.1
FROM node:${NODE_VERSION}-slim AS base
# Adjust BUN_VERSION as desired
ARG BUN_VERSION=1.2.2
FROM oven/bun:${BUN_VERSION} AS base

LABEL fly_launch_runtime="Vite"

# Vite app lives here
WORKDIR /app
WORKDIR /usr/src/app

# Set production environment
ENV NODE_ENV="production"

# Set pnpm environment
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
FROM base AS install

# Enable corepack
RUN npm uninstall -g yarn pnpm && \
npm install -g corepack
RUN mkdir -p /temp/dev
COPY package.json bun.lock /temp/dev/
RUN cd /temp/dev && \
bun install --frozen-lockfile

RUN mkdir -p /temp/prod
COPY package.json bun.lock /temp/prod/
RUN cd /temp/prod && \
bun install --frozen-lockfile --production

# Throw-away build stage to reduce size of final image
FROM base AS build
FROM base AS prerelease

# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3
COPY --from=install /temp/dev/node_modules node_modules

# Install node modules
COPY package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile --prod=false

# Copy application code
COPY . .

# Build application
RUN pnpm run build
ENV NODE_ENV="production"

# Remove development dependencies
RUN pnpm prune --prod
RUN bun run build


# Final stage for app image
FROM nginx
FROM nginx AS release

# Copy built application
COPY --from=build /app/dist /usr/share/nginx/html
COPY --from=prerelease /usr/src/app/dist /usr/share/nginx/html

# Start the server by default, this can be overwritten at runtime
EXPOSE 80
CMD [ "/usr/sbin/nginx", "-g", "daemon off;" ]
1,047 changes: 1,047 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,5 @@
"vite": "^6.0.11",
"vite-tsconfig-paths": "^5.1.4",
"typescript-eslint": "^8.23.0"
},
"engines": {
"node": ">=22.13.1"
},
"packageManager": "[email protected]"
}
}
Loading

0 comments on commit 1f04eb3

Please sign in to comment.