1- # Configurable base image - must be declared before any FROM statement
2- # Defaults to Oracle Linux 10 for OCI SDK compatibility
3- # Can be overridden with --build-arg BASE_IMAGE=ubuntu:24.04
4- # Note: Ubuntu 22.04 has glibc 2.35, but golang:1.24 requires glibc 2.38+
5- ARG BASE_IMAGE=oraclelinux:10-slim
6-
71# Build the ome-agent binary
82FROM golang:1.24 AS builder
93
@@ -29,75 +23,39 @@ WORKDIR /workspace
2923COPY go.mod go.mod
3024COPY go.sum go.sum
3125
32- # Download dependencies with Go module cache
33- RUN --mount=type=cache,target=/go/pkg/mod \
34- go mod download
35-
36- # Copy XET dependencies from other pkg subdirectories
37- COPY pkg/configutils/ pkg/configutils/
38- COPY pkg/logging/ pkg/logging/
39-
40- # Copy XET package for building with better caching
41- COPY pkg/xet/ pkg/xet/
42-
43- # Download Rust dependencies with cargo cache
44- RUN --mount=type=cache,target=/root/.cargo/registry \
45- --mount=type=cache,target=/root/.cargo/git \
46- cd pkg/xet && cargo fetch
26+ # Download dependencies
27+ RUN go mod download
4728
48- # Build the XET library with cargo build cache
49- RUN --mount=type=cache,target=/root/.cargo/registry \
50- --mount=type=cache,target=/root/.cargo/git \
51- cd pkg/xet && \
52- cargo build --release
53-
54- # Verify static library exists and remove dynamic library to force static linking
55- RUN ls -lh /workspace/pkg/xet/target/release/libxet.* && \
56- rm -f /workspace/pkg/xet/target/release/libxet.so
57-
58- # Copy remaining source code
29+ # Copy source code
5930COPY cmd/ cmd/
6031COPY pkg/ pkg/
6132COPY internal/ internal/
6233
34+ # Build the XET library first
35+ RUN cd pkg/xet && make build
36+
6337# Build arguments for version info
6438ARG VERSION
6539ARG GIT_TAG
6640ARG GIT_COMMIT
6741
6842# Build the ome-agent binary (CGO must be enabled for XET library)
69- RUN --mount=type=cache,target=/root/.cache/go-build \
70- --mount=type=cache,target=/go/pkg/mod \
71- PKG_CONFIG_ALL_STATIC=1 \
72- CGO_ENABLED=1 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} \
43+ RUN CGO_ENABLED=1 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} \
7344 go build -a \
7445 -ldflags "-X github.com/sgl-project/ome/pkg/version.GitVersion=${GIT_TAG} -X github.com/sgl-project/ome/pkg/version.GitCommit=${GIT_COMMIT}" \
7546 -o ome-agent ./cmd/ome-agent
7647
77- # Use the base image specified at the top of the file
78- ARG BASE_IMAGE
79- FROM ${BASE_IMAGE}
80-
81- # Install/update packages and runtime dependencies based on the base image
82- RUN if [ -f /usr/bin/microdnf ]; then \
83- microdnf update -y && \
84- microdnf install -y \
85- glibc \
86- libgcc \
87- libstdc++ \
88- openssl-libs && \
89- microdnf clean all; \
90- elif [ -f /usr/bin/apt-get ]; then \
91- apt-get update && \
92- apt-get install -y \
93- ca-certificates \
94- libc6 \
95- libgcc-s1 \
96- libstdc++6 \
97- libssl3 && \
98- apt-get upgrade -y && \
99- apt-get clean && rm -rf /var/lib/apt/lists/*; \
100- fi
48+ # Use Oracle Linux 10 as base image for OCI SDK compatibility
49+ FROM oraclelinux:10-slim
50+ RUN microdnf update -y && microdnf clean all
51+
52+ # Install runtime dependencies for the XET library
53+ RUN microdnf install -y \
54+ glibc \
55+ libgcc \
56+ libstdc++ \
57+ openssl-libs \
58+ && microdnf clean all
10159
10260COPY --from=builder /workspace/ome-agent /
10361COPY config/ome-agent/ome-agent.yaml /
0 commit comments