Skip to content

Commit e01c38e

Browse files
Add Debian-based Docker and comprehensive CI/CD workflows
- Update Dockerfile to use Debian slim instead of Alpine - Improve entrypoint.sh with better error handling - Add ci.yml workflow for builds/tests on PRs and main - Add release-and-publish.yml for multi-arch Docker + cross-compiled binaries - Update set-version.sh to use shell instead of Python for better portability - Update README.md with comprehensive Docker and release documentation Co-authored-by: elasticdotventures <[email protected]>
1 parent c2ce396 commit e01c38e

File tree

6 files changed

+348
-197
lines changed

6 files changed

+348
-197
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
uses: actions-rs/toolchain@v1
37+
with:
38+
toolchain: 1.91.1
39+
override: true
40+
components: clippy, rustfmt
41+
42+
- name: Show rustc & cargo versions
43+
run: |
44+
rustc --version
45+
cargo --version
46+
47+
- name: Build (release)
48+
run: cargo build --locked --release
49+
50+
- name: Run tests
51+
run: cargo test --locked --all -- --nocapture
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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@v2
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v2
29+
30+
- name: Authenticate to GHCR
31+
uses: docker/login-action@v2
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@v4
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+
run: |
77+
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
78+
cargo build --locked --release --target aarch64-unknown-linux-gnu
79+
strip target/aarch64-unknown-linux-gnu/release/cratedocs || true
80+
81+
- name: Upload x86_64 binary to release
82+
uses: softprops/action-gh-release@v1
83+
with:
84+
files: target/x86_64-unknown-linux-gnu/release/cratedocs
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
88+
- name: Upload aarch64 binary to release
89+
uses: softprops/action-gh-release@v1
90+
with:
91+
files: target/aarch64-unknown-linux-gnu/release/cratedocs
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 10 additions & 8 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,9 +21,9 @@ 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

0 commit comments

Comments
 (0)