mirror of https://github.com/k3d-io/k3d
parent
3451675bc7
commit
bf3f630d1b
@ -1,36 +0,0 @@ |
|||||||
FROM ubuntu:18.04 as base |
|
||||||
RUN apt-get update -y && apt-get install -y ca-certificates |
|
||||||
ADD k3s/build/out/data.tar.gz /image |
|
||||||
RUN mkdir -p /image/etc/ssl/certs /image/run /image/var/run /image/tmp /image/lib/modules /image/lib/firmware && \ |
|
||||||
cp /etc/ssl/certs/ca-certificates.crt /image/etc/ssl/certs/ca-certificates.crt |
|
||||||
RUN cd image/bin && \ |
|
||||||
rm -f k3s && \ |
|
||||||
ln -s k3s-server k3s |
|
||||||
|
|
||||||
FROM ubuntu:18.04 |
|
||||||
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections |
|
||||||
RUN apt-get update -y && apt-get -y install gnupg2 curl |
|
||||||
# Install the NVIDIA CUDA drivers and Container Runtime |
|
||||||
RUN apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub |
|
||||||
RUN sh -c 'echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda.list' |
|
||||||
RUN curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | apt-key add - |
|
||||||
RUN curl -s -L https://nvidia.github.io/nvidia-container-runtime/ubuntu18.04/nvidia-container-runtime.list | tee /etc/apt/sources.list.d/nvidia-container-runtime.list |
|
||||||
RUN apt-get update -y |
|
||||||
RUN apt-get -y install cuda-drivers nvidia-container-runtime |
|
||||||
COPY --from=base /image / |
|
||||||
RUN mkdir -p /etc && \ |
|
||||||
echo 'hosts: files dns' > /etc/nsswitch.conf |
|
||||||
RUN chmod 1777 /tmp |
|
||||||
# Provide custom containerd configuration to configure the nvidia-container-runtime |
|
||||||
RUN mkdir -p /var/lib/rancher/k3s/agent/etc/containerd/ |
|
||||||
COPY config.toml.tmpl /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl |
|
||||||
# Deploy the nvidia driver plugin on startup |
|
||||||
RUN mkdir -p /var/lib/rancher/k3s/server/manifests |
|
||||||
COPY gpu.yaml /var/lib/rancher/k3s/server/manifests/gpu.yaml |
|
||||||
VOLUME /var/lib/kubelet |
|
||||||
VOLUME /var/lib/rancher/k3s |
|
||||||
VOLUME /var/lib/cni |
|
||||||
VOLUME /var/log |
|
||||||
ENV PATH="$PATH:/bin/aux" |
|
||||||
ENTRYPOINT ["/bin/k3s"] |
|
||||||
CMD ["agent"] |
|
@ -0,0 +1,32 @@ |
|||||||
|
FROM nvidia/cuda:11.2.0-base-ubuntu18.04 |
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND noninteractive |
||||||
|
|
||||||
|
ARG DOCKER_VERSION |
||||||
|
ENV DOCKER_VERSION=$DOCKER_VERSION |
||||||
|
|
||||||
|
RUN set -x && \ |
||||||
|
apt-get update && \ |
||||||
|
apt-get install -y \ |
||||||
|
apt-transport-https \ |
||||||
|
ca-certificates \ |
||||||
|
curl \ |
||||||
|
wget \ |
||||||
|
tar \ |
||||||
|
zstd \ |
||||||
|
gnupg \ |
||||||
|
lsb-release \ |
||||||
|
git \ |
||||||
|
software-properties-common \ |
||||||
|
build-essential && \ |
||||||
|
rm -rf /var/lib/apt/lists/* |
||||||
|
|
||||||
|
RUN set -x && \ |
||||||
|
curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \ |
||||||
|
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \ |
||||||
|
apt-get update && \ |
||||||
|
apt-get install -y \ |
||||||
|
containerd.io \ |
||||||
|
docker-ce=5:$DOCKER_VERSION~3-0~$(lsb_release -is | tr '[:upper:]' '[:lower:]')-$(lsb_release -cs) \ |
||||||
|
docker-ce-cli=5:$DOCKER_VERSION~3-0~$(lsb_release -is | tr '[:upper:]' '[:lower:]')-$(lsb_release -cs) && \ |
||||||
|
rm -rf /var/lib/apt/lists/* |
@ -0,0 +1,72 @@ |
|||||||
|
FROM nvidia/cuda:11.2.0-base-ubuntu18.04 as base |
||||||
|
|
||||||
|
RUN set -x && \ |
||||||
|
apt-get update && \ |
||||||
|
apt-get install -y ca-certificates zstd |
||||||
|
|
||||||
|
COPY k3s/build/out/data.tar.zst / |
||||||
|
|
||||||
|
RUN set -x && \ |
||||||
|
mkdir -p /image/etc/ssl/certs /image/run /image/var/run /image/tmp /image/lib/modules /image/lib/firmware && \ |
||||||
|
tar -I zstd -xf /data.tar.zst -C /image && \ |
||||||
|
cp /etc/ssl/certs/ca-certificates.crt /image/etc/ssl/certs/ca-certificates.crt |
||||||
|
|
||||||
|
RUN set -x && \ |
||||||
|
cd image/bin && \ |
||||||
|
rm -f k3s && \ |
||||||
|
ln -s k3s-server k3s |
||||||
|
|
||||||
|
FROM nvidia/cuda:11.2.0-base-ubuntu18.04 |
||||||
|
|
||||||
|
ARG NVIDIA_CONTAINER_RUNTIME_VERSION |
||||||
|
ENV NVIDIA_CONTAINER_RUNTIME_VERSION=$NVIDIA_CONTAINER_RUNTIME_VERSION |
||||||
|
|
||||||
|
RUN set -x && \ |
||||||
|
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections |
||||||
|
|
||||||
|
RUN set -x && \ |
||||||
|
apt-get update && \ |
||||||
|
apt-get -y install gnupg2 curl |
||||||
|
|
||||||
|
# Install NVIDIA Container Runtime |
||||||
|
RUN set -x && \ |
||||||
|
curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | apt-key add - |
||||||
|
|
||||||
|
RUN set -x && \ |
||||||
|
curl -s -L https://nvidia.github.io/nvidia-container-runtime/ubuntu18.04/nvidia-container-runtime.list | tee /etc/apt/sources.list.d/nvidia-container-runtime.list |
||||||
|
|
||||||
|
RUN set -x && \ |
||||||
|
apt-get update && \ |
||||||
|
apt-get -y install nvidia-container-runtime=${NVIDIA_CONTAINER_RUNTIME_VERSION} |
||||||
|
|
||||||
|
|
||||||
|
COPY --from=base /image / |
||||||
|
|
||||||
|
RUN set -x && \ |
||||||
|
mkdir -p /etc && \ |
||||||
|
echo 'hosts: files dns' > /etc/nsswitch.conf |
||||||
|
|
||||||
|
RUN set -x && \ |
||||||
|
chmod 1777 /tmp |
||||||
|
|
||||||
|
# Provide custom containerd configuration to configure the nvidia-container-runtime |
||||||
|
RUN set -x && \ |
||||||
|
mkdir -p /var/lib/rancher/k3s/agent/etc/containerd/ |
||||||
|
|
||||||
|
COPY config.toml.tmpl /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl |
||||||
|
|
||||||
|
# Deploy the nvidia driver plugin on startup |
||||||
|
RUN set -x && \ |
||||||
|
mkdir -p /var/lib/rancher/k3s/server/manifests |
||||||
|
|
||||||
|
COPY gpu.yaml /var/lib/rancher/k3s/server/manifests/gpu.yaml |
||||||
|
|
||||||
|
VOLUME /var/lib/kubelet |
||||||
|
VOLUME /var/lib/rancher/k3s |
||||||
|
VOLUME /var/lib/cni |
||||||
|
VOLUME /var/log |
||||||
|
|
||||||
|
ENV PATH="$PATH:/bin/aux" |
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/k3s"] |
||||||
|
CMD ["agent"] |
@ -1,15 +1,30 @@ |
|||||||
#!/bin/bash |
#!/bin/bash |
||||||
set -e |
|
||||||
cd $(dirname $0) |
|
||||||
|
|
||||||
K3S_TAG="${1:-v1.18.10+k3s1}" |
export CI_REGISTRY_IMAGE="YOUR_REGISTRY_IMAGE_URL" |
||||||
IMAGE_TAG="${K3S_TAG/+/-}" |
export VERSION="1.0" |
||||||
|
export K3S_TAG="v1.21.2+k3s1" |
||||||
|
export DOCKER_VERSION="20.10.7" |
||||||
|
export IMAGE_TAG="v1.21.2-k3s1" |
||||||
|
export NVIDIA_CONTAINER_RUNTIME_VERSION="3.5.0-1" |
||||||
|
|
||||||
if [ -d k3s ]; then |
docker build -f Dockerfile.base --build-arg DOCKER_VERSION=$DOCKER_VERSION -t $CI_REGISTRY_IMAGE/base:$VERSION . && \ |
||||||
rm -rf k3s |
docker push $CI_REGISTRY_IMAGE/base:$VERSION |
||||||
|
|
||||||
|
rm -rf ./k3s && \ |
||||||
|
git clone --depth 1 https://github.com/rancher/k3s.git -b "$K3S_TAG" && \ |
||||||
|
docker run -ti -v ${PWD}/k3s:/k3s -v /var/run/docker.sock:/var/run/docker.sock $CI_REGISTRY_IMAGE/base:1.0 sh -c "cd /k3s && make" && \ |
||||||
|
ls -al k3s/build/out/data.tar.zst |
||||||
|
|
||||||
|
if [ -f k3s/build/out/data.tar.zst ]; then |
||||||
|
echo "File exists! Building!" |
||||||
|
docker build -f Dockerfile.k3d-gpu \ |
||||||
|
--build-arg NVIDIA_CONTAINER_RUNTIME_VERSION=$NVIDIA_CONTAINER_RUNTIME_VERSION\ |
||||||
|
-t $CI_REGISTRY_IMAGE:$IMAGE_TAG . && \ |
||||||
|
docker push $CI_REGISTRY_IMAGE:$IMAGE_TAG |
||||||
|
echo "Done!" |
||||||
|
else |
||||||
|
echo "Error, file does not exist!" |
||||||
|
exit 1 |
||||||
fi |
fi |
||||||
git clone --depth 1 https://github.com/rancher/k3s.git -b $K3S_TAG |
|
||||||
cd k3s |
docker build -t $CI_REGISTRY_IMAGE:$IMAGE_TAG . |
||||||
make |
|
||||||
cd .. |
|
||||||
docker build -t k3s-gpu:$IMAGE_TAG . |
|
Loading…
Reference in new issue