Skip to content

Commit cd664a1

Browse files
committed
ci
1 parent 849f488 commit cd664a1

File tree

4 files changed

+54
-7
lines changed

4 files changed

+54
-7
lines changed

.github/workflows/containers.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
paths:
88
- packages/containers/**
99
- .github/workflows/containers.yml
10+
- package.json
1011
workflow_dispatch:
1112

1213
permissions:
@@ -24,6 +25,12 @@ jobs:
2425

2526
- uses: ./.github/actions/setup-bun
2627

28+
- name: Set up QEMU
29+
uses: docker/setup-qemu-action@v3
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
2734
- name: Login to GHCR
2835
uses: docker/login-action@v3
2936
with:

packages/containers/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Build
1616

1717
```
1818
REGISTRY=ghcr.io/anomalyco TAG=24.04 bun ./packages/containers/script/build.ts
19+
REGISTRY=ghcr.io/anomalyco TAG=24.04 bun ./packages/containers/script/build.ts --push
1920
```
2021

2122
Workflow usage
@@ -32,5 +33,6 @@ Notes
3233

3334
- These images only help Linux jobs. macOS and Windows jobs cannot run
3435
inside Linux containers.
36+
- `--push` publishes multi-arch (amd64 + arm64) images using Buildx.
3537
- If a job uses Docker Buildx, the container needs access to the host
3638
Docker daemon (or `docker-in-docker` with privileged mode).

packages/containers/bun-node/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
ARG REGISTRY=ghcr.io/anomalyco
22
FROM ${REGISTRY}/build/base:24.04
33

4+
SHELL ["/bin/bash", "-lc"]
5+
46
ARG NODE_VERSION=24.4.0
57
ARG BUN_VERSION=1.3.5
68

packages/containers/script/build.ts

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,59 @@ if (!bun) throw new Error("packageManager must be bun@<version>")
1919

2020
const 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+
2236
for (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

Comments
 (0)