From 63e12e1adec7ad38398c34a71451c7172f8f4f28 Mon Sep 17 00:00:00 2001 From: Xiaochen Wu Date: Tue, 28 Oct 2025 23:08:50 +0800 Subject: [PATCH 1/2] fix: resolve Docker entrypoint error on Windows by enforcing LF line endings for shell scripts --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c21ed19 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Ensure shell scripts always use LF line endings +entrypoint.sh text eol=lf From 4b8364cce4c087a352866a1dc940e768edcf9bf8 Mon Sep 17 00:00:00 2001 From: Xiaochen Wu Date: Wed, 29 Oct 2025 01:10:11 +0800 Subject: [PATCH 2/2] Add GitHub Container Registry support with automated Docker build and publish workflow --- .github/workflows/docker-publish.yml | 60 ++++++++++++++++++++++++++++ README.md | 47 +++++++++++++++++++++- 2 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..16f36be --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,60 @@ +name: Docker Image CI + +on: + push: + branches: [ "master", "main" ] + tags: + - 'v*' + pull_request: + branches: [ "master", "main" ] + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha,prefix={{branch}}- + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + platforms: linux/amd64,linux/arm64 diff --git a/README.md b/README.md index 0d36c13..413b70c 100644 --- a/README.md +++ b/README.md @@ -59,13 +59,36 @@ bun install ## Using with Docker -Build image +### Using Pre-built Image from GitHub Container Registry + +You can pull and run the pre-built image directly from GitHub Container Registry: + +```sh +# Pull the latest image +docker pull ghcr.io/ericc-ch/copilot-api:latest + +# Create a directory on your host to persist the GitHub token and related data +mkdir -p ./copilot-data + +# Run the container with a bind mount to persist the token +docker run -p 4141:4141 -v $(pwd)/copilot-data:/root/.local/share/copilot-api ghcr.io/ericc-ch/copilot-api:latest +``` + +Available tags: +- `latest` - Latest build from the master branch +- `v*.*.*` - Specific version tags (e.g., `v1.0.0`) +- `master` - Latest master branch build +- `` - Specific commit builds + +### Building Locally + +Build image from source: ```sh docker build -t copilot-api . ``` -Run the container +Run the locally built container: ```sh # Create a directory on your host to persist the GitHub token and related data @@ -97,6 +120,24 @@ docker run -p 4141:4141 -e GH_TOKEN=your_token copilot-api start --verbose --por ### Docker Compose Example +Using pre-built image: + +```yaml +version: "3.8" +services: + copilot-api: + image: ghcr.io/ericc-ch/copilot-api:latest + ports: + - "4141:4141" + environment: + - GH_TOKEN=your_github_token_here + volumes: + - ./copilot-data:/root/.local/share/copilot-api + restart: unless-stopped +``` + +Or building from source: + ```yaml version: "3.8" services: @@ -106,6 +147,8 @@ services: - "4141:4141" environment: - GH_TOKEN=your_github_token_here + volumes: + - ./copilot-data:/root/.local/share/copilot-api restart: unless-stopped ```