提交 fae68d4c 编写于 作者: R Renaud Gaubert

Build the containers in the CI

Signed-off-by: NRenaud Gaubert <rgaubert@nvidia.com>
上级 a0cefeef
variables: image: docker:latest
LICENSE_TAG: $CI_REGISTRY_IMAGE:license
PACKAGE_PATH: /go/src/gitlab.com/${CI_PROJECT_PATH} services:
BUILDER: ${CI_REGISTRY_IMAGE}/builder:${CI_COMMIT_REF_NAME} - docker:dind
BASE: ${CI_REGISTRY_IMAGE}/base
DOCKER_HOST: tcp://docker:2375
stages: stages:
- docker_images
- unit
- integration
- build - build
license-builder: .build_template: &build_definition
image: docker:stable stage: build
stage: docker_images
services:
- docker:stable-dind
only:
changes:
- license/Dockerfile
script: script:
- OS="${CI_JOB_NAME#*:}"
- apk add make
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $LICENSE_TAG ./license - make REGISTRY=${CI_REGISTRY_IMAGE} ${OS}
- docker push $LICENSE_TAG - make REGISTRY=${CI_REGISTRY_IMAGE} push${OS}
artifacts:
expire_in: 1 week
paths:
- dist/
# Build the base images and store in gitlab registry amd64:amzn1:
base-builder: <<: *build_definition
stage: docker_images
image: docker:stable
services:
- docker:stable-dind
only:
changes:
- base/*
before_script:
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
- apk add --update make
script:
- make -C base base-push BASE=${BASE}
gitlab-builder: amd64:amzn2:
stage: docker_images <<: *build_definition
image: docker:stable
services:
- docker:stable-dind
before_script:
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
script:
- docker build --build-arg PKG_PATH="${PACKAGE_PATH}" -t ${BUILDER} -f ./builder.Dockerfile .
- docker push ${BUILDER}
license: amd64:centos7:
stage: unit <<: *build_definition
image:
name: $LICENSE_TAG
script:
- ./license/check.sh
code-check: amd64:opensuse-leap15.1:
stage: unit <<: *build_definition
image: ${BUILDER}
script:
- cd ${PACKAGE_PATH}
- make verify
shim-test: amd64:debian9:
stage: integration <<: *build_definition
image: ${BUILDER}
before_script:
- mkdir /etc/nvidia-container-runtime && echo "" > /etc/nvidia-container-runtime/config.toml # config for test
- echo "" > /usr/bin/nvidia-container-runtime-hook # hook for test
- chmod +x /usr/bin/nvidia-container-runtime-hook
- cd ${PACKAGE_PATH}/runtime/src
script:
- make test
build: amd64:debian10:
stage: build <<: *build_definition
image: docker:stable
services: amd64:ubuntu16.04:
- docker:stable-dind <<: *build_definition
before_script:
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}" amd64:ubuntu18.04:
- apk add --update make <<: *build_definition
script:
- make runtime BASE=${BASE} # build all runtime packages
- make toolkit BASE=${BASE} # build all toolkit packages
artifacts:
expire_in: 1 week
paths:
- dist/
\ No newline at end of file
...@@ -9,13 +9,17 @@ PKG_REV := 1 ...@@ -9,13 +9,17 @@ PKG_REV := 1
TOOLKIT_VERSION := 1.0.5 TOOLKIT_VERSION := 1.0.5
GOLANG_VERSION := 1.10.3 GOLANG_VERSION := 1.10.3
DIST_DIR := $(CURDIR)/../dist DIST_DIR := $(CURDIR)/dist
REGISTRY := nvidia
.NOTPARALLEL: .NOTPARALLEL:
.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
push%:
$(DOCKER) push "$(REGISTRY)/runtime/$*"
ubuntu%: ARCH := amd64 ubuntu%: ARCH := amd64
ubuntu%: ubuntu%:
$(DOCKER) build --pull \ $(DOCKER) build --pull \
...@@ -24,10 +28,10 @@ ubuntu%: ...@@ -24,10 +28,10 @@ ubuntu%:
--build-arg PKG_VERS="$(VERSION)" \ --build-arg PKG_VERS="$(VERSION)" \
--build-arg PKG_REV="$(PKG_REV)" \ --build-arg PKG_REV="$(PKG_REV)" \
--build-arg TOOLKIT_VERSION="$(TOOLKIT_VERSION)" \ --build-arg TOOLKIT_VERSION="$(TOOLKIT_VERSION)" \
--tag "nvidia/runtime/ubuntu:$*" \ --tag "$(REGISTRY)/runtime/ubuntu$*" \
--file docker/Dockerfile.ubuntu . --file docker/Dockerfile.ubuntu .
$(MKDIR) -p "$(DIST_DIR)/ubuntu$*/$(ARCH)" $(MKDIR) -p "$(DIST_DIR)/ubuntu$*/$(ARCH)"
$(DOCKER) run --cidfile $@.cid "nvidia/runtime/ubuntu:$*" $(DOCKER) run --cidfile $@.cid "$(REGISTRY)/runtime/ubuntu$*"
$(DOCKER) cp $$(cat $@.cid):/dist/. "$(DIST_DIR)/ubuntu$*/$(ARCH)/" $(DOCKER) cp $$(cat $@.cid):/dist/. "$(DIST_DIR)/ubuntu$*/$(ARCH)/"
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid $(DOCKER) rm $$(cat $@.cid) && rm $@.cid
...@@ -39,10 +43,10 @@ debian%: ...@@ -39,10 +43,10 @@ debian%:
--build-arg PKG_VERS="$(VERSION)" \ --build-arg PKG_VERS="$(VERSION)" \
--build-arg PKG_REV="$(PKG_REV)" \ --build-arg PKG_REV="$(PKG_REV)" \
--build-arg TOOLKIT_VERSION="$(TOOLKIT_VERSION)" \ --build-arg TOOLKIT_VERSION="$(TOOLKIT_VERSION)" \
--tag "nvidia/runtime/debian:$*" \ --tag "$(REGISTRY)/runtime/debian$*" \
--file docker/Dockerfile.debian . --file docker/Dockerfile.debian .
$(MKDIR) -p "$(DIST_DIR)/debian$*/$(ARCH)" $(MKDIR) -p "$(DIST_DIR)/debian$*/$(ARCH)"
$(DOCKER) run --cidfile $@.cid "nvidia/runtime/debian:$*" $(DOCKER) run --cidfile $@.cid "$(REGISTRY)/runtime/debian$*"
$(DOCKER) cp $$(cat $@.cid):/dist/. "$(DIST_DIR)/debian$*/$(ARCH)/" $(DOCKER) cp $$(cat $@.cid):/dist/. "$(DIST_DIR)/debian$*/$(ARCH)/"
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid $(DOCKER) rm $$(cat $@.cid) && rm $@.cid
...@@ -54,10 +58,10 @@ centos%: ...@@ -54,10 +58,10 @@ centos%:
--build-arg PKG_VERS="$(VERSION)" \ --build-arg PKG_VERS="$(VERSION)" \
--build-arg PKG_REV="$(PKG_REV)" \ --build-arg PKG_REV="$(PKG_REV)" \
--build-arg TOOLKIT_VERSION="$(TOOLKIT_VERSION)" \ --build-arg TOOLKIT_VERSION="$(TOOLKIT_VERSION)" \
--tag "nvidia/runtime/centos:$*" \ --tag "$(REGISTRY)/runtime/centos$*" \
--file docker/Dockerfile.centos . --file docker/Dockerfile.centos .
$(MKDIR) -p "$(DIST_DIR)/centos$*/$(ARCH)" $(MKDIR) -p "$(DIST_DIR)/centos$*/$(ARCH)"
$(DOCKER) run --cidfile $@.cid "nvidia/runtime/centos:$*" $(DOCKER) run --cidfile $@.cid "$(REGISTRY)/runtime/centos$*"
$(DOCKER) cp $$(cat $@.cid):/dist/. "$(DIST_DIR)/centos$*/$(ARCH)/" $(DOCKER) cp $$(cat $@.cid):/dist/. "$(DIST_DIR)/centos$*/$(ARCH)/"
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid $(DOCKER) rm $$(cat $@.cid) && rm $@.cid
...@@ -69,10 +73,10 @@ amzn%: ...@@ -69,10 +73,10 @@ amzn%:
--build-arg PKG_VERS="$(VERSION)" \ --build-arg PKG_VERS="$(VERSION)" \
--build-arg PKG_REV="$(PKG_REV)" \ --build-arg PKG_REV="$(PKG_REV)" \
--build-arg TOOLKIT_VERSION="$(TOOLKIT_VERSION)" \ --build-arg TOOLKIT_VERSION="$(TOOLKIT_VERSION)" \
--tag "nvidia/runtime/amzn:$*" \ --tag "$(REGISTRY)/runtime/amzn$*" \
--file docker/Dockerfile.amzn . --file docker/Dockerfile.amzn .
$(MKDIR) -p "$(DIST_DIR)/amzn$*/$(ARCH)" $(MKDIR) -p "$(DIST_DIR)/amzn$*/$(ARCH)"
$(DOCKER) run --cidfile $@.cid "nvidia/runtime/amzn:$*" $(DOCKER) run --cidfile $@.cid "$(REGISTRY)/runtime/amzn$*"
$(DOCKER) cp $$(cat $@.cid):/dist/. "$(DIST_DIR)/amzn$*/$(ARCH)/" $(DOCKER) cp $$(cat $@.cid):/dist/. "$(DIST_DIR)/amzn$*/$(ARCH)/"
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid $(DOCKER) rm $$(cat $@.cid) && rm $@.cid
...@@ -84,9 +88,9 @@ opensuse-leap%: ...@@ -84,9 +88,9 @@ opensuse-leap%:
--build-arg PKG_VERS="$(VERSION)" \ --build-arg PKG_VERS="$(VERSION)" \
--build-arg PKG_REV="$(PKG_REV)" \ --build-arg PKG_REV="$(PKG_REV)" \
--build-arg TOOLKIT_VERSION="$(TOOLKIT_VERSION)" \ --build-arg TOOLKIT_VERSION="$(TOOLKIT_VERSION)" \
--tag "nvidia/runtime/opensuse-leap:$*" \ --tag "$(REGISTRY)/runtime/opensuse-leap$*" \
--file docker/Dockerfile.opensuse-leap . --file docker/Dockerfile.opensuse-leap .
$(MKDIR) -p $(DIST_DIR)/opensuse-leap$*/$(ARCH) $(MKDIR) -p $(DIST_DIR)/opensuse-leap$*/$(ARCH)
$(DOCKER) run --cidfile $@.cid "nvidia/runtime/opensuse-leap:$*" $(DOCKER) run --cidfile $@.cid "$(REGISTRY)/runtime/opensuse-leap$*"
$(DOCKER) cp $$(cat $@.cid):/dist/. $(DIST_DIR)/opensuse-leap$*/$(ARCH)/ $(DOCKER) cp $$(cat $@.cid):/dist/. $(DIST_DIR)/opensuse-leap$*/$(ARCH)/
$(DOCKER) rm $$(cat $@.cid) && rm $@.cid $(DOCKER) rm $$(cat $@.cid) && rm $@.cid
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册