Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
DOCKER ?= docker
MKDIR ?= mkdir
TR ?= tr
CC ?= cc
DIST_DIR ?= $(CURDIR)/dist

include $(CURDIR)/common.mk
Expand All @@ -40,6 +41,7 @@ DOCKERFILE_DEVEL ?= "images/devel/Dockerfile"
DOCKERFILE_CONTEXT ?= "https://github.com/NVIDIA/k8s-test-infra.git"

GOOS ?= linux
GOARCH ?= $(shell uname -m | sed -e 's,aarch64,arm64,' -e 's,x86_64,amd64,')
ifeq ($(VERSION),)
CLI_VERSION = $(LIB_VERSION)$(if $(LIB_TAG),-$(LIB_TAG))
else
Expand All @@ -53,15 +55,16 @@ cmd-%: COMMAND_BUILD_OPTIONS = -o $(PREFIX)/$(*)
endif
cmds: $(CMD_TARGETS)
$(CMD_TARGETS): cmd-%:
CGO_LDFLAGS_ALLOW='-Wl,--unresolved-symbols=ignore-in-object-files' GOOS=$(GOOS) \
CGO_LDFLAGS_ALLOW='-Wl,--unresolved-symbols=ignore-in-object-files' \
CC=$(CC) CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) \
go build -ldflags "-s -w -X $(CLI_VERSION_PACKAGE).gitCommit=$(GIT_COMMIT) -X $(CLI_VERSION_PACKAGE).version=$(CLI_VERSION)" $(COMMAND_BUILD_OPTIONS) $(MODULE)/cmd/$(*)

build:
GOOS=$(GOOS) go build ./...
CC=$(CC) GOOS=$(GOOS) GOARCH=$(GOARCH) go build ./...

examples: $(EXAMPLE_TARGETS)
$(EXAMPLE_TARGETS): example-%:
GOOS=$(GOOS) go build ./examples/$(*)
CC=$(CC) GOOS=$(GOOS) GOARCH=$(GOARCH) go build ./examples/$(*)

all: check test build binaries
check: $(CHECK_TARGETS)
Expand Down
14 changes: 3 additions & 11 deletions deployments/container/Dockerfile.ubi8
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,16 @@ ARG GOLANG_VERSION=1.23.1
ARG CUDA_IMAGE=cuda
ARG CUDA_VERSION=11.8.0
ARG BASE_DIST=ubi8
FROM nvidia/cuda:${CUDA_VERSION}-base-${BASE_DIST} as build
FROM --platform=${TARGETARCH} nvidia/cuda:${CUDA_VERSION}-base-${BASE_DIST} as build

RUN yum install -y \
wget make git gcc \
&& \
rm -rf /var/cache/yum/*

ARG TARGETARCH
ARG GOLANG_VERSION=x.x.x
RUN set -eux; \
\
arch="$(uname -m)"; \
case "${arch##*-}" in \
x86_64 | amd64) ARCH='amd64' ;; \
ppc64el | ppc64le) ARCH='ppc64le' ;; \
aarch64 | arm64) ARCH='arm64' ;; \
*) echo "unsupported architecture" ; exit 1 ;; \
esac; \
wget -nv -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${ARCH}.tar.gz \
RUN wget -nv -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${TARGETARCH}.tar.gz \
| tar -C /usr/local -xz

ENV GOPATH /go
Expand Down
23 changes: 10 additions & 13 deletions deployments/container/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,15 @@ ARG GOLANG_VERSION=1.23.1
ARG CUDA_IMAGE=cuda
ARG CUDA_VERSION=11.8.0
ARG BASE_DIST=ubuntu20.04
FROM nvidia/cuda:${CUDA_VERSION}-base-${BASE_DIST} as build
FROM --platform=${BUILDOS}/amd64 nvidia/cuda:${CUDA_VERSION}-base-${BASE_DIST} as build

RUN apt-get update && \
apt-get install -y wget make git gcc \
apt-get install -y wget make git gcc-aarch64-linux-gnu gcc \
&& \
rm -rf /var/lib/apt/lists/*

ARG GOLANG_VERSION=x.x.x
RUN set -eux; \
\
arch="$(uname -m)"; \
case "${arch##*-}" in \
x86_64 | amd64) ARCH='amd64' ;; \
ppc64el | ppc64le) ARCH='ppc64le' ;; \
aarch64 | arm64) ARCH='arm64' ;; \
*) echo "unsupported architecture" ; exit 1 ;; \
esac; \
wget -nv -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${ARCH}.tar.gz \
RUN wget -nv -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-amd64.tar.gz \
| tar -C /usr/local -xz

ENV GOPATH /go
Expand All @@ -42,10 +33,16 @@ ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
WORKDIR /build
COPY . .

ARG TARGETARCH
RUN mkdir /artifacts
ARG VERSION="N/A"
ARG GIT_COMMIT="unknown"
RUN make PREFIX=/artifacts cmds
RUN if [ "$TARGETARCH" = "amd64" ]; then \
cc=gcc; \
elif [ "$TARGETARCH" = "arm64" ]; then \
cc=aarch64-linux-gnu-gcc; \
fi && \
make CC=${cc} GOARCH=${TARGETARCH} PREFIX=/artifacts cmds

FROM nvidia/${CUDA_IMAGE}:${CUDA_VERSION}-base-${BASE_DIST}

Expand Down
3 changes: 2 additions & 1 deletion deployments/container/native-only.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# limitations under the License.

PUSH_ON_BUILD ?= false
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/amd64
ARCH ?= $(shell uname -m | sed -e 's,aarch64,arm64,' -e 's,x86_64,amd64,')
DOCKER_BUILD_PLATFORM_OPTIONS = --platform=linux/$(ARCH)

ifeq ($(PUSH_ON_BUILD),true)
$(BUILD_TARGETS): build-%: image-%
Expand Down