Skip to content

Resolve backend development for new contributors#135

Open
pratham15541 wants to merge 5 commits intoomegaup:mainfrom
pratham15541:fix/metrics-pipeline
Open

Resolve backend development for new contributors#135
pratham15541 wants to merge 5 commits intoomegaup:mainfrom
pratham15541:fix/metrics-pipeline

Conversation

@pratham15541
Copy link
Copy Markdown

Old Docker setup was failing for new contributors due to outdated base image.
Replaced with a reproducible Go 1.22 + libgit2 environment.

To build: docker build -f Dockerfile.latest-build -t quark-test .
To run test: docker run --rm -it -v "$PWD:/app" -w /app quark-test go test ./...

Fixes: #134

Copy link
Copy Markdown
Contributor

@pabo99 pabo99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the two commands you included in the description to the README?

Comment thread Dockerfile.latest-build Outdated
@pratham15541
Copy link
Copy Markdown
Author

Hi @pabo99, I’ve made the changes. Could you please review and let me know if anything else needs to be updated?

@pratham15541 pratham15541 requested a review from pabo99 March 27, 2026 03:48
@pratham15541 pratham15541 force-pushed the fix/metrics-pipeline branch from e166d73 to dfbfdd2 Compare March 27, 2026 06:10
@pratham15541 pratham15541 requested a review from pabo99 March 27, 2026 06:11
@heduenas
Copy link
Copy Markdown
Member

@pratham15541 if this PR is updating the base image, why is it creating a dockerfile instead of updating an existing one?

@pratham15541
Copy link
Copy Markdown
Author

pratham15541 commented Mar 29, 2026

Hi @heduenas, Updating the base image introduced multiple breaking changes—libgit2 was not being found during git2go build, and several Go dependencies.

Fixing this required restructuring the build steps (installing libgit2 manually, adjusting dependency handling, and aligning with newer Go module behavior). Since these changes are more than a small patch, I created a separate Dockerfile to keep the original setup intact and avoid unintended regressions.

@pratham15541
Copy link
Copy Markdown
Author

pratham15541 commented Mar 29, 2026

Hi @heduenas, I’ve prepared a patched version that looks like this. However, it currently does not work for ARM builds.

Since the image relies on CGO dependencies (libgit2 / git2go) with static linking, the ARM part cannot be built with CGO_ENABLED=0. Proper cross-compilation would require a full ARM toolchain and sysroot, which are not configured in this setup.

For now, I’ve disabled/skipped the ARM-related steps. Please let me know if you’d prefer a different approach for handling ARM support.

Additionally, my version is intentionally kept simpler, so I opted to add a new file instead of modifying the existing one extensively, which could have impacted other parts of the setup. That said, we can definitely optimize the image further if needed.

Also, for handling multiple architectures, it may be better to use a multi-stage build with Docker buildx instead of manually mixing architectures. CGO-dependent builds can be kept for supported targets, while disabling CGO for cross-compiled ones.
Happy to adjust based on your preference.

Docker.prebuild

FROM golang:1.22-bullseye

RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential cmake pkg-config \
    libssl-dev zlib1g-dev libssh2-1-dev \
    libgcrypt-dev libgpg-error-dev \
    gcc-arm-linux-gnueabihf libc6-dev-armhf-cross \
    default-jre \
    git ca-certificates \
 && rm -rf /var/lib/apt/lists/*


WORKDIR /root
RUN git clone https://github.com/libgit2/libgit2.git \
 && cd libgit2 \
 && git checkout v1.3.0 \
 \
 && echo "--- Building shared library ---" \
 && cmake -B build-shared -S . \
    -DBUILD_SHARED_LIBS=ON \
    -DCMAKE_BUILD_TYPE=Release \
 && cmake --build build-shared -j$(nproc) \
 && cmake --install build-shared \
 \
 && echo "--- Building static library ---" \
 && cmake -B build-static -S . \
    -DBUILD_SHARED_LIBS=OFF \
    -DCMAKE_BUILD_TYPE=Release \
 && cmake --build build-static -j$(nproc) \
 && cmake --install build-static \
 \
 && ldconfig

ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

WORKDIR /go/src/github.com/omegaup/quark
COPY go.mod go.sum ./
RUN go mod download

Docker.build

FROM omegaup/quark-prebuild

WORKDIR /go/src/github.com/omegaup/quark

COPY go.mod go.sum ./
RUN go mod download

COPY . .

ENV STATIC_LIBS="-lgit2 -lssl -lcrypto -ldl -lssh2 -lgcrypt -lgpg-error -lz"

RUN go test -c github.com/omegaup/quark/common -o bin/common_test && \
    go test -c github.com/omegaup/quark/runner -o bin/runner_test && \
    go test -c github.com/omegaup/quark/grader -o bin/grader_test && \
    go build --ldflags "-extldflags \"-static ${STATIC_LIBS}\"" -o bin/grader github.com/omegaup/quark/cmd/omegaup-grader && \
    go build --ldflags "-extldflags \"-static ${STATIC_LIBS}\"" -o bin/validator github.com/omegaup/quark/cmd/validator && \
    go build --ldflags "-extldflags \"-static ${STATIC_LIBS} -lpthread\"" -o bin/benchmark github.com/omegaup/quark/cmd/benchmark && \
    go build --ldflags "-extldflags \"-static ${STATIC_LIBS} -lpthread\"" -o bin/runner github.com/omegaup/quark/cmd/omegaup-runner

I’m happy to update the existing Dockerfile instead if that’s preferred, and can merge these changes there while ensuring nothing else breaks.

@heduenas
Copy link
Copy Markdown
Member

Thanks for the detailed context @pratham15541! Sounds good to keep these changes in a separate file and I don't think we need to worry about different architectures, at least for now.

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.

Fix Docker build: replace outdated prebuild image with reproducible Go + libgit2 setup

3 participants