@@ -19,23 +19,59 @@ if (!bun) throw new Error("packageManager must be bun@<version>")
1919
2020const images = [ "base" , "bun-node" , "rust" , "tauri-linux" , "publish" ]
2121
22+ const setup = async ( ) => {
23+ if ( ! push ) return
24+ const list = await $ `docker buildx ls` . text ( )
25+ if ( list . includes ( "opencode" ) ) {
26+ await $ `docker buildx use opencode`
27+ return
28+ }
29+ await $ `docker buildx create --name opencode --use`
30+ }
31+
32+ await setup ( )
33+
34+ const platform = "linux/amd64,linux/arm64"
35+
2236for ( const name of images ) {
2337 const image = `${ reg } /build/${ name } :${ tag } `
2438 const file = `packages/containers/${ name } /Dockerfile`
2539 if ( name === "base" ) {
26- console . log ( `docker build -f ${ file } -t ${ image } .` )
27- await $ `docker build -f ${ file } -t ${ image } .`
40+ if ( push ) {
41+ console . log ( `docker buildx build --platform ${ platform } -f ${ file } -t ${ image } --push .` )
42+ await $ `docker buildx build --platform ${ platform } -f ${ file } -t ${ image } --push .`
43+ }
44+ if ( ! push ) {
45+ console . log ( `docker build -f ${ file } -t ${ image } .` )
46+ await $ `docker build -f ${ file } -t ${ image } .`
47+ }
2848 }
2949 if ( name === "bun-node" ) {
30- console . log ( `docker build -f ${ file } -t ${ image } --build-arg REGISTRY=${ reg } --build-arg BUN_VERSION=${ bun } .` )
31- await $ `docker build -f ${ file } -t ${ image } --build-arg REGISTRY=${ reg } --build-arg BUN_VERSION=${ bun } .`
50+ if ( push ) {
51+ console . log (
52+ `docker buildx build --platform ${ platform } -f ${ file } -t ${ image } --build-arg REGISTRY=${ reg } --build-arg BUN_VERSION=${ bun } --push .` ,
53+ )
54+ await $ `docker buildx build --platform ${ platform } -f ${ file } -t ${ image } --build-arg REGISTRY=${ reg } --build-arg BUN_VERSION=${ bun } --push .`
55+ }
56+ if ( ! push ) {
57+ console . log ( `docker build -f ${ file } -t ${ image } --build-arg REGISTRY=${ reg } --build-arg BUN_VERSION=${ bun } .` )
58+ await $ `docker build -f ${ file } -t ${ image } --build-arg REGISTRY=${ reg } --build-arg BUN_VERSION=${ bun } .`
59+ }
3260 }
3361 if ( name !== "base" && name !== "bun-node" ) {
34- console . log ( `docker build -f ${ file } -t ${ image } --build-arg REGISTRY=${ reg } .` )
35- await $ `docker build -f ${ file } -t ${ image } --build-arg REGISTRY=${ reg } .`
62+ if ( push ) {
63+ console . log (
64+ `docker buildx build --platform ${ platform } -f ${ file } -t ${ image } --build-arg REGISTRY=${ reg } --push .` ,
65+ )
66+ await $ `docker buildx build --platform ${ platform } -f ${ file } -t ${ image } --build-arg REGISTRY=${ reg } --push .`
67+ }
68+ if ( ! push ) {
69+ console . log ( `docker build -f ${ file } -t ${ image } --build-arg REGISTRY=${ reg } .` )
70+ await $ `docker build -f ${ file } -t ${ image } --build-arg REGISTRY=${ reg } .`
71+ }
3672 }
3773
3874 if ( push ) {
39- await $ `docker push ${ image } `
75+ console . log ( `pushed ${ image } `)
4076 }
4177}
0 commit comments