Skip to content

Commit 6f4a5a3

Browse files
author
Renaud Gaubert
committed
Init
Signed-off-by: Renaud Gaubert <[email protected]>
0 parents  commit 6f4a5a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4811
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
*.swp
3+
*.swo

.gitlab-ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
stages:
2+
- build
3+
4+
.build_template: &build_definition
5+
stage: build
6+
script:
7+
- OS="${CI_JOB_NAME#*:}"
8+
- make REGISTRY=${CI_REGISTRY_IMAGE} ${OS}
9+
- make REGISTRY=${CI_REGISTRY_IMAGE} push-${OS}
10+
artifacts:
11+
expire_in: 1 week
12+
paths:
13+
- dist/
14+
15+
amd64:amzn1
16+
<<: *build_definition
17+
18+
amd64:amzn2
19+
<<: *build_definition
20+
21+
amd64:centos7:
22+
<<: *build_definition
23+
24+
amd64:opensuse-leap15.1
25+
<<: *build_definition
26+
27+
amd64:debian9
28+
<<: *build_definition
29+
30+
amd64:debian10
31+
<<: *build_definition
32+
33+
amd64:ubuntu16.04
34+
<<: *build_definition
35+
36+
amd64:ubuntu18.04
37+
<<: *build_definition

Makefile

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved.
2+
3+
DOCKER ?= docker
4+
MKDIR ?= mkdir
5+
REGISTRY ?= nvidia/toolkit
6+
7+
GOLANG_VERSION := 1.10.3
8+
VERSION := 1.0.5
9+
DIST_DIR := $(CURDIR)/dist
10+
11+
.NOTPARALLEL:
12+
.PHONY: all
13+
14+
all: ubuntu18.04 ubuntu16.04 debian10 debian9 centos7 amzn2 amzn1 opensuse-leap15.1
15+
16+
push%:
17+
docker push "$(REGISTRY)/ubuntu:$*"
18+
19+
ubuntu%: ARCH := amd64
20+
ubuntu%:
21+
$(DOCKER) build --pull \
22+
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
23+
--build-arg VERSION_ID="$*" \
24+
--build-arg PKG_VERS="$(VERSION)" \
25+
--build-arg PKG_REV="1" \
26+
--tag "$(REGISTRY)/ubuntu:$*" \
27+
--file docker/Dockerfile.ubuntu .
28+
$(MKDIR) -p $(DIST_DIR)/$@/$(ARCH)
29+
$(DOCKER) run --cidfile $@.cid "$(REGISTRY)/ubuntu:$*"
30+
$(DOCKER) cp $$(cat $@.cid):/dist/. $(DIST_DIR)/$@/$(ARCH)/
31+
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid
32+
33+
debian%: ARCH := amd64
34+
debian%:
35+
$(DOCKER) build --pull \
36+
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
37+
--build-arg VERSION_ID="$*" \
38+
--build-arg PKG_VERS="$(VERSION)" \
39+
--build-arg PKG_REV="1" \
40+
--tag "$(REGISTRY)/debian:$*" \
41+
--file docker/Dockerfile.debian .
42+
$(MKDIR) -p $(DIST_DIR)/$@/$(ARCH)
43+
$(DOCKER) run --cidfile $@.cid "$(REGISTRY)/debian:$*"
44+
$(DOCKER) cp $$(cat $@.cid):/dist/. $(DIST_DIR)/$@/$(ARCH)/
45+
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid
46+
47+
centos%: ARCH := x86_64
48+
centos%:
49+
$(DOCKER) build --pull \
50+
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
51+
--build-arg VERSION_ID="$*" \
52+
--build-arg PKG_VERS="$(VERSION)" \
53+
--build-arg PKG_REV="2" \
54+
--tag "$(REGISTRY)/centos:$*" \
55+
--file docker/Dockerfile.centos .
56+
$(MKDIR) -p $(DIST_DIR)/$@/$(ARCH)
57+
$(DOCKER) run --cidfile $@.cid "$(REGISTRY)/centos:$*"
58+
$(DOCKER) cp $$(cat $@.cid):/dist/. $(DIST_DIR)/$@/$(ARCH)/
59+
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid
60+
61+
amzn%: ARCH := x86_64
62+
amzn%:
63+
$(DOCKER) build --pull \
64+
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
65+
--build-arg VERSION_ID="$*" \
66+
--build-arg PKG_VERS="$(VERSION)" \
67+
--build-arg PKG_REV="2.amzn$*" \
68+
--tag "$(REGISTRY)/amzn:$*" \
69+
--file docker/Dockerfile.amzn .
70+
$(MKDIR) -p $(DIST_DIR)/$@/$(ARCH)
71+
$(DOCKER) run --cidfile $@.cid "$(REGISTRY)/amzn:$*"
72+
$(DOCKER) cp $$(cat $@.cid):/dist/. $(DIST_DIR)/$@/$(ARCH)/
73+
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid
74+
75+
opensuse-leap%: ARCH := x86_64
76+
opensuse-leap%:
77+
$(DOCKER) build --pull \
78+
--build-arg GOLANG_VERSION="$(GOLANG_VERSION)" \
79+
--build-arg VERSION_ID="$*" \
80+
--build-arg PKG_VERS="$(VERSION)" \
81+
--build-arg PKG_REV="1" \
82+
--tag "$(REGISTRY)/opensuse-leap:$*" \
83+
--file docker/Dockerfile.opensuse-leap .
84+
$(MKDIR) -p $(DIST_DIR)/$@/$(ARCH)
85+
$(DOCKER) run --cidfile $@.cid "$(REGISTRY)/opensuse-leap:$*"
86+
$(DOCKER) cp $$(cat $@.cid):/dist/. $(DIST_DIR)/$@/$(ARCH)/
87+
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid

config/config.toml.amzn

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
disable-require = false
2+
#swarm-resource = "DOCKER_RESOURCE_GPU"
3+
4+
[nvidia-container-cli]
5+
#root = "/run/nvidia/driver"
6+
#path = "/usr/bin/nvidia-container-cli"
7+
environment = []
8+
#debug = "/var/log/nvidia-container-toolkit.log"
9+
#ldcache = "/etc/ld.so.cache"
10+
load-kmods = true
11+
#no-cgroups = false
12+
#user = "root:video"
13+
ldconfig = "@/sbin/ldconfig"
14+
15+
[nvidia-container-runtime]
16+
#debug = "/var/log/nvidia-container-runtime.log"

config/config.toml.centos

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
disable-require = false
2+
#swarm-resource = "DOCKER_RESOURCE_GPU"
3+
4+
[nvidia-container-cli]
5+
#root = "/run/nvidia/driver"
6+
#path = "/usr/bin/nvidia-container-cli"
7+
environment = []
8+
#debug = "/var/log/nvidia-container-toolkit.log"
9+
#ldcache = "/etc/ld.so.cache"
10+
load-kmods = true
11+
#no-cgroups = false
12+
#user = "root:video"
13+
ldconfig = "@/sbin/ldconfig"
14+
15+
[nvidia-container-runtime]
16+
#debug = "/var/log/nvidia-container-runtime.log"

config/config.toml.debian

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
disable-require = false
2+
#swarm-resource = "DOCKER_RESOURCE_GPU"
3+
4+
[nvidia-container-cli]
5+
#root = "/run/nvidia/driver"
6+
#path = "/usr/bin/nvidia-container-cli"
7+
environment = []
8+
#debug = "/var/log/nvidia-container-toolkit.log"
9+
#ldcache = "/etc/ld.so.cache"
10+
load-kmods = true
11+
#no-cgroups = false
12+
#user = "root:video"
13+
ldconfig = "@/sbin/ldconfig"
14+
15+
[nvidia-container-runtime]
16+
#debug = "/var/log/nvidia-container-runtime.log"

config/config.toml.opensuse-leap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
disable-require = false
2+
#swarm-resource = "DOCKER_RESOURCE_GPU"
3+
4+
[nvidia-container-cli]
5+
#root = "/run/nvidia/driver"
6+
#path = "/usr/bin/nvidia-container-cli"
7+
environment = []
8+
#debug = "/var/log/nvidia-container-toolkit.log"
9+
#ldcache = "/etc/ld.so.cache"
10+
load-kmods = true
11+
#no-cgroups = false
12+
user = "root:video"
13+
ldconfig = "@/sbin/ldconfig"
14+
15+
[nvidia-container-runtime]
16+
#debug = "/var/log/nvidia-container-runtime.log"

config/config.toml.ubuntu

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
disable-require = false
2+
#swarm-resource = "DOCKER_RESOURCE_GPU"
3+
4+
[nvidia-container-cli]
5+
#root = "/run/nvidia/driver"
6+
#path = "/usr/bin/nvidia-container-cli"
7+
environment = []
8+
#debug = "/var/log/nvidia-container-toolkit.log"
9+
#ldcache = "/etc/ld.so.cache"
10+
load-kmods = true
11+
#no-cgroups = false
12+
#user = "root:video"
13+
ldconfig = "@/sbin/ldconfig.real"
14+
15+
[nvidia-container-runtime]
16+
#debug = "/var/log/nvidia-container-runtime.log"

docker/Dockerfile.amzn

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
ARG VERSION_ID
2+
FROM amazonlinux:${VERSION_ID}
3+
4+
RUN yum install -y \
5+
ca-certificates \
6+
wget \
7+
git \
8+
rpm-build \
9+
make && \
10+
rm -rf /var/cache/yum/*
11+
12+
ARG GOLANG_VERSION=0.0.0
13+
RUN set -eux; \
14+
\
15+
arch="$(uname -m)"; \
16+
case "${arch##*-}" in \
17+
x86_64 | amd64) ARCH='amd64' ;; \
18+
ppc64el | ppc64le) ARCH='ppc64le' ;; \
19+
aarch64) ARCH='arm64' ;; \
20+
*) echo "unsupported architecture"; exit 1 ;; \
21+
esac; \
22+
wget -nv -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${ARCH}.tar.gz \
23+
| tar -C /usr/local -xz
24+
25+
ENV GOPATH /go
26+
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
27+
28+
# packaging
29+
ARG PKG_VERS
30+
ARG PKG_REV
31+
32+
ENV VERSION $PKG_VERS
33+
ENV RELEASE $PKG_REV
34+
35+
# output directory
36+
ENV DIST_DIR=/tmp/nvidia-container-toolkit-$PKG_VERS/SOURCES
37+
RUN mkdir -p $DIST_DIR /dist
38+
39+
# nvidia-container-toolkit
40+
COPY nvidia-container-toolkit/ $GOPATH/src/nvidia-container-toolkit
41+
42+
RUN go get -ldflags "-s -w" -v nvidia-container-toolkit && \
43+
mv $GOPATH/bin/nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit
44+
45+
COPY config/config.toml.amzn $DIST_DIR/config.toml
46+
47+
# 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
48+
# This might not be useful on Amazon Linux, but it's simpler to keep the RHEL
49+
# and Amazon Linux packages identical.
50+
COPY oci-nvidia-hook $DIST_DIR/oci-nvidia-hook
51+
52+
# Hook for libpod/CRI-O: https://github.com/containers/libpod/blob/v0.8.5/pkg/hooks/docs/oci-hooks.5.md
53+
COPY oci-nvidia-hook.json $DIST_DIR/oci-nvidia-hook.json
54+
55+
WORKDIR $DIST_DIR/..
56+
COPY pkg/rpm .
57+
58+
CMD arch=$(uname -m) && \
59+
rpmbuild --clean --target=$arch -bb \
60+
-D "_topdir $PWD" \
61+
-D "version $VERSION" \
62+
-D "release $RELEASE" \
63+
SPECS/nvidia-container-toolkit.spec && \
64+
mv RPMS/$arch/*.rpm /dist

docker/Dockerfile.centos

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
ARG VERSION_ID
2+
FROM centos:${VERSION_ID}
3+
4+
RUN yum install -y \
5+
ca-certificates \
6+
wget \
7+
git \
8+
rpm-build && \
9+
rm -rf /var/cache/yum/*
10+
11+
ARG GOLANG_VERSION=0.0.0
12+
RUN set -eux; \
13+
\
14+
arch="$(uname -m)"; \
15+
case "${arch##*-}" in \
16+
x86_64 | amd64) ARCH='amd64' ;; \
17+
ppc64el | ppc64le) ARCH='ppc64le' ;; \
18+
aarch64) ARCH='arm64' ;; \
19+
*) echo "unsupported architecture"; exit 1 ;; \
20+
esac; \
21+
wget -nv -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${ARCH}.tar.gz \
22+
| tar -C /usr/local -xz
23+
24+
ENV GOPATH /go
25+
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
26+
27+
# packaging
28+
ARG PKG_VERS
29+
ARG PKG_REV
30+
31+
ENV VERSION $PKG_VERS
32+
ENV RELEASE $PKG_REV
33+
34+
# output directory
35+
ENV DIST_DIR=/tmp/nvidia-container-toolkit-$PKG_VERS/SOURCES
36+
RUN mkdir -p $DIST_DIR /dist
37+
38+
# nvidia-container-toolkit
39+
COPY nvidia-container-toolkit/ $GOPATH/src/nvidia-container-toolkit
40+
41+
RUN go get -ldflags "-s -w" -v nvidia-container-toolkit && \
42+
mv $GOPATH/bin/nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit
43+
44+
COPY config/config.toml.centos $DIST_DIR/config.toml
45+
46+
# 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
47+
COPY oci-nvidia-hook $DIST_DIR/oci-nvidia-hook
48+
49+
# Hook for libpod/CRI-O: https://github.com/containers/libpod/blob/v0.8.5/pkg/hooks/docs/oci-hooks.5.md
50+
COPY oci-nvidia-hook.json $DIST_DIR/oci-nvidia-hook.json
51+
52+
WORKDIR $DIST_DIR/..
53+
COPY pkg/rpm .
54+
55+
CMD arch=$(uname -m) && \
56+
rpmbuild --clean --target=$arch -bb \
57+
-D "_topdir $PWD" \
58+
-D "version $VERSION" \
59+
-D "release $RELEASE" \
60+
SPECS/nvidia-container-toolkit.spec && \
61+
mv RPMS/$arch/*.rpm /dist

0 commit comments

Comments
 (0)