Skip to content

Commit 39727aa

Browse files
Merge branch 'main' into feat/build-pkgx-install
Signed-off-by: Brian Horakh <[email protected]>
2 parents 471be18 + 344dfe4 commit 39727aa

File tree

12 files changed

+575
-97
lines changed

12 files changed

+575
-97
lines changed

.github/workflows/ci.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
build-and-test:
16+
name: Build and Test
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Cache cargo registry & target
25+
uses: actions/cache@v4
26+
with:
27+
path: |
28+
~/.cargo/registry
29+
~/.cargo/git
30+
target
31+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-cargo-
34+
35+
- name: Install Rust toolchain
36+
run: |
37+
rustup toolchain install 1.91.1
38+
rustup default 1.91.1
39+
rustup component add clippy rustfmt
40+
41+
- name: Show rustc & cargo versions
42+
run: |
43+
rustc --version
44+
cargo --version
45+
46+
- name: Build (release)
47+
run: cargo build --locked --release
48+
49+
- name: Run tests
50+
run: cargo test --locked --all -- --nocapture
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Release & Publish (GHCR + cross-compiled binaries)
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch: {}
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
build-push-and-release:
15+
name: Build, Push Docker, Create Release, Upload Binaries
16+
runs-on: ubuntu-latest
17+
environment: production
18+
steps:
19+
- name: Checkout (full history & tags)
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up QEMU
25+
uses: docker/setup-qemu-action@v3
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
30+
- name: Authenticate to GHCR
31+
uses: docker/login-action@v3
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Determine tag name
38+
id: tag
39+
run: |
40+
echo "ref_name=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
41+
42+
- name: Build and push multi-arch Docker image
43+
uses: docker/build-push-action@v6
44+
with:
45+
context: .
46+
file: ./Dockerfile
47+
push: true
48+
platforms: linux/amd64,linux/arm64
49+
tags: |
50+
ghcr.io/${{ github.repository_owner }}/rust-cargo-docs-rag-mcp:${{ steps.tag.outputs.ref_name }}
51+
ghcr.io/${{ github.repository_owner }}/rust-cargo-docs-rag-mcp:latest
52+
cache-from: type=gha
53+
cache-to: type=gha,mode=max
54+
55+
- name: Create GitHub release
56+
id: create_release
57+
uses: softprops/action-gh-release@v1
58+
with:
59+
tag_name: ${{ steps.tag.outputs.ref_name }}
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
63+
- name: Prepare for cross-compilation (install toolchains)
64+
run: |
65+
sudo apt-get update
66+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
67+
rustup default 1.91.1
68+
rustup target add x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu
69+
70+
- name: Build x86_64-unknown-linux-gnu release binary
71+
run: |
72+
cargo build --locked --release --target x86_64-unknown-linux-gnu
73+
strip target/x86_64-unknown-linux-gnu/release/cratedocs || true
74+
75+
- name: Build aarch64-unknown-linux-gnu release binary
76+
env:
77+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
78+
CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc
79+
CXX_aarch64_unknown_linux_gnu: aarch64-linux-gnu-g++
80+
AR_aarch64_unknown_linux_gnu: aarch64-linux-gnu-ar
81+
run: |
82+
cargo build --locked --release --target aarch64-unknown-linux-gnu
83+
aarch64-linux-gnu-strip target/aarch64-unknown-linux-gnu/release/cratedocs || true
84+
85+
- name: Upload x86_64 binary to release
86+
uses: softprops/action-gh-release@v1
87+
with:
88+
files: target/x86_64-unknown-linux-gnu/release/cratedocs
89+
env:
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
92+
- name: Upload aarch64 binary to release
93+
uses: softprops/action-gh-release@v1
94+
with:
95+
files: target/aarch64-unknown-linux-gnu/release/cratedocs
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/rust.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@ name: Rust
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: ["main"]
66
pull_request:
7-
branches: [ "main" ]
7+
branches: ["main"]
88

99
env:
1010
CARGO_TERM_COLOR: always
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
1615

1716
steps:
18-
- uses: actions/checkout@v4
19-
- name: Build
20-
run: cargo build --verbose
21-
- name: Run tests
22-
run: cargo test --verbose
17+
- uses: actions/checkout@v4
18+
- name: Build
19+
run: cargo build --verbose
20+
- name: Run tests
21+
run: cargo test --verbose

