62 lines
1.8 KiB
Docker
62 lines
1.8 KiB
Docker
# syntax=docker/dockerfile:1
|
|
# NOTE: Building this image require's docker version >= 23.0.
|
|
#
|
|
# For reference:
|
|
# - https://docs.docker.com/build/dockerfile/frontend/#stable-channel
|
|
ARG TAG_VERSION="12.4.1"
|
|
FROM nvidia/cuda:${TAG_VERSION}-cudnn-devel-ubuntu22.04 as apptainerbuilder
|
|
ARG HTTP_PROXY
|
|
ARG HTTPS_PROXY
|
|
ENV http_proxy=${HTTP_PROXY}
|
|
ENV https_proxy=${HTTPS_PROXY}
|
|
ARG DEBIAN_FRONTEND="noninteractive"
|
|
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
|
|
# 安装必需的包
|
|
RUN apt-get update && apt-get install -y \
|
|
wget \
|
|
gcc \
|
|
git \
|
|
libc-dev \
|
|
make \
|
|
bash \
|
|
linux-headers-generic \
|
|
libseccomp-dev \
|
|
libssl-dev \
|
|
libuuid1 \
|
|
uuid-dev \
|
|
pkg-config \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 安装 Go
|
|
ARG GO_VERSION="1.21.13"
|
|
RUN wget https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz && \
|
|
tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \
|
|
rm go${GO_VERSION}.linux-amd64.tar.gz
|
|
|
|
# 设置 Go 环境变量
|
|
ENV PATH="/usr/local/go/bin:${PATH}"
|
|
|
|
# 构建 Apptainer
|
|
ARG APPTAINER_COMMITISH="main"
|
|
ARG MCONFIG_OPTIONS="--with-suid"
|
|
WORKDIR /go/src/github.com/apptainer
|
|
RUN git clone https://github.com/apptainer/apptainer.git \
|
|
&& cd apptainer \
|
|
&& git checkout "$APPTAINER_COMMITISH" \
|
|
&& ./mconfig $MCONFIG_OPTIONS -p /usr/local/apptainer \
|
|
&& cd builddir \
|
|
&& make \
|
|
&& make install
|
|
|
|
# 清理
|
|
RUN apt-get remove -y wget gcc git && \
|
|
apt-get autoremove -y && \
|
|
apt-get clean
|
|
|
|
FROM nvidia/cuda:${TAG_VERSION}-cudnn-devel-ubuntu22.04
|
|
# 复制 Apptainer 和 Go
|
|
COPY --from=apptainerbuilder /usr/local/apptainer /usr/local/apptainer
|
|
COPY --from=apptainerbuilder /usr/local/go /usr/local/go
|
|
ENV GO_PATH="/usr/local/go"
|
|
ENV PATH="/usr/local/apptainer/bin:${GO_PATH}/bin:$PATH"
|
|
ENV APPTAINER_TMPDIR="/tmp/tmp-apptainer" |