Skip to content

Commit a8b33ba

Browse files
committed
Fix antrea-ubi image build
Starting with Go 1.21, the runtime system needs to have a version of glibc "compatible" with the version available at build time. The ubi8 image comes with a very old version of glibc compared to the golang builder, and the Antrea binaries no longer run. To address this, we use the ubi8 image to build Antrea, which means we need to install Go manually. Fixes antrea-io#5722 Signed-off-by: Antonin Bas <[email protected]>
1 parent e144059 commit a8b33ba

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

build/images/Dockerfile.build.ubi

+23-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,30 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
ARG GO_VERSION
1615
ARG BUILD_TAG
17-
FROM golang:${GO_VERSION} as antrea-build
16+
FROM registry.access.redhat.com/ubi8 as antrea-build
17+
18+
ADD https://go.dev/dl/?mode=json&include=all go-versions.json
19+
20+
RUN yum install ca-certificates gcc jq make wget -y
21+
22+
ARG GO_VERSION
23+
24+
# GO_VERSION is a Go minor version, we use the downloaded go-versions.json file
25+
# to identify and install the latest patch release for this minor version.
26+
RUN set -eux; \
27+
arch="$(uname -m)"; \
28+
case "${arch##*-}" in \
29+
x86_64) goArch='amd64' ;; \
30+
arm) goArch='armv6l' ;; \
31+
aarch64) goArch='arm64' ;; \
32+
*) goArch=''; echo >&2; echo >&2 "unsupported architecture '$arch'"; echo >&2 ; exit 1 ;; \
33+
esac; \
34+
GO_ARCHIVE=$(jq --arg version_prefix "go${GO_VERSION}." --arg arch "$goArch" -r '. | map(select(. | .version | startswith($version_prefix))) | first | .files[] | select(.os == "linux" and .arch == $arch and .kind == "archive").filename' go-versions.json); \
35+
wget -q -O - https://go.dev/dl/${GO_ARCHIVE} | tar xz -C /usr/local/
36+
37+
# Using ENV makes the change persistent, but this is just a builder image.
38+
ENV PATH /usr/local/go/bin:$PATH
1839

1940
WORKDIR /antrea
2041

0 commit comments

Comments
 (0)