Created
December 18, 2025 09:51
-
-
Save airtonix/e79f4383936d45cd95a0c10d7f4c3e9c to your computer and use it in GitHub Desktop.
OpenCode build script for Fedora Docker builds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| DOCKER_IMAGE_NAME="${DOCKER_IMAGE_NAME:-opencode-builder}" | |
| DOCKER_BASE_IMAGE="${DOCKER_BASE_IMAGE:-fedora:latest}" | |
| # Display usage | |
| usage() { | |
| cat <<EOF | |
| Usage: $0 [prepare|build] | |
| Commands: | |
| prepare Build the Docker image with OS dependencies and Bun | |
| build Build OpenCode desktop apps in Docker | |
| Examples: | |
| $0 prepare # Build the image (do this first) | |
| $0 build # Build the desktop app | |
| Environment variables: | |
| DOCKER_IMAGE_NAME Docker image name (default: opencode-builder) | |
| DOCKER_BASE_IMAGE Base image to build from (default: fedora:latest) | |
| EOF | |
| exit 1 | |
| } | |
| # Prepare: Build Docker image with dependencies | |
| prepare_image() { | |
| echo "π³ Building Docker image: $DOCKER_IMAGE_NAME" | |
| docker build -t "$DOCKER_IMAGE_NAME" --progress=plain - <<'DOCKERFILE' | |
| FROM fedora:latest | |
| # Install OS dependencies | |
| RUN echo "π¦ Installing dependencies..." && \ | |
| dnf install -y \ | |
| curl git unzip tar gzip \ | |
| webkit2gtk4.1-devel libappindicator-devel \ | |
| librsvg2-devel patchelf rustup && \ | |
| dnf clean all | |
| # Install Bun globally | |
| RUN echo "π° Installing Bun..." && \ | |
| curl -fsSL https://bun.sh/install | bash && \ | |
| ln -s /root/.bun/bin/bun /usr/local/bin/bun && \ | |
| bun --version | |
| # Set environment for Tauri | |
| ENV PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 | |
| ENV PATH="/root/.bun/bin:$PATH" | |
| WORKDIR /workspace | |
| DOCKERFILE | |
| echo "β Docker image prepared: $DOCKER_IMAGE_NAME" | |
| } | |
| # Build: Run build commands in Docker | |
| build_app() { | |
| echo "ποΈ Building OpenCode desktop in Docker..." | |
| docker run --rm -it \ | |
| -v "$SCRIPT_DIR":/workspace \ | |
| -w /workspace \ | |
| "$DOCKER_IMAGE_NAME" \ | |
| bash -c ' | |
| set -e | |
| echo "π¦ Building OpenCode CLI with sidecars..." | |
| bun run ./packages/tauri/scripts/build.ts opencode | |
| echo "π₯οΈ Building OpenCode desktop apps..." | |
| bun run ./packages/tauri/scripts/build.ts desktop | |
| echo "β Build complete!" | |
| ' | |
| } | |
| # Main | |
| if [[ $# -eq 0 ]]; then | |
| usage | |
| fi | |
| case "$1" in | |
| prepare) | |
| prepare_image | |
| ;; | |
| build) | |
| build_app | |
| ;; | |
| *) | |
| echo "β Unknown command: $1" | |
| usage | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment