Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 5, 2026

Building GripMock binaries and plugins outside a controlled environment causes runtime incompatibilities: plugin version mismatches, Go toolchain conflicts, libc incompatibilities (glibc vs musl), and CGO symbol resolution errors.

Changes

New builder image (Dockerfile.builder)

  • Pins Go 1.25 + Alpine 3.23 matching runtime and go.mod
  • Includes full CGO toolchain: gcc, g++, musl-dev, binutils, git
  • Sets CGO_ENABLED=1, CC=gcc, CXX=g++

CI/CD updates (.github/workflows/builder.yaml)

  • Adds builder-image job before docker job
  • Publishes to Docker Hub and GHCR with semver tags
  • Uses separate cache scope
  • Sets explicit permissions: contents: read, packages: write

Build targets (Makefile)

build-builder:
	docker buildx build --load -f Dockerfile.builder -t ${BUILDER_IMAGE} .

plugins-docker:
	docker run --rm -v $(pwd):/workspace -w /workspace ${BUILDER_IMAGE} sh -c '\
		mkdir -p plugins; \
		for dir in examples/plugins/*; do \
			[ -d $$dir ] && go build -buildmode=plugin -o plugins/$$(basename $$dir).so $$dir/*.go; \
		done'

Documentation (README.md)

  • Documents common build failures prevented by builder image
  • Provides plugin build examples with Docker
  • Shows multi-stage build pattern for custom plugins

Usage

FROM bavix/gripmock-builder:latest AS builder
WORKDIR /app
COPY . .
RUN go build -buildmode=plugin -o custom.so ./plugin/*.go

FROM bavix/gripmock:latest
COPY --from=builder /app/custom.so /plugins/
CMD ["gripmock", "--plugins", "/plugins", "/proto/service.proto"]

Main Dockerfile unchanged to maintain existing build behavior.

Original prompt

This section details on the original issue you should resolve

<issue_title>Create a builder image</issue_title>
<issue_description>Currently, building binaries and plugins outside of a controlled environment may lead to runtime incompatibilities and non-reproducible builds. Introducing a dedicated builder image would provide a stable and consistent toolchain for compilation and linking.

A builder image would ensure:

  • Reproducible builds with pinned compiler, Go version, and system libraries
  • Correct linking of binaries and plugins
  • Fewer environment-specific issues in local builds and CI/CD
  • Cleaner production images via multi-stage Docker builds

Common issues without a builder image:

  • Plugin / runtime mismatch

    plugin was built with a different version of package runtime
    
  • Go toolchain mismatch

    panic: plugin.Open: plugin was built with a different version of package sync
    
  • libc incompatibility (glibc vs musl)

    /lib64/libc.so.6: version `GLIBC_2.34' not found
    
  • Invalid or incompatible binary format

    invalid ELF header
    
  • Missing shared libraries at runtime

    error while loading shared libraries: libstdc++.so.6: cannot open shared object file
    
  • CGO symbol resolution errors

    undefined symbol: sqlite3_open_v2
    

Proposed solution:
Provide an official builder image that:

  • Pins Go and system dependency versions
  • Is used for compiling binaries and plugins
  • Is compatible with the recommended runtime image
  • Can be easily integrated into CI/CD and multi-stage Dockerfiles

This would significantly improve build reliability and developer experience.
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits January 5, 2026 20:24
Co-authored-by: rez1dent3 <5111255+rez1dent3@users.noreply.github.com>
…resilience

Co-authored-by: rez1dent3 <5111255+rez1dent3@users.noreply.github.com>
Co-authored-by: rez1dent3 <5111255+rez1dent3@users.noreply.github.com>
Co-authored-by: rez1dent3 <5111255+rez1dent3@users.noreply.github.com>
Copilot AI changed the title [WIP] Add builder image for stable build environment Add builder image for reproducible builds and plugin compatibility Jan 5, 2026
Copilot AI requested a review from rez1dent3 January 5, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a builder image

2 participants