Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ensure shell scripts always use LF line endings
entrypoint.sh text eol=lf
60 changes: 60 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -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
47 changes: 45 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- `<sha>` - 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
Expand Down Expand Up @@ -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:
Expand All @@ -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
```

Expand Down