refactor: use bun in Dockerfile and CI workflow

This commit is contained in:
Justin Lin committed 2026-10-11 17:24:12 +11:00
1 parent 77577d9b8d
commit 634dc8f987
16 files changed
+99 -71

No files matched your search

+1
View File
@@ -3,3 +3,4 @@
**/dist
**/tsconfig.tsbuildinfo
data
postgres-data
+12 -4
View File
@@ -11,18 +11,26 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14
# Jest still runs on Node until tests move to `bun test`
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Install dependencies
run: yarn install
run: bun install --frozen-lockfile
- name: Type check
run: bun run type-check
- name: Build
run: yarn build
run: bun run build
- name: Lint
run: yarn lint
run: bun run lint
- name: Test
run: yarn test
run: bun run test
+1 -1
View File
@@ -14,7 +14,7 @@ jobs:
run: docker-compose -f docker-compose.testing.yml build base backend app-test cypress
- name: Build Test Quests
run: docker-compose -f docker-compose.testing.yml run --rm backend yarn build:quests
run: docker-compose -f docker-compose.testing.yml run --rm backend bun run build:quests
- name: Run Cypress Tests
env:
+4 -4
View File
@@ -4,10 +4,10 @@
{
"type": "node",
"request": "launch",
"name": "File Graph Yarn Jest",
"runtimeExecutable": "yarn",
"args": ["test", "--runInBand"],
"cwd": "${workspaceFolder}/packages/file-graph",
"name": "File Graph Jest",
"runtimeExecutable": "bun",
"args": ["run", "test", "packages/file-graph", "--runInBand"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
+11 -12
View File
@@ -5,16 +5,15 @@
## TLDR
yarn install
bun install
cp .env.sample .env
docker compose up -d
yarn dev
bun run dev
## Requirements
- NodeJS v20+
- Bun: v1.3+
- Docker
- Yarn: v1.22
## Known Issues
@@ -26,7 +25,7 @@ Windows user please refer to [docs/windows-setup.md](docs/windows-setup.md) for
git clone https://github.com/lancatlin/linux-odyssey.git
cd linux-odyssey
yarn install
bun install
## Project Structures
@@ -104,7 +103,7 @@ Customized `entrypoint.sh` for each quest is not yet supported.
To build all quests:
yarn build:quests
bun run build:quests
The base image is built with docker-compose, so you can use `docker compose build base` to rebuild it. Once you rebuild the base image, you have to rebuild all quests.
@@ -134,11 +133,11 @@ Copy `.env.sample` to `.env` and customize it for your needs.
Run dev server (frontend, backend):
yarn dev
bun run dev
To develop analytics dashboard:
yarn analytics
bun run analytics
The default username and password is `alex` and `Alex1234`.
@@ -146,12 +145,12 @@ The default username and password is `alex` and `Alex1234`.
Unit tests:
yarn test:unit
bun run test
Run Cypress locally, using the current development containers:
docker compose up -d
yarn test:e2e
bun run test:e2e
Run Cypress in container, create brand-new containers along with it:
@@ -183,7 +182,7 @@ Start the service
# Server side
docker compose -f docker-compose.prod.yml pull
yarn build:quests
bun run build:quests
docker compose -f docker-compose.prod.yml up -d
### Necessary Configuration
@@ -197,4 +196,4 @@ You can copy from `.env.sample`
You can generate a random key by running
yarn setup
bun run setup
+11 -4
View File
@@ -1,17 +1,24 @@
# Base stage
FROM node:20-alpine AS build
FROM oven/bun:1.3.14-alpine AS build
WORKDIR /app
COPY package.json yarn.lock ./
COPY package.json bun.lock ./
COPY app/package.json ./app/package.json
COPY server/package.json ./server/package.json
RUN yarn install --frozen-lockfile
COPY services/analytics/package.json ./services/analytics/package.json
COPY tests/package.json ./tests/package.json
COPY packages/constants/package.json ./packages/constants/package.json
COPY packages/file-graph/package.json ./packages/file-graph/package.json
COPY packages/game/package.json ./packages/game/package.json
COPY packages/models/package.json ./packages/models/package.json
COPY packages/utils/package.json ./packages/utils/package.json
RUN bun install --frozen-lockfile --filter app
COPY tsconfig.json ./tsconfig.json
COPY server ./server
COPY packages ./packages
COPY app ./app
RUN yarn workspace app build
RUN bun run --filter app build
# Production stage
FROM nginx:stable-alpine AS prod
+1
View File
@@ -102,6 +102,7 @@
"name": "@odyssey/models",
"version": "0.0.0",
"dependencies": {
"@odyssey/constants": "workspace:*",
"mongoose": "^8.24.1",
},
},
+10 -9
View File
@@ -81,22 +81,23 @@ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
```
### Install Yarn 1.22
### Install Bun
```bash
sudo npm install -g yarn@1.22.22
curl -fsSL https://bun.sh/install | bash
```
Restart your terminal (or run `source ~/.bashrc`) so `bun` is on your `PATH`.
Verify the installations:
```bash
git --version
node --version
npm --version
yarn --version
bun --version
```
The Node.js version should be `20.x` or later, and the Yarn version should be `1.22.x`.
The Node.js version should be `20.x` or later, and the Bun version should be `1.3` or later.
## 4. Clone the Project
@@ -130,10 +131,10 @@ code .
From the project root, run:
```bash
yarn install
bun install
```
Warnings during installation may be harmless. The installation succeeded if Yarn finishes with a `Done` message and does not display `error Command failed`.
Warnings during installation may be harmless. The installation succeeded if Bun finishes with an `installed` message and does not display an `error:` message.
If a `gyp` error appears, confirm that it belongs to an optional dependency before ignoring it.
@@ -180,7 +181,7 @@ docker compose down
Start the frontend and backend development servers:
```bash
yarn dev
bun run dev
```
Keep the terminal running and open the following address in your browser:
@@ -194,5 +195,5 @@ To stop the development servers, press `Ctrl+C`.
You can verify that the project builds successfully by running:
```bash
yarn build
bun run build
```
+1 -1
View File
@@ -1,4 +1,4 @@
import { FileGraph, IFileNode } from '../file-graph'
import { FileGraph, IFileNode } from '@odyssey/file-graph'
import { Quest } from './Quest'
import {
IQuest,
+1
View File
@@ -8,6 +8,7 @@
".": "./index.ts"
},
"dependencies": {
"@odyssey/constants": "workspace:*",
"mongoose": "^8.24.1"
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
import { model, Schema, Types } from 'mongoose'
import type { QuestLocale } from '../constants'
import { SUPPORTED_LOCALES } from '../constants'
import type { QuestLocale } from '@odyssey/constants'
import { SUPPORTED_LOCALES } from '@odyssey/constants'
export interface INode {
path: string
+16 -15
View File
@@ -1,27 +1,28 @@
FROM node:20-alpine AS build
FROM oven/bun:1.3.14-alpine AS prod
WORKDIR /app
COPY ./package.json yarn.lock ./
COPY package.json bun.lock ./
COPY app/package.json ./app/package.json
COPY server/package.json ./server/package.json
RUN yarn install
COPY services/analytics/package.json ./services/analytics/package.json
COPY tests/package.json ./tests/package.json
COPY packages/constants/package.json ./packages/constants/package.json
COPY packages/file-graph/package.json ./packages/file-graph/package.json
COPY packages/game/package.json ./packages/game/package.json
COPY packages/models/package.json ./packages/models/package.json
COPY packages/utils/package.json ./packages/utils/package.json
RUN bun install --frozen-lockfile --production --filter server
# Install docker cli
COPY server ./server
COPY packages ./packages
COPY tsconfig.json ./tsconfig.json
RUN yarn workspace server build
# Production
FROM node:20-alpine AS prod
WORKDIR /app
COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/server ./server
COPY tsconfig.json ./tsconfig.json
COPY packages ./packages
COPY server ./server
COPY ./quests ./quests
ENV NODE_ENV=production
WORKDIR /app/server
CMD [ "yarn", "start" ]
CMD [ "bun", "src/index.ts" ]
ENV HOST=0.0.0.0
ENV PORT=3000
+1 -1
View File
@@ -24,7 +24,7 @@ import { createContext } from './trpc.js'
async function main() {
if (!config.secret) {
logger.error(
'No SECRET_KEY found in .env! To set up a persistent key, please run `yarn setup`:'
'No SECRET_KEY found in .env! To set up a persistent key, please run `bun run setup`:'
)
process.exit(1)
}
+12 -13
View File
@@ -1,27 +1,26 @@
FROM node:20-alpine AS build
FROM oven/bun:1.3.14-alpine AS prod
WORKDIR /app
COPY ./package.json yarn.lock ./
COPY package.json bun.lock ./
COPY app/package.json ./app/package.json
COPY server/package.json ./server/package.json
COPY services/analytics/package.json ./services/analytics/package.json
RUN yarn install --frozen-lockfile
COPY tests/package.json ./tests/package.json
COPY packages/constants/package.json ./packages/constants/package.json
COPY packages/file-graph/package.json ./packages/file-graph/package.json
COPY packages/game/package.json ./packages/game/package.json
COPY packages/models/package.json ./packages/models/package.json
COPY packages/utils/package.json ./packages/utils/package.json
RUN bun install --frozen-lockfile --production --filter analytics
COPY tsconfig.json ./tsconfig.json
COPY packages ./packages
COPY services/analytics ./services/analytics
RUN yarn workspace analytics build
# Production stage
FROM node:20-alpine AS prod
WORKDIR /app
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/services/analytics ./services/analytics
ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=3001
EXPOSE 3001
WORKDIR /app/services/analytics
CMD [ "yarn", "start" ]
CMD [ "bun", "src/index.ts" ]
+13 -3
View File
@@ -1,12 +1,22 @@
FROM cypress/browsers
COPY --from=oven/bun:1.3.14 /usr/local/bin/bun /usr/local/bin/bun
WORKDIR /e2e
COPY package.json yarn.lock ./
COPY package.json bun.lock ./
COPY app/package.json ./app/package.json
COPY server/package.json ./server/package.json
COPY services/analytics/package.json ./services/analytics/package.json
COPY tests/package.json ./tests/package.json
RUN yarn install --frozen-lockfile
COPY packages/constants/package.json ./packages/constants/package.json
COPY packages/file-graph/package.json ./packages/file-graph/package.json
COPY packages/game/package.json ./packages/game/package.json
COPY packages/models/package.json ./packages/models/package.json
COPY packages/utils/package.json ./packages/utils/package.json
RUN bun install --frozen-lockfile
COPY quests ./quests
COPY tests ./tests
WORKDIR /e2e/tests
CMD [ "yarn", "test" ]
CMD [ "bun", "run", "test" ]
+2 -2
View File
@@ -6,8 +6,8 @@
"type": "commonjs",
"license": "MIT",
"scripts": {
"test": "yarn cypress run",
"test:open": "yarn cypress open"
"test": "cypress run",
"test:open": "cypress open"
},
"dependencies": {
"@testing-library/cypress": "^10.0.1",