Skip to content

Commit

Permalink
Merge pull request #12 from SataQiu/rework-make
Browse files Browse the repository at this point in the history
Code cleanup and fix the bug that the default make goal can not work
  • Loading branch information
archlitchi authored Aug 12, 2024
2 parents 3f3a5f1 + 4264988 commit 18eb946
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 141 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ jobs:
id: buildx
uses: docker/setup-buildx-action@v1

- run: make vgpu
- run: TAG_VERSION="${BRANCH_NAME}" make push-vgpu-tag
- run: VERSION="${BRANCH_NAME}" make ubuntu20.04
- run: VERSION="${BRANCH_NAME}" make push-short
- run: VERSION="${BRANCH_NAME}" make push-latest
38 changes: 9 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,27 @@

DOCKER ?= docker
REGISTRY ?= projecthami
VERSION ?= latest
TAG_VERSION ?= 1.0.0
VERSION ?= 1.0.0

##### Public rules #####

all: ubuntu20.04 centos7
all: ubuntu20.04

push:
$(DOCKER) push "$(REGISTRY)/volcano-device-plugin:$(VERSION)-ubuntu20.04"
$(DOCKER) push "$(REGISTRY)/volcano-device-plugin:$(VERSION)-centos7"
$(DOCKER) push "$(REGISTRY)/volcano-vgpu-device-plugin:$(VERSION)-ubuntu20.04"

push-short:
$(DOCKER) tag "$(REGISTRY)/volcano-device-plugin:$(VERSION)-ubuntu20.04" "$(REGISTRY)/volcano-device-plugin:$(VERSION)"
$(DOCKER) push "$(REGISTRY)/volcano-device-plugin:$(VERSION)"
$(DOCKER) tag "$(REGISTRY)/volcano-vgpu-device-plugin:$(VERSION)-ubuntu20.04" "$(REGISTRY)/volcano-vgpu-device-plugin:$(VERSION)"
$(DOCKER) push "$(REGISTRY)/volcano-vgpu-device-plugin:$(VERSION)"

push-latest:
$(DOCKER) tag "$(REGISTRY)/volcano-device-plugin:$(VERSION)-ubuntu20.04" "$(REGISTRY)/volcano-device-plugin:latest"
$(DOCKER) push "$(REGISTRY)/volcano-device-plugin:latest"

push-tag:
$(DOCKER) tag "$(REGISTRY)/volcano-device-plugin:$(VERSION)-ubuntu20.04" "$(REGISTRY)/volcano-device-plugin:$(TAG_VERSION)"
$(DOCKER) push "$(REGISTRY)/volcano-device-plugin:$(TAG_VERSION)"

push-vgpu-tag:
$(DOCKER) tag "$(REGISTRY)/volcano-vgpu-device-plugin:$(VERSION)-ubuntu20.04" "$(REGISTRY)/volcano-vgpu-device-plugin:$(TAG_VERSION)"
$(DOCKER) push "$(REGISTRY)/volcano-vgpu-device-plugin:$(TAG_VERSION)"
$(DOCKER) tag "$(REGISTRY)/volcano-vgpu-device-plugin:$(VERSION)-ubuntu20.04" "$(REGISTRY)/volcano-vgpu-device-plugin:latest"
$(DOCKER) push "$(REGISTRY)/volcano-vgpu-device-plugin:latest"

ubuntu20.04:
$(DOCKER) build --pull \
--tag $(REGISTRY)/volcano-device-plugin:$(VERSION)-ubuntu20.04 \
--file docker/amd64/Dockerfile.ubuntu20.04 .

vgpu:
$(DOCKER) build --pull \
--tag $(REGISTRY)/volcano-vgpu-device-plugin:$(VERSION)-ubuntu20.04 \
--file docker/amd64/Dockerfile.vgpu-ubuntu20.04 .

centos7:
$(DOCKER) build --pull \
--tag $(REGISTRY)/volcano-device-plugin:$(VERSION)-centos7 \
--file docker/amd64/Dockerfile.centos7 .
--file docker/amd64/Dockerfile.ubuntu20.04 .

include Makefile.def

Expand All @@ -74,4 +54,4 @@ init:

gen_bin: init
go get github.com/mitchellh/gox
CGO_ENABLED=1 gox -osarch=${REL_OSARCH} -ldflags ${LD_FLAGS} -output ${BIN_DIR}/${REL_OSARCH}/volcano-device-plugin cmd/vgpu
CGO_ENABLED=1 gox -osarch=${REL_OSARCH} -ldflags ${LD_FLAGS} -output ${BIN_DIR}/${REL_OSARCH}/volcano-vgpu-device-plugin ./cmd/vgpu
43 changes: 0 additions & 43 deletions docker/amd64/Dockerfile.centos7

This file was deleted.

32 changes: 24 additions & 8 deletions docker/amd64/Dockerfile.ubuntu20.04
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,48 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM ubuntu:20.04 as build
ARG NVIDIA_IMAGE=nvidia/cuda:12.2.0-devel-ubuntu20.04
ARG GOLANG_VERSION=1.19.3

FROM ubuntu:20.04 as build
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
ca-certificates \
wget && \
rm -rf /var/lib/apt/lists/*

ENV GOLANG_VERSION 1.19.3
RUN wget -nv -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-amd64.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
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH

WORKDIR /go/src/volcano.sh/devices
COPY . .

RUN go env -w GO111MODULE=on
RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN export CGO_LDFLAGS_ALLOW='-Wl,--unresolved-symbols=ignore-in-object-files' && \
go build -ldflags="-s -w" -o volcano-device-plugin

go build -ldflags="-s -w" -o volcano-vgpu-device-plugin ./cmd/vgpu

FROM $NVIDIA_IMAGE AS NVBUILD
COPY ./libvgpu /libvgpu
WORKDIR /libvgpu
RUN apt-get -y update; apt-get -y install wget
RUN wget https://cmake.org/files/v3.19/cmake-3.19.8-Linux-x86_64.tar.gz
RUN tar -xf cmake-3.19.8-Linux-x86_64.tar.gz
RUN cp /libvgpu/cmake-3.19.8-Linux-x86_64/bin/cmake /libvgpu/cmake-3.19.8-Linux-x86_64/bin/cmake3
ENV PATH="/libvgpu/cmake-3.19.8-Linux-x86_64/bin:${PATH}"
RUN apt-get -y install openssl libssl-dev
RUN rm -rf /libvgpu/build
RUN bash ./build.sh

FROM debian:stretch-slim

ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=utility

COPY --from=build /go/src/volcano.sh/devices/volcano-device-plugin /usr/bin/volcano-device-plugin
COPY --from=build /go/src/volcano.sh/devices/volcano-vgpu-device-plugin /usr/bin/volcano-vgpu-device-plugin
RUN mkdir -p /k8s-vgpu/lib/nvidia
COPY --from=build /go/src/volcano.sh/devices/lib/nvidia/ld.so.preload /k8s-vgpu/lib/nvidia/
COPY --from=NVBUILD /libvgpu/build/libvgpu.so /k8s-vgpu/lib/nvidia/

ENTRYPOINT ["volcano-device-plugin"]
ENTRYPOINT ["volcano-vgpu-device-plugin"]
59 changes: 0 additions & 59 deletions docker/amd64/Dockerfile.vgpu-ubuntu20.04

This file was deleted.

0 comments on commit 18eb946

Please sign in to comment.