Skip to content

Commit 6623803

Browse files
ci: publish pre-built dsl-parser binary to GHCR
Adds a GitHub Actions workflow that builds the OCaml dsl-parser binary for amd64 and arm64, then publishes it as a multi-arch scratch image to ghcr.io/griffincancode/callosum-dsl-parser:latest. This lets downstream consumers (uniqpath) pull the ~5 MB binary in ~2s instead of compiling OCaml from source (~220s per build). Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 5a04fab commit 6623803

2 files changed

Lines changed: 106 additions & 0 deletions

File tree

.github/workflows/build-binary.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build dsl-parser binary
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "core/**"
8+
- ".github/workflows/build-binary.yml"
9+
workflow_dispatch:
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository_owner }}/callosum-dsl-parser
14+
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
jobs:
20+
build:
21+
strategy:
22+
matrix:
23+
include:
24+
- runner: ubuntu-latest
25+
platform: linux/amd64
26+
tag_suffix: amd64
27+
- runner: ubuntu-24.04-arm
28+
platform: linux/arm64
29+
tag_suffix: arm64
30+
31+
runs-on: ${{ matrix.runner }}
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v3
38+
39+
- name: Log in to GHCR
40+
uses: docker/login-action@v3
41+
with:
42+
registry: ${{ env.REGISTRY }}
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Build and push
47+
uses: docker/build-push-action@v6
48+
with:
49+
context: ./core
50+
file: ./core/Dockerfile.binary
51+
push: true
52+
tags: |
53+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.tag_suffix }}
54+
platforms: ${{ matrix.platform }}
55+
cache-from: type=gha,scope=callosum-${{ matrix.tag_suffix }}
56+
cache-to: type=gha,mode=max,scope=callosum-${{ matrix.tag_suffix }}
57+
58+
manifest:
59+
needs: build
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- name: Log in to GHCR
64+
uses: docker/login-action@v3
65+
with:
66+
registry: ${{ env.REGISTRY }}
67+
username: ${{ github.actor }}
68+
password: ${{ secrets.GITHUB_TOKEN }}
69+
70+
- name: Create multi-arch manifest
71+
run: |
72+
docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
73+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:amd64 \
74+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:arm64
75+
docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest

core/Dockerfile.binary

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# syntax=docker/dockerfile:1
2+
#
3+
# Builds the dsl-parser binary and exports it in a minimal scratch image.
4+
# Consumed by uniqpath via: COPY --from=ghcr.io/griffincancode/callosum-dsl-parser:latest /dsl-parser /app/bin/dsl-parser
5+
#
6+
# Usage:
7+
# docker build -f Dockerfile.binary -t callosum-dsl-parser .
8+
# docker cp "$(docker create callosum-dsl-parser)":/dsl-parser ./dsl-parser
9+
10+
ARG OCAML_VERSION=5.3
11+
12+
FROM ocaml/opam:debian-12-ocaml-${OCAML_VERSION} AS build
13+
14+
USER root
15+
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates && rm -rf /var/lib/apt/lists/*
16+
USER opam
17+
18+
COPY --chown=opam:opam . /home/opam/callosum/core
19+
WORKDIR /home/opam/callosum/core
20+
21+
RUN opam install . --deps-only --yes --quiet 2>&1 && \
22+
opam exec -- dune build bin/main.exe 2>&1
23+
24+
RUN test -x _build/default/bin/main.exe && \
25+
cp _build/default/bin/main.exe /tmp/dsl-parser && \
26+
chmod 755 /tmp/dsl-parser && \
27+
strip /tmp/dsl-parser
28+
29+
# Scratch image with just the binary (~5 MB)
30+
FROM scratch
31+
COPY --from=build /tmp/dsl-parser /dsl-parser

0 commit comments

Comments
 (0)