mirror of
https://github.com/anomalyco/opencode.git
synced 2026-02-01 22:48:16 +00:00
ci
This commit is contained in:
7
.github/workflows/containers.yml
vendored
7
.github/workflows/containers.yml
vendored
@@ -7,6 +7,7 @@ on:
|
||||
paths:
|
||||
- packages/containers/**
|
||||
- .github/workflows/containers.yml
|
||||
- package.json
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
@@ -24,6 +25,12 @@ jobs:
|
||||
|
||||
- uses: ./.github/actions/setup-bun
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
|
||||
@@ -16,6 +16,7 @@ Build
|
||||
|
||||
```
|
||||
REGISTRY=ghcr.io/anomalyco TAG=24.04 bun ./packages/containers/script/build.ts
|
||||
REGISTRY=ghcr.io/anomalyco TAG=24.04 bun ./packages/containers/script/build.ts --push
|
||||
```
|
||||
|
||||
Workflow usage
|
||||
@@ -32,5 +33,6 @@ Notes
|
||||
|
||||
- These images only help Linux jobs. macOS and Windows jobs cannot run
|
||||
inside Linux containers.
|
||||
- `--push` publishes multi-arch (amd64 + arm64) images using Buildx.
|
||||
- If a job uses Docker Buildx, the container needs access to the host
|
||||
Docker daemon (or `docker-in-docker` with privileged mode).
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
ARG REGISTRY=ghcr.io/anomalyco
|
||||
FROM ${REGISTRY}/build/base:24.04
|
||||
|
||||
SHELL ["/bin/bash", "-lc"]
|
||||
|
||||
ARG NODE_VERSION=24.4.0
|
||||
ARG BUN_VERSION=1.3.5
|
||||
|
||||
|
||||
@@ -19,23 +19,59 @@ if (!bun) throw new Error("packageManager must be bun@<version>")
|
||||
|
||||
const images = ["base", "bun-node", "rust", "tauri-linux", "publish"]
|
||||
|
||||
const setup = async () => {
|
||||
if (!push) return
|
||||
const list = await $`docker buildx ls`.text()
|
||||
if (list.includes("opencode")) {
|
||||
await $`docker buildx use opencode`
|
||||
return
|
||||
}
|
||||
await $`docker buildx create --name opencode --use`
|
||||
}
|
||||
|
||||
await setup()
|
||||
|
||||
const platform = "linux/amd64,linux/arm64"
|
||||
|
||||
for (const name of images) {
|
||||
const image = `${reg}/build/${name}:${tag}`
|
||||
const file = `packages/containers/${name}/Dockerfile`
|
||||
if (name === "base") {
|
||||
console.log(`docker build -f ${file} -t ${image} .`)
|
||||
await $`docker build -f ${file} -t ${image} .`
|
||||
if (push) {
|
||||
console.log(`docker buildx build --platform ${platform} -f ${file} -t ${image} --push .`)
|
||||
await $`docker buildx build --platform ${platform} -f ${file} -t ${image} --push .`
|
||||
}
|
||||
if (!push) {
|
||||
console.log(`docker build -f ${file} -t ${image} .`)
|
||||
await $`docker build -f ${file} -t ${image} .`
|
||||
}
|
||||
}
|
||||
if (name === "bun-node") {
|
||||
console.log(`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} --build-arg BUN_VERSION=${bun} .`)
|
||||
await $`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} --build-arg BUN_VERSION=${bun} .`
|
||||
if (push) {
|
||||
console.log(
|
||||
`docker buildx build --platform ${platform} -f ${file} -t ${image} --build-arg REGISTRY=${reg} --build-arg BUN_VERSION=${bun} --push .`,
|
||||
)
|
||||
await $`docker buildx build --platform ${platform} -f ${file} -t ${image} --build-arg REGISTRY=${reg} --build-arg BUN_VERSION=${bun} --push .`
|
||||
}
|
||||
if (!push) {
|
||||
console.log(`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} --build-arg BUN_VERSION=${bun} .`)
|
||||
await $`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} --build-arg BUN_VERSION=${bun} .`
|
||||
}
|
||||
}
|
||||
if (name !== "base" && name !== "bun-node") {
|
||||
console.log(`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} .`)
|
||||
await $`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} .`
|
||||
if (push) {
|
||||
console.log(
|
||||
`docker buildx build --platform ${platform} -f ${file} -t ${image} --build-arg REGISTRY=${reg} --push .`,
|
||||
)
|
||||
await $`docker buildx build --platform ${platform} -f ${file} -t ${image} --build-arg REGISTRY=${reg} --push .`
|
||||
}
|
||||
if (!push) {
|
||||
console.log(`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} .`)
|
||||
await $`docker build -f ${file} -t ${image} --build-arg REGISTRY=${reg} .`
|
||||
}
|
||||
}
|
||||
|
||||
if (push) {
|
||||
await $`docker push ${image}`
|
||||
console.log(`pushed ${image}`)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user