Skip to content
Snippets Groups Projects
Dockerfile 2.33 KiB
Newer Older
Xuefeng Ding's avatar
Xuefeng Ding committed
# Use AlmaLinux 9 base image
FROM almalinux:9
LABEL user.name="vscode"

# https://apt.llvm.org/
RUN dnf --best --assumeyes update && \
    dnf -y install \
Xuefeng Ding's avatar
Xuefeng Ding committed
        python3.11 python3.11-pip python3.11-devel \
        gcc make cmake \
        git \
        zsh \
Xuefeng Ding's avatar
Xuefeng Ding committed
        which util-linux-user wget sudo passwd unzip \
        clang lldb lld clang-tools-extra && \
    dnf clean all

RUN rm /usr/bin/cc /usr/bin/c++ && \
    alternatives --install /usr/bin/cc cc /usr/bin/clang 100 && \
    alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100 && \
    alternatives --auto c++ && \
    alternatives --auto cc

RUN dnf -y install 'dnf-command(config-manager)' && \
    dnf -y config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/cuda-rhel9.repo && \
    dnf -y install cuda-nvcc-12-4 && \
    dnf clean all

Xuefeng Ding's avatar
Xuefeng Ding committed
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME && \
    useradd --uid $USER_UID --gid $USER_GID -ms /bin/zsh $USERNAME && \
    echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \
    chmod 0440 /etc/sudoers.d/$USERNAME

USER $USERNAME

RUN export REMOTE="https://gitee.com/mirrors/oh-my-zsh" && \
    export COMMAND="$(curl -fsSL ${REMOTE}/raw/master/tools/install.sh)" && \
    sh -c "${COMMAND}" "" --unattended && \
    echo ${REMOTE} && \
    echo ${COMMAND} && \
    echo 'export PATH="/usr/local/cuda-12.4/bin${PATH:+:${PATH}}"' >>~/.zshrc && \
    echo 'export LD_LIBRARY_PATH="/usr/local/cuda-12.4/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"' >>~/.zshrc

RUN python3.11 -m venv ~/venv
COPY requirements.txt /home/vscode/requirements.txt
COPY requirements-dev.txt /home/vscode/requirements-dev.txt
RUN source ~/venv/bin/activate && \
    # echo 'source ~/venv/bin/activate' >> ~/.zshrc && \
    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
    pip install --upgrade pip && \
Xuefeng Ding's avatar
Xuefeng Ding committed
    pip install -r ~/requirements-dev.txt && \
    rm -rf ~/requirements.txt ~/requirements-dev.txt

RUN curl -o /home/vscode/vscode-lldb.vsix https://vadimcn.gallery.vsassets.io/_apis/public/gallery/publisher/vadimcn/extension/vscode-lldb/latest/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage && \
    echo "find ~ -name lldb | grep -q . || code --install-extension /home/vscode/vscode-lldb.vsix" >> ~/.zshrc