.pr-summary.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# PR Summary: Debian-based Docker and CI/CD Workflows
2+
3+
**IMPORTANT: Branch Note**
4+
The changes have been implemented on the `release/ghcr-debian-cross` branch locally. Due to workspace automation constraints, the identical changes have also been pushed to `origin/copilot/update-dockerfile-to-debian-slim`.
5+
6+
To create the PR from the correct branch name (`release/ghcr-debian-cross`), you can:
7+
1. Manually push the local `release/ghcr-debian-cross` branch: `git push -u origin release/ghcr-debian-cross`
8+
2. Then create a PR from `release/ghcr-debian-cross` to `main`
9+
10+
Alternatively, you can rename the existing `copilot/update-dockerfile-to-debian-slim` branch to `release/ghcr-debian-cross` on GitHub.
11+
12+
This branch contains comprehensive updates to the Docker configuration and CI/CD workflows for the rust-cargo-docs-rag-mcp project.
13+
14+
## Changes Made
15+
16+
### 1. Dockerfile - Debian Migration
17+
- **Changed**: Migrated from Alpine to Debian slim (bullseye)
18+
- **Why**: Better compatibility with Rust dependencies and OpenSSL
19+
- **Details**: Multi-stage build preserved, uses `rust:1.91.1-slim-bullseye` for builder and `debian:bullseye-slim` for runtime
20+
21+
### 2. docker/entrypoint.sh - Enhanced Wrapper
22+
- **Changed**: Improved entrypoint script with case statement
23+
- **Features**:
24+
- Support for http and stdio modes
25+
- Debug mode flag handling
26+
- Pass-through support for custom arguments
27+
- Better error messages for unknown modes
28+
29+
### 3. .github/workflows/ci.yml - Build & Test Workflow
30+
- **New**: CI workflow for continuous integration
31+
- **Triggers**: On push to main and pull requests to main
32+
- **Steps**:
33+
- Checkout code
34+
- Cache cargo dependencies
35+
- Install Rust 1.91.1 toolchain
36+
- Build release binary
37+
- Run all tests
38+
39+
### 4. .github/workflows/release-and-publish.yml - Release Workflow
40+
- **New**: Comprehensive release automation
41+
- **Triggers**: On push of tags matching `v*` or manual dispatch
42+
- **Capabilities**:
43+
- Multi-architecture Docker builds (amd64, arm64)
44+
- Push to GitHub Container Registry (GHCR)
45+
- Create GitHub releases
46+
- Cross-compile binaries for x86_64 and aarch64 Linux
47+
- Upload binaries as release assets
48+
49+
### 5. scripts/set-version.sh - Portability Improvement
50+
- **Changed**: Rewritten from Python to pure shell
51+
- **Benefits**:
52+
- No Python dependency required
53+
- Falls back to sed if perl is not available
54+
- More portable across different environments
55+
- Idempotent and safe
56+
57+
### 6. README.md - Comprehensive Documentation
58+
- **Changed**: Complete rewrite of README
59+
- **New sections**:
60+
- Release/versioning workflow with Cocogitto
61+
- Docker installation and usage (GHCR)
62+
- Environment variables documentation
63+
- pkgx and Cargo installation methods
64+
- All available MCP tools with examples
65+
- Testing tools directly without server
66+
- MCP protocol integration examples
67+
68+
## Validation Performed
69+
70+
✅ YAML syntax validated for all workflows
71+
✅ Shell script syntax validated for entrypoint.sh and set-version.sh
72+
✅ Dockerfile validated with hadolint (minor warnings about best practices)
73+
✅ CodeQL security scan completed with no issues
74+
✅ Build system validated (cargo build succeeds)
75+
✅ Test suite runs (some pre-existing failures unrelated to these changes)
76+
77+
## Files Modified
78+
79+
```
80+
A .github/workflows/ci.yml
81+
A .github/workflows/release-and-publish.yml
82+
M Dockerfile
83+
M README.md
84+
M docker/entrypoint.sh
85+
M scripts/set-version.sh
86+
```
87+
88+
## Next Steps
89+
90+
1. Review and approve this PR
91+
2. Merge to main
92+
3. Tag a release (e.g., `v0.4.0`) to trigger the release workflow
93+
4. Verify Docker images are published to GHCR
94+
5. Verify binaries are attached to the GitHub release
95+
96+
## Notes
97+
98+
- The `production` environment referenced in the release workflow may need to be configured in GitHub repository settings
99+
- Ensure GitHub Actions has permission to publish packages (Settings → Actions → General → Workflow permissions → Read and write permissions)
100+
- The release workflow requires the `GITHUB_TOKEN` which is automatically provided by GitHub Actions

Dockerfile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
FROM rust:1.91.1-alpine3.20 AS builder
1+
FROM rust:1.91.1-slim-bullseye AS builder
22

3-
RUN apk add --no-cache \
4-
build-base \
5-
pkgconfig \
6-
openssl-dev \
7-
git
3+
RUN apt-get update && apt-get install -y \
4+
build-essential \
5+
pkg-config \
6+
libssl-dev \
7+
git \
8+
ca-certificates \
9+
&& rm -rf /var/lib/apt/lists/*
810

911
WORKDIR /app
1012

@@ -19,17 +21,15 @@ COPY . .
1921

2022
RUN cargo build --locked --release --bin cratedocs
2123

22-
FROM alpine:3.20
24+
FROM debian:bullseye-slim
2325

24-
RUN apk add --no-cache ca-certificates libgcc libstdc++ libssl3
26+
RUN apt-get update && apt-get install -y ca-certificates libssl1.1 && rm -rf /var/lib/apt/lists/*
2527

2628
COPY --from=builder /app/target/release/cratedocs /usr/local/bin/cratedocs
2729
COPY docker/entrypoint.sh /entrypoint.sh
2830

2931
RUN chmod +x /entrypoint.sh
3032

31-
LABEL io.modelcontextprotocol.server.name="io.github.promptexecution/rust-cargo-docs-rag-mcp"
32-
3333
EXPOSE 8080
3434

3535
ENV CRATEDOCS_MODE=http \

0 commit comments

Comments
 (0)