diff --git a/.github/workflows/template-build.yml b/.github/workflows/template-build.yml index dc8d4146..4a327967 100644 --- a/.github/workflows/template-build.yml +++ b/.github/workflows/template-build.yml @@ -49,7 +49,8 @@ jobs: with: provenance: false context: . - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 + load: true file: package/Dockerfile push: ${{ inputs.push }} tags: ${{env.imageName}}:${{ inputs.release-tag-name }} diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 3697691a..329d99e3 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -17,6 +17,11 @@ RUN export K8S_VERSION=1.24.2 && \ ## install golangci RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.57.1 +# The docker version in dapper is too old to have buildx. Install it manually. +RUN curl -sSfL https://github.com/docker/buildx/releases/download/v0.13.1/buildx-v0.13.1.linux-${ARCH} -o buildx-v0.13.1.linux-${ARCH} && \ + chmod +x buildx-v0.13.1.linux-${ARCH} && \ + mv buildx-v0.13.1.linux-${ARCH} /usr/local/bin/buildx + ENV GO111MODULE on ENV DAPPER_ENV REPO TAG DRONE_TAG ENV DAPPER_SOURCE /go/src/github.com/harvester/pcidevices/ diff --git a/package/Dockerfile b/package/Dockerfile index d2d61c9f..8f1fd828 100644 --- a/package/Dockerfile +++ b/package/Dockerfile @@ -1,6 +1,19 @@ +# syntax=docker/dockerfile:1.7.0 + FROM registry.suse.com/bci/bci-base:15.5 #awk is needed by sriov-manage utility from nvidia to perform gpu management + RUN zypper -n install pciutils which curl ethtool awk + +ARG TARGETPLATFORM + +RUN if [ "$TARGETPLATFORM" != "linux/amd64" ] && [ "$TARGETPLATFORM" != "linux/arm64" ]; then \ + echo "Error: Unsupported TARGETPLATFORM: $TARGETPLATFORM" && \ + exit 1; \ + fi + +ENV ARCH=${TARGETPLATFORM#linux/} + RUN /sbin/update-pciids -COPY bin/pcidevices /bin/pcidevices +COPY bin/pcidevices-${ARCH} /bin/pcidevices ENTRYPOINT ["pcidevices"] diff --git a/scripts/build b/scripts/build index 6c2ef3d7..56bdcf83 100755 --- a/scripts/build +++ b/scripts/build @@ -7,4 +7,5 @@ cd $(dirname $0)/.. mkdir -p bin [ "$(uname)" != "Darwin" ] && LINKFLAGS="-extldflags -static -s" -CGO_ENABLED=0 go build -ldflags "-X main.VERSION=$VERSION $LINKFLAGS" -o bin/pcidevices +GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.VERSION=$VERSION $LINKFLAGS" -o bin/pcidevices-amd64 +GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "-X main.VERSION=$VERSION $LINKFLAGS" -o bin/pcidevices-arm64 \ No newline at end of file diff --git a/scripts/package b/scripts/package index 48b04f4f..3bc13466 100755 --- a/scripts/package +++ b/scripts/package @@ -16,7 +16,7 @@ if echo $TAG | grep -q dirty; then fi mkdir -p dist/artifacts -cp bin/pcidevices dist/artifacts/pcidevices${SUFFIX} +cp bin/pcidevices${SUFFIX} dist/artifacts/pcidevices${SUFFIX} IMAGE=${REPO}/pcidevices:${TAG} DOCKERFILE=package/Dockerfile @@ -24,5 +24,7 @@ if [ -e ${DOCKERFILE}.${ARCH} ]; then DOCKERFILE=${DOCKERFILE}.${ARCH} fi -docker build -f ${DOCKERFILE} -t ${IMAGE} . +buildx build --load \ + -f ${DOCKERFILE} -t ${IMAGE} . + echo Built ${IMAGE}