Просмотр исходного кода

add ARM64 Docker image support (#5483)

Felipe Oduardo Sierra 3 месяцев назад
Родитель
Сommit
f254cf76d9
3 измененных файлов с 20 добавлено и 6 удалено
  1. 6 0
      .github/workflows/publish.yml
  2. 10 2
      packages/opencode/Dockerfile
  3. 4 4
      packages/opencode/script/publish.ts

+ 6 - 0
.github/workflows/publish.yml

@@ -64,6 +64,12 @@ jobs:
           username: ${{ github.repository_owner }}
           username: ${{ github.repository_owner }}
           password: ${{ secrets.GITHUB_TOKEN }}
           password: ${{ secrets.GITHUB_TOKEN }}
 
 
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v3
+
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v3
+
       - uses: actions/setup-node@v4
       - uses: actions/setup-node@v4
         with:
         with:
           node-version: "24"
           node-version: "24"

+ 10 - 2
packages/opencode/Dockerfile

@@ -1,10 +1,18 @@
-FROM alpine
+FROM alpine AS base
 
 
 # Disable the runtime transpiler cache by default inside Docker containers.
 # Disable the runtime transpiler cache by default inside Docker containers.
 # On ephemeral containers, the cache is not useful
 # On ephemeral containers, the cache is not useful
 ARG BUN_RUNTIME_TRANSPILER_CACHE_PATH=0
 ARG BUN_RUNTIME_TRANSPILER_CACHE_PATH=0
 ENV BUN_RUNTIME_TRANSPILER_CACHE_PATH=${BUN_RUNTIME_TRANSPILER_CACHE_PATH}
 ENV BUN_RUNTIME_TRANSPILER_CACHE_PATH=${BUN_RUNTIME_TRANSPILER_CACHE_PATH}
 RUN apk add libgcc libstdc++ ripgrep
 RUN apk add libgcc libstdc++ ripgrep
-ADD ./dist/opencode-linux-x64-baseline-musl/bin/opencode /usr/local/bin/opencode
+
+FROM base AS build-amd64
+COPY dist/opencode-linux-x64-baseline-musl/bin/opencode /usr/local/bin/opencode
+
+FROM base AS build-arm64
+COPY dist/opencode-linux-arm64-musl/bin/opencode /usr/local/bin/opencode
+
+ARG TARGETARCH
+FROM build-${TARGETARCH}
 RUN opencode --version
 RUN opencode --version
 ENTRYPOINT ["opencode"]
 ENTRYPOINT ["opencode"]

+ 4 - 4
packages/opencode/script/publish.ts

@@ -244,8 +244,8 @@ if (!Script.preview) {
   await $`cd ./dist/homebrew-tap && git push`
   await $`cd ./dist/homebrew-tap && git push`
 
 
   const image = "ghcr.io/sst/opencode"
   const image = "ghcr.io/sst/opencode"
-  await $`docker build -t ${image}:${Script.version} .`
-  await $`docker push ${image}:${Script.version}`
-  await $`docker tag ${image}:${Script.version} ${image}:latest`
-  await $`docker push ${image}:latest`
+  const platforms = "linux/amd64,linux/arm64"
+  const tags = [`${image}:${Script.version}`, `${image}:latest`]
+  const tagFlags = tags.flatMap((t) => ["-t", t])
+  await $`docker buildx build --platform ${platforms} ${tagFlags} --push .`
 }
 }