added docker build

This commit is contained in:
southseact-3d
2026-02-10 11:57:46 +00:00
parent 8e9f2dec8e
commit ec3aa6a6b5
2 changed files with 125 additions and 3 deletions

View File

@@ -0,0 +1,113 @@
name: Build OpenCode CLI and Docker Image
on:
push:
branches:
- main
- master
paths:
- opencode/**
- Dockerfile
- .github/workflows/build-opencode-cli-docker.yml
workflow_dispatch:
inputs:
image_name:
description: "Docker image name (including registry if desired)"
required: false
default: "ghcr.io/${{ github.repository_owner }}/shopify-ai-builder"
push_image:
description: "Push the image to the registry"
type: boolean
default: false
permissions:
contents: read
packages: write
jobs:
build-cli:
name: Build OpenCode CLI (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: ubuntu-24.04
cli_dir: opencode-linux-x64
- arch: arm64
runner: ubuntu-24.04-arm64
cli_dir: opencode-linux-arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version-file: opencode/package.json
- name: Install dependencies
run: bun install
working-directory: opencode
- name: Build CLI
run: ./packages/opencode/script/build.ts --single
working-directory: opencode
- name: Upload CLI artifact
uses: actions/upload-artifact@v4
with:
name: opencode-cli-${{ matrix.arch }}
path: opencode/packages/opencode/dist/${{ matrix.cli_dir }}
build-image:
name: Build Docker image
needs: build-cli
runs-on: ubuntu-24.04
env:
IMAGE_NAME: ${{ inputs.image_name || format('ghcr.io/{0}/shopify-ai-builder', github.repository_owner) }}
PUSH_IMAGE: ${{ inputs.push_image || false }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download CLI artifacts
uses: actions/download-artifact@v4
with:
pattern: opencode-cli-*
path: opencode/packages/opencode/dist
merge-multiple: true
- 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
if: ${{ env.PUSH_IMAGE == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image (multi-arch push)
if: ${{ env.PUSH_IMAGE == 'true' }}
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t "$IMAGE_NAME" \
--push \
.
- name: Build image (amd64) and verify CLI
if: ${{ env.PUSH_IMAGE != 'true' }}
run: |
docker buildx build \
--platform linux/amd64 \
-t "$IMAGE_NAME" \
--load \
.
docker run --rm "$IMAGE_NAME" opencode --version

View File

@@ -79,10 +79,19 @@ RUN ARCH="${TARGETARCH:-}" && \
"https://github.com/tsl0922/ttyd/releases/download/${TTYD_VERSION}/ttyd.${TTYD_ARCH}" \ "https://github.com/tsl0922/ttyd/releases/download/${TTYD_VERSION}/ttyd.${TTYD_ARCH}" \
&& chmod +x /usr/local/bin/ttyd && chmod +x /usr/local/bin/ttyd
# Install OpenCode from bundled anomalyco/opencode source # Install OpenCode from locally built CLI artifacts
# CI builds these binaries from the opencode folder.
COPY opencode /opt/opencode-src COPY opencode /opt/opencode-src
RUN bash /opt/opencode-src/install --no-modify-path \ COPY opencode/packages/opencode/dist/opencode-linux-x64/bin/opencode /opt/opencode-bin/opencode-linux-x64
&& ln -sf /root/.opencode/bin/opencode /usr/local/bin/opencode COPY opencode/packages/opencode/dist/opencode-linux-arm64/bin/opencode /opt/opencode-bin/opencode-linux-arm64
RUN if [ "$TARGETARCH" = "amd64" ]; then \
cp /opt/opencode-bin/opencode-linux-x64 /usr/local/bin/opencode; \
elif [ "$TARGETARCH" = "arm64" ]; then \
cp /opt/opencode-bin/opencode-linux-arm64 /usr/local/bin/opencode; \
else \
echo "Unsupported architecture: $TARGETARCH" && exit 1; \
fi \
&& chmod +x /usr/local/bin/opencode
# Removed Gemini CLI - not needed for Shopify AI App Builder # Removed Gemini CLI - not needed for Shopify AI App Builder