Skip to content

Commit

Permalink
tidy up template
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrokethecloud committed Apr 24, 2024
1 parent 84e640c commit 5939ee3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/template-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
15 changes: 14 additions & 1 deletion package/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
3 changes: 2 additions & 1 deletion scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions scripts/package
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ 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
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}

0 comments on commit 5939ee3

Please sign in to comment.