-
Notifications
You must be signed in to change notification settings - Fork 0
feat: combine #9 (Docker workflow + GHCR) and #11 (harden GH Actions CI) into one PR #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
abfab61
86fdf17
2d43222
bfece09
2af3410
a5fee4a
d7674bf
53e94ad
ce7aeab
5a382a4
fec8432
6cf0e32
4e90722
fe1bf98
2c1643e
daa9959
87c6c1a
e2a9394
eaa90b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Ignore junk for Docker builds (helps with the duplicated layout issue) | ||
| engram-parser/ | ||
| target/ | ||
| **/.git | ||
| **/*.rs.bk |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Minimal Codecov config for Rust (per https://about.codecov.io/language/rust/ and #11 AC) | ||
| # We will use codecov https://about.codecov.io/language/rust/ | ||
| codecov: | ||
| require_ci_to_pass: true | ||
|
|
||
| coverage: | ||
| precision: 2 | ||
| round: down | ||
| range: "70...100" | ||
|
|
||
| status: | ||
| project: true | ||
| patch: true | ||
| changes: false | ||
|
|
||
| # CI generates lcov format (cargo llvm-cov --lcov); no gcov parser needed. | ||
| comment: false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| name: Docker Build | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - '**' | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| concurrency: | ||
| group: docker-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build Docker Image (CPU-only) | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| # actions/checkout@v4.2.2 | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 | ||
|
|
||
| - name: Set Docker tags | ||
| id: tags | ||
| env: | ||
| EVENT_NAME: ${{ github.event_name }} | ||
| REF: ${{ github.ref }} | ||
| PR_NUMBER: ${{ github.event.number }} | ||
| COMMIT_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} | ||
| REPO_RAW: ${{ github.repository }} | ||
| run: | | ||
| REPO="ghcr.io/$(echo "$REPO_RAW" | tr '[:upper:]' '[:lower:]')" | ||
| TAGS="${REPO}:${COMMIT_SHA}" | ||
| if [ "$EVENT_NAME" = "push" ] && [ "$REF" = "refs/heads/main" ]; then | ||
| TAGS="$TAGS,${REPO}:main" | ||
| fi | ||
| if [ "$EVENT_NAME" = "pull_request" ]; then | ||
| TAGS="$TAGS,${REPO}:pr-${PR_NUMBER}" | ||
| fi | ||
| echo "tags=$TAGS" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Login to GitHub Container Registry | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Build Docker Image | ||
| uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5 | ||
| with: | ||
| context: . | ||
| push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | ||
| tags: ${{ steps.tags.outputs.tags }} | ||
| # No build-args needed (CPU-only, stable Rust in Dockerfile) | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| /target | ||
| /Cargo.lock.bak | ||
| **/*.rs.bk | ||
| .mimocode/ | ||
| engram-parser/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # syntax=docker/dockerfile:1.4 | ||
| # | ||
| # Dockerfile for engram-parser (pure-Rust, zero-dep GGUF/MoE parser). | ||
| # Single-stage build for CI verification and reproducible builds. | ||
| # | ||
| # engram-parser is a library crate with no binary target, so there is no | ||
| # standalone artifact to deploy to a runtime image. This image is used for: | ||
| # - CI build/test verification | ||
| # - Reproducible build environment | ||
| # - Base image for downstream crates that depend on engram-parser | ||
| # | ||
| # Usage: | ||
| # docker build -t engram-parser . | ||
| # docker run --rm engram-parser cargo test --all-features | ||
| # | ||
| # See .github/workflows/docker-build.yml and issue #9 for CI (GHCR on main). | ||
|
|
||
| ARG RUST_VERSION=1.87 | ||
|
|
||
| FROM rust:${RUST_VERSION}-slim | ||
|
|
||
| RUN useradd -m -u 10001 appuser | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Copy manifests and lock file for reproducibility | ||
| COPY Cargo.toml Cargo.lock ./ | ||
|
|
||
| # Copy source | ||
| COPY . . | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
Comment on lines
+27
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Dockerfile COPY pattern defeats dependency layer caching The Dockerfile copies manifests first ( Was this helpful? React with 👍 or 👎 to provide feedback.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acknowledged — the separate COPY Cargo.toml/Cargo.lock before COPY . . is kept for organizational clarity and forward compatibility. This crate has zero deps today so there is no caching benefit either way. Adding RUN cargo fetch between the COPYs was attempted but failed because cargo requires a target (src/lib.rs) to parse Cargo.toml. The standard Docker dummy-source pattern was rejected for simplicity in the single-stage design (ce7aeab). — Cline agent: DeepSeek-v4-pro |
||
|
|
||
| # Build and test the crate (zero external deps, no system packages needed) | ||
| RUN cargo build --release --all-features && \ | ||
| cargo test --release --all-features | ||
|
|
||
| RUN chown -R appuser:appuser /app | ||
|
|
||
| USER appuser | ||
|
rmems marked this conversation as resolved.
|
||
|
|
||
| CMD ["cargo", "test", "--release", "--all-features"] | ||
Uh oh!
There was an error while loading. Please reload this page.