Skip to content
Snippets Groups Projects
Commit 5b82b995 authored by Xuefeng Ding's avatar Xuefeng Ding
Browse files

update dockefile and folder

parent bf22227f
No related branches found
No related tags found
No related merge requests found
Showing
with 93 additions and 128 deletions
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
#
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/common.md
# Maintainer: The VS Code and Codespaces Teams
#
# Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] [install Oh My Zsh! flag] [Add non-free packages]
set -e
INSTALL_ZSH="true"
USERNAME=$(whoami)
INSTALL_OH_MYS="true"
# ** Shell customization section **
if [ "${USERNAME}" = "root" ]; then
user_rc_path="/root"
else
user_rc_path="/home/${USERNAME}"
fi
codespaces_zsh="$(cat \
<<'EOF'
# Codespaces zsh prompt theme
__zsh_prompt() {
local prompt_username
if [ ! -z "${GITHUB_USER}" ]; then
prompt_username="@${GITHUB_USER}"
else
prompt_username="%n"
fi
PROMPT="%{$fg[green]%}${prompt_username} %(?:%{$reset_color%}➜ :%{$fg_bold[red]%}➜ )" # User/exit code arrow
PROMPT+='%{$fg_bold[blue]%}%(5~|%-1~/…/%3~|%4~)%{$reset_color%} ' # cwd
PROMPT+='$([ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ] && git_prompt_info)' # Git status
PROMPT+='%{$fg[white]%}$ %{$reset_color%}'
unset -f __zsh_prompt
}
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[cyan]%}(%{$fg_bold[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg_bold[yellow]%}✗%{$fg_bold[cyan]%})"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[cyan]%})"
__zsh_prompt
EOF
)"
# Adapted, simplified inline Oh My Zsh! install steps that adds, defaults to a codespaces theme.
# See https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh for official script.
oh_my_install_dir="${user_rc_path}/.oh-my-zsh"
template_path="${oh_my_install_dir}/templates/zshrc.zsh-template"
user_rc_file="${user_rc_path}/.zshrc"
if [ ! -d "${oh_my_install_dir}" ] && [ "${INSTALL_OH_MYS}" = "true" ]; then
umask g-w,o-w
mkdir -p ${oh_my_install_dir}
git clone --depth=1 \
-c core.eol=lf \
-c core.autocrlf=false \
-c fsck.zeroPaddedFilemode=ignore \
-c fetch.fsck.zeroPaddedFilemode=ignore \
-c receive.fsck.zeroPaddedFilemode=ignore \
"https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git" "${oh_my_install_dir}" 2>&1
mkdir -p ${oh_my_install_dir}/custom/themes
echo "${codespaces_zsh}" > "${oh_my_install_dir}/custom/themes/codespaces.zsh-theme"
# Shrink git while still enabling updates
cd "${oh_my_install_dir}"
git repack -a -d -f --depth=1 --window=1
fi
echo -e "$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${user_rc_file}
sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="codespaces"/g' ${user_rc_file}
echo "Done!"
# Use AlmaLinux 9 base image
FROM almalinux:9
RUN useradd -m vscode
RUN dnf --best --assumeyes update \
&& dnf -y install \
python3.11 \
python3.11-pip \
gcc \
make \
cmake \
git \
zsh \
which \
util-linux-user \
&& dnf clean all \
&& chsh -s /bin/zsh vscode
LABEL user.name="vscode"
# https://apt.llvm.org/
RUN dnf --best --assumeyes update && \
dnf -y install \
python3.11 python3.11-pip \
gcc make cmake \
git \
zsh \
which util-linux-user wget sudo passwd \
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
RUN useradd -ms /bin/zsh vscode && \
usermod -aG wheel vscode
WORKDIR /workspaces
USER vscode
RUN python3.11 -m venv /workspaces/.venv
RUN python3.11 -m venv /workspaces/venv
COPY requirements.txt /workspaces/requirements.txt
COPY requirements-dev.txt /workspaces/requirements-dev.txt
COPY .devcontainer/install_zsh.sh /workspaces/install_zsh.sh
RUN /workspaces/install_zsh.sh
RUN echo 'source /workspaces/.venv/bin/activate' >> ~/.zshrc \
&& source /workspaces/.venv/bin/activate \
&& pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
&& pip install --upgrade pip \
&& pip install -r requirements-dev.txt
RUN rm -rf /workspaces/requirements.txt /workspaces/requirements-dev.txt /workspaces/install_zsh.sh
RUN sh -c "$(curl -fsSL https://install.ohmyz.sh/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
RUN 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 && \
source /workspaces/venv/bin/activate && \
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
pip install --upgrade pip && \
pip install -r requirements-dev.txt && \
rm -rf /workspaces/requirements.txt /workspaces/requirements-dev.txt && \
echo "hi"
# sudo chown vscode:vscode -R /workspaces
......@@ -5,5 +5,19 @@
"context": "../.."
},
"runArgs": ["--userns=keep-id"], // needed for podman
"remoteUser": "vscode"
"remoteUser": "vscode",
"postCreateCommand": "",
"customizations": {
"vscode": {
"extensions": [
"llvm-vs-code-extensions.vscode-clangd",
"vadimcn.vscode-lldb",
"ms-toolsai.jupyter",
"ziruiwang.nvidia-monitor",
"esbenp.prettier-vscode",
"ms-python.python",
"charliermarsh.ruff"
]
}
}
}
# Use AlmaLinux 9 base image
FROM almalinux:9
LABEL user.name="root"
WORKDIR /workspaces
RUN dnf --best --assumeyes update \
&& dnf -y install \
python3.11 \
python3.11-pip \
gcc \
make \
cmake \
git \
zsh \
which \
util-linux-user \
&& dnf clean all \
&& chsh -s /bin/zsh root
RUN python3.11 -m venv /workspaces/.venv
RUN dnf --best --assumeyes update && \
dnf -y install \
python3.11 \
python3.11-pip \
gcc \
make \
cmake \
git \
zsh \
which \
util-linux-user && \
dnf clean all && \
chsh -s /bin/zsh root
RUN python3.11 -m venv /workspaces/venv
COPY requirements.txt /workspaces/requirements.txt
COPY requirements-dev.txt /workspaces/requirements-dev.txt
COPY .devcontainer/install_zsh.sh /workspaces/install_zsh.sh
RUN /workspaces/install_zsh.sh
RUN echo 'source /workspaces/.venv/bin/activate' >> ~/.zshrc \
&& source /workspaces/.venv/bin/activate \
&& pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
&& pip install --upgrade pip \
&& pip install -r requirements-dev.txt
RUN sh -c "$(curl -fsSL https://install.ohmyz.sh/install.sh)" "" --unattended
RUN source /workspaces/venv/bin/activate && \
echo 'source /workspaces/venv/bin/activate' >> ~/.zshrc && \
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
pip install --upgrade pip && \
pip install -r requirements-dev.txt
RUN rm -rf /workspaces/requirements.txt /workspaces/requirements-dev.txt /workspaces/install_zsh.sh
{
// example how to make a devcontainer for root user
"name": "Alma9 (root)",
"build": {
"dockerfile": "./Dockerfile",
......
......@@ -53,6 +53,22 @@
"python.analysis.inlayHints.variableTypes": true,
"python.analysis.typeCheckingMode": "strict",
"python.analysis.extraPaths": ["${workspaceFolder}/python"],
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
// "docker.host": "unix:///run/user/1000/podman/podman.sock"
"dev.containers.dockerPath": "podman"
"dev.containers.dockerPath": "podman",
"shellformat.effectLanguages": [
"shellscript",
// "dockerfile",
"dotenv",
"hosts",
"jvmoptions",
"ignore",
"gitignore",
"properties",
"spring-boot-properties",
"azcli",
"bats"
]
}
File moved
File moved
File moved
File moved
File moved
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment