mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-28 06:52:34 +00:00
Add binary target and use go mod
Signed-off-by: Renaud Gaubert <rgaubert@nvidia.com>
This commit is contained in:
parent
60f165ad69
commit
87c8a868f9
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.git
|
||||||
|
dist
|
14
Makefile
14
Makefile
@ -1,18 +1,24 @@
|
|||||||
# Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved.
|
# Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
|
||||||
DOCKER ?= docker
|
DOCKER ?= docker
|
||||||
MKDIR ?= mkdir
|
MKDIR ?= mkdir
|
||||||
REGISTRY ?= nvidia/toolkit
|
REGISTRY ?= nvidia/container-toolkit
|
||||||
|
|
||||||
GOLANG_VERSION := 1.10.3
|
GOLANG_VERSION := 1.14.2
|
||||||
VERSION := 1.0.5
|
VERSION := 1.0.5
|
||||||
DIST_DIR := $(CURDIR)/dist
|
DIST_DIR := $(CURDIR)/dist
|
||||||
|
|
||||||
.NOTPARALLEL:
|
TOOLKIT=nvidia-container-toolkit
|
||||||
|
|
||||||
|
include $(CURDIR)/docker.mk
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
|
|
||||||
all: ubuntu18.04 ubuntu16.04 debian10 debian9 centos7 amzn2 amzn1 opensuse-leap15.1
|
all: ubuntu18.04 ubuntu16.04 debian10 debian9 centos7 amzn2 amzn1 opensuse-leap15.1
|
||||||
|
|
||||||
|
binary:
|
||||||
|
go build -ldflags "-s -w" -o "$(TOOLKIT)" github.com/NVIDIA/container-toolkit/pkg
|
||||||
|
|
||||||
push%:
|
push%:
|
||||||
docker push "$(REGISTRY)/$*"
|
docker push "$(REGISTRY)/$*"
|
||||||
|
|
||||||
|
74
docker.mk
Normal file
74
docker.mk
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
# Copyright (c) 2017-2020, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
|
||||||
|
push%:
|
||||||
|
docker push "$(REGISTRY)/$*"
|
||||||
|
|
||||||
|
ubuntu%: ARCH := amd64
|
||||||
|
ubuntu%:
|
||||||
|
$(DOCKER) build --pull \
|
||||||
|
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
|
||||||
|
--build-arg VERSION_ID="$*" \
|
||||||
|
--build-arg PKG_VERS="$(VERSION)" \
|
||||||
|
--build-arg PKG_REV="1" \
|
||||||
|
--tag "$(REGISTRY)/ubuntu$*" \
|
||||||
|
--file docker/Dockerfile.ubuntu .
|
||||||
|
$(MKDIR) -p $(DIST_DIR)/$@/$(ARCH)
|
||||||
|
$(DOCKER) run --cidfile $@.cid "$(REGISTRY)/ubuntu$*"
|
||||||
|
$(DOCKER) cp $$(cat $@.cid):/dist/. $(DIST_DIR)/$@/$(ARCH)/
|
||||||
|
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid
|
||||||
|
|
||||||
|
debian%: ARCH := amd64
|
||||||
|
debian%:
|
||||||
|
$(DOCKER) build --pull \
|
||||||
|
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
|
||||||
|
--build-arg VERSION_ID="$*" \
|
||||||
|
--build-arg PKG_VERS="$(VERSION)" \
|
||||||
|
--build-arg PKG_REV="1" \
|
||||||
|
--tag "$(REGISTRY)/debian$*" \
|
||||||
|
--file docker/Dockerfile.debian .
|
||||||
|
$(MKDIR) -p $(DIST_DIR)/$@/$(ARCH)
|
||||||
|
$(DOCKER) run --cidfile $@.cid "$(REGISTRY)/debian$*"
|
||||||
|
$(DOCKER) cp $$(cat $@.cid):/dist/. $(DIST_DIR)/$@/$(ARCH)/
|
||||||
|
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid
|
||||||
|
|
||||||
|
centos%: ARCH := x86_64
|
||||||
|
centos%:
|
||||||
|
$(DOCKER) build --pull \
|
||||||
|
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
|
||||||
|
--build-arg VERSION_ID="$*" \
|
||||||
|
--build-arg PKG_VERS="$(VERSION)" \
|
||||||
|
--build-arg PKG_REV="2" \
|
||||||
|
--tag "$(REGISTRY)/centos$*" \
|
||||||
|
--file docker/Dockerfile.centos .
|
||||||
|
$(MKDIR) -p $(DIST_DIR)/$@/$(ARCH)
|
||||||
|
$(DOCKER) run --cidfile $@.cid "$(REGISTRY)/centos$*"
|
||||||
|
$(DOCKER) cp $$(cat $@.cid):/dist/. $(DIST_DIR)/$@/$(ARCH)/
|
||||||
|
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid
|
||||||
|
|
||||||
|
amzn%: ARCH := x86_64
|
||||||
|
amzn%:
|
||||||
|
$(DOCKER) build --pull \
|
||||||
|
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
|
||||||
|
--build-arg VERSION_ID="$*" \
|
||||||
|
--build-arg PKG_VERS="$(VERSION)" \
|
||||||
|
--build-arg PKG_REV="2.amzn$*" \
|
||||||
|
--tag "$(REGISTRY)/amzn$*" \
|
||||||
|
--file docker/Dockerfile.amzn .
|
||||||
|
$(MKDIR) -p $(DIST_DIR)/$@/$(ARCH)
|
||||||
|
$(DOCKER) run --cidfile $@.cid "$(REGISTRY)/amzn$*"
|
||||||
|
$(DOCKER) cp $$(cat $@.cid):/dist/. $(DIST_DIR)/$@/$(ARCH)/
|
||||||
|
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid
|
||||||
|
|
||||||
|
opensuse-leap%: ARCH := x86_64
|
||||||
|
opensuse-leap%:
|
||||||
|
$(DOCKER) build --pull \
|
||||||
|
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
|
||||||
|
--build-arg VERSION_ID="$*" \
|
||||||
|
--build-arg PKG_VERS="$(VERSION)" \
|
||||||
|
--build-arg PKG_REV="1" \
|
||||||
|
--tag "$(REGISTRY)/opensuse-leap$*" \
|
||||||
|
--file docker/Dockerfile.opensuse-leap .
|
||||||
|
$(MKDIR) -p $(DIST_DIR)/$@/$(ARCH)
|
||||||
|
$(DOCKER) run --cidfile $@.cid "$(REGISTRY)/opensuse-leap$*"
|
||||||
|
$(DOCKER) cp $$(cat $@.cid):/dist/. $(DIST_DIR)/$@/$(ARCH)/
|
||||||
|
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid
|
@ -37,10 +37,11 @@ ENV DIST_DIR=/tmp/nvidia-container-toolkit-$PKG_VERS/SOURCES
|
|||||||
RUN mkdir -p $DIST_DIR /dist
|
RUN mkdir -p $DIST_DIR /dist
|
||||||
|
|
||||||
# nvidia-container-toolkit
|
# nvidia-container-toolkit
|
||||||
COPY nvidia-container-toolkit/ $GOPATH/src/nvidia-container-toolkit
|
WORKDIR $GOPATH/src/nvidia-container-toolkit
|
||||||
|
COPY . .
|
||||||
|
|
||||||
RUN go get -ldflags "-s -w" -v nvidia-container-toolkit && \
|
RUN make binary && \
|
||||||
mv $GOPATH/bin/nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit
|
mv ./nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit
|
||||||
|
|
||||||
COPY config/config.toml.amzn $DIST_DIR/config.toml
|
COPY config/config.toml.amzn $DIST_DIR/config.toml
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ COPY oci-nvidia-hook $DIST_DIR/oci-nvidia-hook
|
|||||||
COPY oci-nvidia-hook.json $DIST_DIR/oci-nvidia-hook.json
|
COPY oci-nvidia-hook.json $DIST_DIR/oci-nvidia-hook.json
|
||||||
|
|
||||||
WORKDIR $DIST_DIR/..
|
WORKDIR $DIST_DIR/..
|
||||||
COPY pkg/rpm .
|
COPY packaging/rpm .
|
||||||
|
|
||||||
CMD arch=$(uname -m) && \
|
CMD arch=$(uname -m) && \
|
||||||
rpmbuild --clean --target=$arch -bb \
|
rpmbuild --clean --target=$arch -bb \
|
||||||
|
@ -5,6 +5,7 @@ RUN yum install -y \
|
|||||||
ca-certificates \
|
ca-certificates \
|
||||||
wget \
|
wget \
|
||||||
git \
|
git \
|
||||||
|
make \
|
||||||
rpm-build && \
|
rpm-build && \
|
||||||
rm -rf /var/cache/yum/*
|
rm -rf /var/cache/yum/*
|
||||||
|
|
||||||
@ -36,10 +37,11 @@ ENV DIST_DIR=/tmp/nvidia-container-toolkit-$PKG_VERS/SOURCES
|
|||||||
RUN mkdir -p $DIST_DIR /dist
|
RUN mkdir -p $DIST_DIR /dist
|
||||||
|
|
||||||
# nvidia-container-toolkit
|
# nvidia-container-toolkit
|
||||||
COPY nvidia-container-toolkit/ $GOPATH/src/nvidia-container-toolkit
|
WORKDIR $GOPATH/src/nvidia-container-toolkit
|
||||||
|
COPY . .
|
||||||
|
|
||||||
RUN go get -ldflags "-s -w" -v nvidia-container-toolkit && \
|
RUN make binary && \
|
||||||
mv $GOPATH/bin/nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit
|
mv ./nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit
|
||||||
|
|
||||||
COPY config/config.toml.centos $DIST_DIR/config.toml
|
COPY config/config.toml.centos $DIST_DIR/config.toml
|
||||||
|
|
||||||
@ -50,7 +52,7 @@ COPY oci-nvidia-hook $DIST_DIR/oci-nvidia-hook
|
|||||||
COPY oci-nvidia-hook.json $DIST_DIR/oci-nvidia-hook.json
|
COPY oci-nvidia-hook.json $DIST_DIR/oci-nvidia-hook.json
|
||||||
|
|
||||||
WORKDIR $DIST_DIR/..
|
WORKDIR $DIST_DIR/..
|
||||||
COPY pkg/rpm .
|
COPY packaging/rpm .
|
||||||
|
|
||||||
CMD arch=$(uname -m) && \
|
CMD arch=$(uname -m) && \
|
||||||
rpmbuild --clean --target=$arch -bb \
|
rpmbuild --clean --target=$arch -bb \
|
||||||
|
@ -44,10 +44,11 @@ ENV DIST_DIR=/tmp/nvidia-container-toolkit-$PKG_VERS
|
|||||||
RUN mkdir -p $DIST_DIR /dist
|
RUN mkdir -p $DIST_DIR /dist
|
||||||
|
|
||||||
# nvidia-container-toolkit
|
# nvidia-container-toolkit
|
||||||
COPY nvidia-container-toolkit/ $GOPATH/src/nvidia-container-toolkit
|
WORKDIR $GOPATH/src/nvidia-container-toolkit
|
||||||
|
COPY . .
|
||||||
|
|
||||||
RUN go get -ldflags "-s -w" -v nvidia-container-toolkit && \
|
RUN make binary && \
|
||||||
mv $GOPATH/bin/nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit
|
mv ./nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit
|
||||||
|
|
||||||
COPY config/config.toml.debian $DIST_DIR/config.toml
|
COPY config/config.toml.debian $DIST_DIR/config.toml
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ RUN if [ "$(lsb_release -cs)" = "jessie" ]; then \
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
WORKDIR $DIST_DIR
|
WORKDIR $DIST_DIR
|
||||||
COPY pkg/debian ./debian
|
COPY packaging/debian ./debian
|
||||||
|
|
||||||
RUN sed -i "s;@VERSION@;${REVISION};" debian/changelog && \
|
RUN sed -i "s;@VERSION@;${REVISION};" debian/changelog && \
|
||||||
if [ "$REVISION" != "$(dpkg-parsechangelog --show-field=Version)" ]; then exit 1; fi
|
if [ "$REVISION" != "$(dpkg-parsechangelog --show-field=Version)" ]; then exit 1; fi
|
||||||
|
@ -36,7 +36,11 @@ ENV DIST_DIR=/tmp/nvidia-container-toolkit-$PKG_VERS/SOURCES
|
|||||||
RUN mkdir -p $DIST_DIR /dist
|
RUN mkdir -p $DIST_DIR /dist
|
||||||
|
|
||||||
# nvidia-container-toolkit
|
# nvidia-container-toolkit
|
||||||
COPY nvidia-container-toolkit/ $GOPATH/src/nvidia-container-toolkit
|
WORKDIR $GOPATH/src/nvidia-container-toolkit
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN make binary && \
|
||||||
|
mv ./nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit
|
||||||
|
|
||||||
# Hook for Project Atomic's fork of Docker: https://github.com/projectatomic/docker/tree/docker-1.13.1-rhel#add-dockerhooks-exec-custom-hooks-for-prestartpoststop-containerspatch
|
# Hook for Project Atomic's fork of Docker: https://github.com/projectatomic/docker/tree/docker-1.13.1-rhel#add-dockerhooks-exec-custom-hooks-for-prestartpoststop-containerspatch
|
||||||
COPY oci-nvidia-hook $DIST_DIR/oci-nvidia-hook
|
COPY oci-nvidia-hook $DIST_DIR/oci-nvidia-hook
|
||||||
@ -44,13 +48,10 @@ COPY oci-nvidia-hook $DIST_DIR/oci-nvidia-hook
|
|||||||
# Hook for libpod/CRI-O: https://github.com/containers/libpod/blob/v0.8.5/pkg/hooks/docs/oci-hooks.5.md
|
# Hook for libpod/CRI-O: https://github.com/containers/libpod/blob/v0.8.5/pkg/hooks/docs/oci-hooks.5.md
|
||||||
COPY oci-nvidia-hook.json $DIST_DIR/oci-nvidia-hook.json
|
COPY oci-nvidia-hook.json $DIST_DIR/oci-nvidia-hook.json
|
||||||
|
|
||||||
RUN go get -ldflags "-s -w" -v nvidia-container-toolkit && \
|
|
||||||
mv $GOPATH/bin/nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit
|
|
||||||
|
|
||||||
COPY config/config.toml.opensuse-leap $DIST_DIR/config.toml
|
COPY config/config.toml.opensuse-leap $DIST_DIR/config.toml
|
||||||
|
|
||||||
WORKDIR $DIST_DIR/..
|
WORKDIR $DIST_DIR/..
|
||||||
COPY pkg/rpm .
|
COPY packaging/rpm .
|
||||||
|
|
||||||
CMD arch=$(uname -m) && \
|
CMD arch=$(uname -m) && \
|
||||||
rpmbuild --clean --target=$arch -bb \
|
rpmbuild --clean --target=$arch -bb \
|
||||||
|
@ -42,15 +42,16 @@ ENV DIST_DIR=/tmp/nvidia-container-toolkit-$PKG_VERS
|
|||||||
RUN mkdir -p $DIST_DIR /dist
|
RUN mkdir -p $DIST_DIR /dist
|
||||||
|
|
||||||
# nvidia-container-toolkit
|
# nvidia-container-toolkit
|
||||||
COPY nvidia-container-toolkit/ $GOPATH/src/nvidia-container-toolkit
|
WORKDIR $GOPATH/src/nvidia-container-toolkit
|
||||||
|
COPY . .
|
||||||
|
|
||||||
RUN go get -ldflags "-s -w" -v nvidia-container-toolkit && \
|
RUN make binary && \
|
||||||
mv $GOPATH/bin/nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit
|
mv ./nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit
|
||||||
|
|
||||||
COPY config/config.toml.ubuntu $DIST_DIR/config.toml
|
COPY config/config.toml.ubuntu $DIST_DIR/config.toml
|
||||||
|
|
||||||
WORKDIR $DIST_DIR
|
WORKDIR $DIST_DIR
|
||||||
COPY pkg/debian ./debian
|
COPY packaging/debian ./debian
|
||||||
|
|
||||||
RUN sed -i "s;@VERSION@;${REVISION};" debian/changelog && \
|
RUN sed -i "s;@VERSION@;${REVISION};" debian/changelog && \
|
||||||
if [ "$REVISION" != "$(dpkg-parsechangelog --show-field=Version)" ]; then exit 1; fi
|
if [ "$REVISION" != "$(dpkg-parsechangelog --show-field=Version)" ]; then exit 1; fi
|
||||||
|
5
go.mod
Normal file
5
go.mod
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module github.com/NVIDIA/container-toolkit
|
||||||
|
|
||||||
|
go 1.14
|
||||||
|
|
||||||
|
require github.com/BurntSushi/toml v0.3.1
|
2
go.sum
Normal file
2
go.sum
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||||
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
BIN
pkg/container-toolkit
Executable file
BIN
pkg/container-toolkit
Executable file
Binary file not shown.
3
vendor/modules.txt
vendored
Normal file
3
vendor/modules.txt
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# github.com/BurntSushi/toml v0.3.1
|
||||||
|
## explicit
|
||||||
|
github.com/BurntSushi/toml
|
Loading…
Reference in New Issue
Block a user