Skip to content

Commit

Permalink
Switch to bun as a runner and package manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Haarhoff committed May 9, 2024
1 parent b59b7b5 commit 3952f70
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 14,329 deletions.
1 change: 1 addition & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[tools]
node = "18"
bun = "latest"
20 changes: 15 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
# BASE
FROM node:18-slim@sha256:cbfb3c9830932b7b1c2738abf47c66568fc7b06cf782d803e7ddff52b2fc835d as node
WORKDIR /app
COPY package*.json ./
COPY package.json ./

FROM oven/bun:1 as bun
WORKDIR /app
COPY package.json ./
COPY bun.lockb ./

# DEV
FROM bun as dev-deps
RUN bun install --frozen-lockfile

FROM node as dev
RUN npm ci
COPY --from=dev-deps /app/node_modules/ node_modules/
COPY ./tsconfig.json .
CMD [ "npx", "ts-node-dev", "--transpile-only", "--respawn", "./src/index.ts" ]

# PROD
FROM node as prod-npm
RUN npm ci --production
FROM bun as prod-deps
RUN bun install --frozen-lockfile --production

FROM dev as prod-build
COPY ./src src/
RUN npx tsc

FROM prod-npm as prod
FROM node as prod
COPY --from=prod-deps /app/node_modules node_modules/
COPY --from=prod-build /app/build/ build/
COPY ./src/static build/src/static/
RUN ls -l
CMD ["node", "build/src/index.js"]
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
check: test lint typecheck unused-exports

node_modules: package.json package-lock.json
npm install
bun install --frozen-lockfile
touch node_modules

dev:
Expand All @@ -14,28 +14,28 @@ populate-local-dev:
bash ./scripts/populate-local-dev.sh

fix: node_modules
npx gts fix
bun gts fix

prod:
docker-compose --file docker-compose.yaml up --build

test: node_modules
npx jest
bun jest

smoketest:
./smoketest.sh

lint: node_modules
npx gts lint --fix
bun gts lint --fix

unused-exports: node_modules
npx ts-unused-exports ./tsconfig.json
bun ts-unused-exports ./tsconfig.json

typecheck: node_modules
npx tsc --noEmit
bun tsc --noEmit

watch-typecheck: node_modules
npx tsc --noEmit --watch
bun tsc --noEmit --watch

clear-containers:
docker-compose --file docker-compose.yaml --file docker-compose.dev.yaml down
Expand Down
Binary file added bun.lockb
Binary file not shown.
Loading

0 comments on commit 3952f70

Please sign in to comment.