feat: migrate from npm to bun and fix analytics map height

Switch package manager and runtime from Node.js/npm to Bun across
Docker, CI, and scripts. The SQLite driver remains better-sqlite3
due to Next.js Turbopack being unable to resolve bun:sqlite during
build-time page pre-rendering.

Also fix the world map not rendering in the analytics page — the
overflowX wrapper added for mobile broke the flex height chain,
collapsing the map to 0px.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
fuomag9
2026-03-21 01:48:21 +01:00
parent 4b5323a7bf
commit b5625e5a96
10 changed files with 1115 additions and 7946 deletions

View File

@@ -3,6 +3,7 @@ node_modules
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
package-lock.json
# Build outputs # Build outputs
.next .next

View File

@@ -22,14 +22,13 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v6 uses: actions/checkout@v6
- name: Set up Node.js - name: Set up Bun
uses: actions/setup-node@v6 uses: oven-sh/setup-bun@v2
with: with:
node-version: '22' bun-version: latest
cache: 'npm'
- name: Install dependencies - name: Install dependencies
run: npm ci run: bun install --frozen-lockfile
- name: Run unit and integration tests - name: Run unit and integration tests
run: npm test run: bun run test

View File

@@ -509,10 +509,8 @@ export default function AnalyticsClient() {
<Typography variant="subtitle1" fontWeight={600} sx={{ mb: 1 }}> <Typography variant="subtitle1" fontWeight={600} sx={{ mb: 1 }}>
Traffic by Country Traffic by Country
</Typography> </Typography>
<Box sx={{ flex: 1, minHeight: 0 }}> <Box sx={{ flex: 1, minHeight: 280 }}>
<Box sx={{ overflowX: "auto", width: "100%" }}> <WorldMap data={countries} selectedCountry={selectedCountry} />
<WorldMap data={countries} selectedCountry={selectedCountry} />
</Box>
</Box> </Box>
</CardContent> </CardContent>
</Card> </Card>

1096
bun.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -65,7 +65,7 @@ services:
networks: networks:
- caddy-network - caddy-network
healthcheck: healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/api/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))"] test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/api/health"]
interval: 30s interval: 30s
timeout: 10s timeout: 10s
retries: 3 retries: 3

View File

@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1.6 # syntax=docker/dockerfile:1.6
FROM node:25-slim AS base FROM oven/bun:1-slim AS base
WORKDIR /app WORKDIR /app
FROM base AS deps FROM base AS deps
@@ -12,9 +12,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
openssl \ openssl \
ca-certificates \ ca-certificates \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json* ./ COPY package.json bun.lock ./
# Install dependencies RUN bun install --frozen-lockfile
RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
FROM base AS builder FROM base AS builder
ENV NODE_ENV=production ENV NODE_ENV=production
@@ -25,7 +24,7 @@ ENV DATABASE_URL=file:/tmp/build.db
COPY --from=deps /app/node_modules ./node_modules COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
# Build the Next.js application # Build the Next.js application
RUN npm run build && rm -f /tmp/build.db RUN bun run build && rm -f /tmp/build.db
FROM base AS runner FROM base AS runner
# Accept build args for user/group IDs to support rootless operation # Accept build args for user/group IDs to support rootless operation

View File

@@ -8,4 +8,4 @@ echo "Ensuring database directory exists..."
mkdir -p "$DB_DIR" mkdir -p "$DB_DIR"
echo "Starting application..." echo "Starting application..."
exec env HOSTNAME=0.0.0.0 node server.js exec env HOSTNAME=0.0.0.0 bun server.js

7925
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -44,6 +44,7 @@
"topojson-client": "^3.1.0" "topojson-client": "^3.1.0"
}, },
"devDependencies": { "devDependencies": {
"@types/bun": "latest",
"@eslint/js": "^10.0.1", "@eslint/js": "^10.0.1",
"@next/eslint-plugin-next": "^16.1.7", "@next/eslint-plugin-next": "^16.1.7",
"@playwright/test": "^1.58.2", "@playwright/test": "^1.58.2",

View File

@@ -20,16 +20,16 @@ typecheck_status=0
vitest_status=0 vitest_status=0
e2e_status=0 e2e_status=0
run_step "Lint" npm run lint run_step "Lint" bun run lint
lint_status=$? lint_status=$?
run_step "Typecheck" npm run typecheck run_step "Typecheck" bun run typecheck
typecheck_status=$? typecheck_status=$?
run_step "Vitest" npm run test run_step "Vitest" bun run test
vitest_status=$? vitest_status=$?
run_step "Playwright" npm run test:e2e run_step "Playwright" bun run test:e2e
e2e_status=$? e2e_status=$?
printf '\n==> Summary\n' printf '\n==> Summary\n'