Skip to content

Commit db0a5fd

Browse files
Merge branch 'docker' into 'master'
Rewrite Docker the docker make system See merge request nvidia/container-toolkit/libnvidia-container!9
2 parents 5823754 + 67e23b5 commit db0a5fd

File tree

7 files changed

+88
-51
lines changed

7 files changed

+88
-51
lines changed

Makefile

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export DEBUG_DIR ?= $(CURDIR)/.debug
3434
#export SECTION ?=
3535

3636
include $(MAKE_DIR)/common.mk
37+
include $(MAKE_DIR)/docker.mk
3738

3839
##### File definitions #####
3940

@@ -299,19 +300,3 @@ rpm: all
299300
$(MKDIR) -p $(DESTDIR)/RPMS && $(LN) -nsf $(DIST_DIR) $(DESTDIR)/RPMS/$(ARCH)
300301
cd $(DESTDIR) && rpmbuild --clean --target=$(ARCH) -bb -D"_topdir $(DESTDIR)" -D"_version $(VERSION)" -D"_major $(MAJOR)" SPECS/*
301302
-cd $(DESTDIR) && rpmlint RPMS/*
302-
303-
304-
docker-%: SHELL:=/bin/bash
305-
docker-%:
306-
image=$* ;\
307-
$(MKDIR) -p $(DIST_DIR)/$${image/:}/$(ARCH) ;\
308-
$(DOCKER) build --network=host \
309-
--build-arg IMAGESPEC=$${image//-//} \
310-
--build-arg USERSPEC=$(UID):$(GID) \
311-
--build-arg WITH_LIBELF=$(WITH_LIBELF) \
312-
--build-arg WITH_TIRPC=$(WITH_TIRPC) \
313-
--build-arg WITH_SECCOMP=$(WITH_SECCOMP) \
314-
-f $(MAKE_DIR)/Dockerfile.$${image%%:*} -t $(LIB_NAME):$${image/:} . && \
315-
$(DOCKER) run --cidfile $*.cid -e DISTRIB -e SECTION $(LIB_NAME):$${image/:} && \
316-
$(DOCKER) cp $$(cat $*.cid):/mnt/. $(DIST_DIR)/$${image/:}/$(ARCH) && \
317-
$(DOCKER) rm $$(cat $*.cid) && rm $*.cid

mk/Dockerfile.amazonlinux

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
ARG IMAGESPEC=amazonlinux:2
2-
FROM ${IMAGESPEC}
3-
ARG IMAGESPEC=amazonlinux:2
1+
ARG VERSION_ID
2+
FROM amazonlinux:${VERSION_ID}
43

54
RUN yum install -y \
65
bzip2 \
@@ -35,12 +34,8 @@ RUN if [ "$WITH_LIBELF" = "no" ]; then \
3534
rm -rf $PWD \
3635
; fi
3736

38-
ARG USERSPEC=0:0
39-
4037
WORKDIR /tmp/libnvidia-container
4138
COPY . .
42-
RUN chown -R $USERSPEC $PWD
43-
USER $USERSPEC
4439

4540
RUN make distclean && make -j"$(nproc)"
4641

mk/Dockerfile.centos

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
ARG IMAGESPEC=centos:7
2-
FROM ${IMAGESPEC}
3-
ARG IMAGESPEC=centos:7
1+
ARG VERSION_ID
2+
FROM centos:${VERSION_ID}
43

54
RUN yum install -y \
65
bzip2 \
@@ -35,12 +34,8 @@ RUN if [ "$WITH_LIBELF" = "no" ]; then \
3534
rm -rf $PWD \
3635
; fi
3736

38-
ARG USERSPEC=0:0
39-
4037
WORKDIR /tmp/libnvidia-container
4138
COPY . .
42-
RUN chown -R $USERSPEC $PWD
43-
USER $USERSPEC
4439

4540
RUN make distclean && make -j"$(nproc)"
4641

mk/Dockerfile.debian

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
ARG IMAGESPEC=debian:9.2
2-
FROM ${IMAGESPEC}
3-
ARG IMAGESPEC=debian:9.2
1+
ARG VERSION_ID
2+
FROM debian:${VERSION_ID}
43

54
RUN apt-get update && apt-get install -y --no-install-recommends \
65
apt-utils \
@@ -26,12 +25,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2625

2726
ENV GPG_TTY /dev/console
2827

29-
ARG USERSPEC=0:0
30-
3128
WORKDIR /tmp/libnvidia-container
3229
COPY . .
33-
RUN chown -R $USERSPEC $PWD
34-
USER $USERSPEC
3530

3631
ARG WITH_LIBELF=no
3732
ARG WITH_TIRPC=no

mk/Dockerfile.opensuse-leap

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
ARG IMAGESPEC=opensuse/leap:15.0
2-
FROM ${IMAGESPEC}
3-
ARG IMAGESPEC=opensuse/leap:15.0
1+
ARG VERSION_ID
2+
FROM opensuse/leap:${VERSION_ID}
43

54
RUN zypper install -y \
65
bmake \
@@ -29,12 +28,8 @@ ENV WITH_LIBELF=${WITH_LIBELF}
2928
ENV WITH_TIRPC=${WITH_TIRPC}
3029
ENV WITH_SECCOMP=${WITH_SECCOMP}
3130

32-
ARG USERSPEC=0:0
33-
3431
WORKDIR /tmp/libnvidia-container
3532
COPY . .
36-
RUN chown -R $USERSPEC $PWD /mnt
37-
USER $USERSPEC
3833

3934
# META_NOECHO=echo is required to work around a bug in Leap 15's version of bmake,
4035
# see also https://github.com/ptt/pttbbs/issues/30

mk/Dockerfile.ubuntu

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
ARG IMAGESPEC=ubuntu:16.04
2-
FROM ${IMAGESPEC}
3-
ARG IMAGESPEC=ubuntu:16.04
1+
ARG VERSION_ID
2+
FROM ubuntu:${VERSION_ID}
43

54
RUN apt-get update && apt-get install -y --no-install-recommends \
65
apt-utils \
@@ -25,12 +24,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2524

2625
ENV GPG_TTY /dev/console
2726

28-
ARG USERSPEC=0:0
29-
3027
WORKDIR /tmp/libnvidia-container
3128
COPY . .
32-
RUN chown -R $USERSPEC $PWD
33-
USER $USERSPEC
3429

3530
ARG WITH_LIBELF=no
3631
ARG WITH_TIRPC=no

mk/docker.mk

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
docker: ubuntu18.04 ubuntu16.04 debian10 debian9 centos7 amzn2 amzn1 opensuse-leap15.1
17+
18+
ubuntu%: SHELL:=/bin/bash
19+
ubuntu%:
20+
$(DOCKER) build --build-arg VERSION_ID=$* \
21+
--build-arg WITH_LIBELF=$(WITH_LIBELF) \
22+
--build-arg WITH_TIRPC=$(WITH_TIRPC) \
23+
--build-arg WITH_SECCOMP=$(WITH_SECCOMP) \
24+
-t nvidia/$(LIB_NAME)/ubuntu:$* -f $(MAKE_DIR)/Dockerfile.ubuntu .
25+
$(MKDIR) -p $(DIST_DIR)/ubuntu$*/$(ARCH)
26+
$(DOCKER) run --cidfile $@.cid -e DISTRIB -e SECTION nvidia/$(LIB_NAME)/ubuntu:$*
27+
$(DOCKER) cp $$(cat $@.cid):/mnt/. $(DIST_DIR)/ubuntu$*/$(ARCH)
28+
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid
29+
30+
debian%: SHELL:=/bin/bash
31+
debian%:
32+
$(DOCKER) build --build-arg VERSION_ID=$* \
33+
--build-arg WITH_LIBELF=$(WITH_LIBELF) \
34+
--build-arg WITH_TIRPC=$(WITH_TIRPC) \
35+
--build-arg WITH_SECCOMP=$(WITH_SECCOMP) \
36+
-t nvidia/$(LIB_NAME)/debian:$* -f $(MAKE_DIR)/Dockerfile.debian .
37+
$(MKDIR) -p $(DIST_DIR)/debian$*/$(ARCH)
38+
$(DOCKER) run --cidfile $@.cid -e DISTRIB -e SECTION nvidia/$(LIB_NAME)/debian:$*
39+
$(DOCKER) cp $$(cat $@.cid):/mnt/. $(DIST_DIR)/debian$*/$(ARCH)
40+
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid
41+
42+
centos%: SHELL:=/bin/bash
43+
centos%:
44+
$(DOCKER) build --build-arg VERSION_ID=$* \
45+
--build-arg WITH_LIBELF=$(WITH_LIBELF) \
46+
--build-arg WITH_TIRPC=$(WITH_TIRPC) \
47+
--build-arg WITH_SECCOMP=$(WITH_SECCOMP) \
48+
-t nvidia/$(LIB_NAME)/centos:$* -f $(MAKE_DIR)/Dockerfile.centos .
49+
$(MKDIR) -p $(DIST_DIR)/centos$*/$(ARCH)
50+
$(DOCKER) run --cidfile $@.cid -e DISTRIB -e SECTION nvidia/$(LIB_NAME)/centos:$*
51+
$(DOCKER) cp $$(cat $@.cid):/mnt/. $(DIST_DIR)/centos$*/$(ARCH)
52+
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid
53+
54+
amazonlinux%: SHELL:=/bin/bash
55+
amazonlinux%:
56+
$(DOCKER) build --build-arg VERSION_ID=$* \
57+
--build-arg WITH_LIBELF=$(WITH_LIBELF) \
58+
--build-arg WITH_TIRPC=$(WITH_TIRPC) \
59+
--build-arg WITH_SECCOMP=$(WITH_SECCOMP) \
60+
-t nvidia/$(LIB_NAME)/amazonlinux:$* -f $(MAKE_DIR)/Dockerfile.amazonlinux .
61+
$(MKDIR) -p $(DIST_DIR)/amazonlinux$*/$(ARCH)
62+
$(DOCKER) run --cidfile $@.cid -e DISTRIB -e SECTION nvidia/$(LIB_NAME)/amazonlinux:$*
63+
$(DOCKER) cp $$(cat $@.cid):/mnt/. $(DIST_DIR)/amazonlinux$*/$(ARCH)
64+
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid
65+
66+
67+
opensuse-leap%: SHELL:=/bin/bash
68+
opensuse-leap%:
69+
$(DOCKER) build --build-arg VERSION_ID=$* \
70+
--build-arg WITH_LIBELF=$(WITH_LIBELF) \
71+
--build-arg WITH_TIRPC=$(WITH_TIRPC) \
72+
--build-arg WITH_SECCOMP=$(WITH_SECCOMP) \
73+
-t nvidia/$(LIB_NAME)/opensuse-leap:$* -f $(MAKE_DIR)/Dockerfile.opensuse-leap .
74+
$(MKDIR) -p $(DIST_DIR)/opensuse-leap$*/$(ARCH)
75+
$(DOCKER) run --cidfile $@.cid -e DISTRIB -e SECTION nvidia/$(LIB_NAME)/opensuse-leap:$*
76+
$(DOCKER) cp $$(cat $@.cid):/mnt/. $(DIST_DIR)/opensuse-leap$*/$(ARCH)
77+
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid

0 commit comments

Comments
 (0)