Skip to content

Commit 8f165d9

Browse files
committed
bun: run
1 parent 93f832c commit 8f165d9

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

bun.Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
FROM oven/bun AS setup
22
WORKDIR /bun-dir
33
COPY . .
4-
RUN bun build ./src/server-node.js --target node --outdir ./dist --entry-naming bun.mjs --format esm
5-
RUN export BLOCKLIST_DOWNLOAD_ONLY=true && node ./dist/bun.mjs
4+
RUN bun install
5+
# flybun --packages=external to ask bun to not resolve @riaskov/mmap-io (which brings in mapbox among other deps)
6+
RUN npm run build:flybun
7+
RUN export BLOCKLIST_DOWNLOAD_ONLY=true && bun run ./dist/bun.mjs --smol
68

79
FROM oven/bun:alpine AS runner
810
# env vals persist even at run-time: archive.is/QpXp2
@@ -12,7 +14,8 @@ WORKDIR /app
1214
COPY --from=setup /bun-dir/dist ./
1315
COPY --from=setup /bun-dir/blocklists__ ./blocklists__
1416
COPY --from=setup /bun-dir/dbip__ ./dbip__
17+
# @riaskov/mmap-io native is unused in bun as it has built-in mmap support
1518
# print files in work dir, must contain blocklists
1619
RUN ls -Fla
1720
# run with the default entrypoint (usually, bash or sh)
18-
CMD ["bun", "run", "./bun.mjs"]
21+
CMD ["bun", "run", "./bun.mjs", "--smol"]

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"build": "npx webpack --config webpack.config.cjs",
1616
"build:fastly": "npx webpack --config webpack.fastly.cjs && npm run fastly:wasm",
1717
"build:fly": "npx webpack --config webpack.fly.cjs",
18+
"build:flybun": "bun build ./src/server-node.js --production --target node --outdir ./dist --entry-naming bun.mjs --format esm --packages=external",
1819
"fastly:wasm": "npx js-compute-runtime ./dist/fastly.js ./dist/fastly.wasm"
1920
},
2021
"repository": {

run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fi
101101
if [ $runtime = "bun" ] || [ $runtime = "b" ]; then
102102
echo "note: bun v1+ required";
103103
echo "using `which bun`";
104-
start="bun run src/server-node.js";
104+
start="bun run src/server-node.js --smol";
105105
elif [ $runtime = "deno" ] || [ $runtime = "d" ]; then
106106
echo "note: deno v2+ required";
107107
echo "using `which deno`";

0 commit comments

Comments
 (0)