Post

Bun CLI via Docker

Similarly to how AWS CDK CLI is used with Docker, we can run Bun too:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#.PHONY: bun
bun:
	docker pull oven/bun
	export sh='#!/usr/bin/env bash\n' \
	  && echo $${sh}'docker run --rm -it --init -v "$$(pwd):/home/bun/app" \\' > bun_run \
	  && echo ' --env-file <(env | grep AWS_) -p 3000:3000 oven/bun "$$@"' >> bun_run \
	  && echo $${sh}'"$${BASH_SOURCE[0]}_run" bun "$$@"' > bun
	chmod +x bun bun_run

/usr/local/bin/bun: bun
	ln -sf "$$(pwd)/bun_run" /usr/local/bin/
	ln -sf "$$(pwd)/bun" /usr/local/bin/
	ls -l /usr/local/bin/bun*

setup: /usr/local/bin/bun

# The following targets are here just for easy one-click running in PyCharm:
bash: setup
	bun_run bash
version: setup
	bun -v
This post is licensed under CC BY 4.0 by the author.