Skip to content

Instantly share code, notes, and snippets.

@appleparan
Last active November 14, 2024 23:56
Show Gist options
  • Save appleparan/e05f4efb2444329fd226249526a1f379 to your computer and use it in GitHub Desktop.
Save appleparan/e05f4efb2444329fd226249526a1f379 to your computer and use it in GitHub Desktop.
Dockerfile for appleparan/ml_base
# Image for vision and tabular machine learnig project with jupterlab
FROM nvcr.io/nvidia/tensorrt:24.10-py3 AS base
# Declare environmental variables
ENV DEBIAN_FRONTEND=noninteractive \
DEBCONF_NONINTERACTIVE_SEEN=true \
TZ=Asia/Seoul \
LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
SHELL=/bin/bash \
MPLBACKEND=Agg \
PIP_IGNORE_INSTALLED=1 \
PYTHONUNBUFFERED=1
# Declare versions
ENV OPENPMIX_VER=4.1.2 \
GIT_LFS_VER=3.5.1 \
PRETENDARD_VER=1.3.9 \
OPENCV_VER=4.10.0 \
NODE_VER=22 \
CODESERVER_VER=4.93.1 \
FNM_VER=1.37.2 \
FNM_DIR=/usr/local/fnm
# Setup locale
# Install necessary packages
RUN apt-key adv --refresh-keys --keyserver keyserver.ubuntu.com
RUN apt-get update && \
apt-get install -y --no-install-recommends locales tzdata
RUN locale-gen en_US.UTF-8 && \
update-locale LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
# Install necessary packages
RUN apt-key adv --refresh-keys --keyserver keyserver.ubuntu.com
RUN apt-get update && \
apt-get install -y --no-install-recommends software-properties-common && \
add-apt-repository universe && \
add-apt-repository ppa:flexiondotorg/nvtop && \
apt-get install -y --no-install-recommends \
build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl git \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
chrpath fakeroot g++ gcc gfortran cmake protobuf-compiler openjdk-11-jdk pkg-config ninja-build \
vim wget unzip bzip2 pbzip2 zip unzip ripgrep coreutils tree fontconfig \
ca-certificates iputils-ping lsof libjemalloc-dev \
openssh-client openssh-server \
pciutils pdsh pkg-config gnupg2 \
gdal-bin libgeos++-dev libgeos-dev libgdal-dev libproj-dev proj-bin graphviz \
libnuma-dev \
python3-dev python3-pip python3-setuptools python3-wheel python3-venv python3-tk \
gir1.2-gtk-3.0 libglib2.0-0 libgtk-3-dev libgtk2.0-dev libcairo-dev libcairo2-dev \
xvfb python-xkit fonts-firacode \
libxrender-dev libxrender1 libxext6 libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev \
ffmpeg libavcodec-dev libavformat-dev libfaac-dev libgirepository1.0-dev libmpdec-dev libv4l-dev \
libsmpeg-dev libswscale-dev libopenblas-dev libswresample-dev libx264-dev libxvidcore-dev \
libasound2-dev libmp3lame-dev \
libdc1394-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev \
libatlas-base-dev libeigen3-dev libfftw3-dev liblapack-dev libnlopt-dev \
libjpeg-dev libpng-dev libtiff-dev libopenexr-dev libwebp-dev \
pv nvtop duf htop iotop iftop nload nmon sysstat
# Change working directory
WORKDIR /tmp
# Install git-lfs
RUN curl -sLO https://github.com/git-lfs/git-lfs/releases/download/v${GIT_LFS_VER}/git-lfs-linux-amd64-v${GIT_LFS_VER}.tar.gz \
&& tar -xzvf git-lfs-linux-amd64-v${GIT_LFS_VER}.tar.gz \
&& sh /tmp/git-lfs-${GIT_LFS_VER}/install.sh \
&& rm -rf /tmp/git-lfs*
# Install Pretendard Font
RUN wget https://github.com/orioncactus/pretendard/releases/download/v${PRETENDARD_VER}/Pretendard-${PRETENDARD_VER}.zip \
&& unzip Pretendard-${PRETENDARD_VER}.zip -d pretendard \
&& mkdir -p /usr/local/share/fonts \
&& cp pretendard/public/static/alternative/*.ttf /usr/local/share/fonts/ \
&& fc-cache -f -v \
&& rm -rf pretendard Pretendard-${PRETENDARD_VER}.zip
# Setup Python
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
RUN python3 -m pip --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host=files.pythonhosted.org \
install --upgrade pip setuptools wheel
# Ignore HTTPS for git, wget, curl
RUN git config --global http.sslVerify false \
&& echo "check_certificate = off" >> /etc/wgetrc \
&& echo "insecure" >> ~/.curlrc
# Add trusted-host to pip.conf
RUN mkdir -p /etc/pip \
&& echo "[global]\ntrusted-host = pypi.org\ntrusted-host = files.pythonhosted.org" > /etc/pip/pip.conf
RUN touch /etc/apt/apt.conf.d/99verify-peer.conf \
&& echo >>/etc/apt/apt.conf.d/99verify-peer.conf "Acquire { https::Verify-Peer false }"
# Install fnm and initiate it
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g yarn pnpm \
&& node -v && yarn -v && pnpm -v
# Install Code-server
RUN curl -fL https://github.com/cdr/code-server/releases/download/v${CODESERVER_VER}/code-server-${CODESERVER_VER}-linux-amd64.tar.gz \
| tar -C /usr/local/lib -xz \
&& mv /usr/local/lib/code-server-${CODESERVER_VER}-linux-amd64 /usr/local/lib/code-server-${CODESERVER_VER} \
&& ln -s /usr/local/lib/code-server-${CODESERVER_VER}/bin/code-server /usr/local/bin/code-server
# Install Jupyterlab
RUN python3 -m pip --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host=files.pythonhosted.org \
install ruff \
python-lsp-server \
python-lsp-ruff
RUN python3 -m pip --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host=files.pythonhosted.org \
install jupyterlab \
ipywidgets \
jupyterlab_favorites \
qgridnext \
ipykernel \
ipympl \
nbdime \
jupyterlab-katex \
jupyterlab-code-formatter \
jupyterlab-git \
jupyterlab-lsp \
jupyterlab_limit_output \
lckr_jupyterlab_variableinspector \
jupyterlab-unfold \
jupyterlabcodetoc \
JLDracula
# Default Jupyterlab settings
RUN mkdir -p /root/.jupyter/lab/user-settings/@jupyterlab/shortcuts-extension && \
mkdir -p /root/.jupyter/lab/user-settings/@jupyterlab/terminal-extension
# Configure code editor settings
RUN cat <<EOF > /root/.jupyter/lab/user-settings/@jupyterlab/terminal-extension/plugin.jupyterlab-settings
{
"fontFamily": "Fira Code",
"fontSize": 16,
"lineHeight": 1.1,
"theme": "inherit",
"screenReaderMode": false,
"scrollback": 9995,
"shutdownOnClose": false,
"closeOnExit": true,
"pasteWithCtrlV": true,
"macOptionIsMeta": false
}
EOF
# Disable default shortcuts in JupyterLab
RUN cat <<EOF > /root/.jupyter/lab/user-settings/@jupyterlab/shortcuts-extension/shortcuts.jupyterlab-settings
{
"shortcuts": [
{
"args": {},
"command": "application:toggle-left-area",
"keys": [
"Accel B"
],
"selector": "body",
"disabled": true
},
{
"args": {},
"command": "apputils:activate-command-palette",
"keys": [
"Accel Shift C"
],
"selector": "body",
"disabled": true
},
]
}
EOF
# Build Jupyterlab extensions
RUN jupyter server extension enable --py jupyterlab --sys-prefix && \
jupyter lab build
# Clean up
RUN apt-get autoclean \
&& apt-get autoremove -y \
&& ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
&& mkdir -p /etc/terminfo/x \
&& ln -sf /usr/share/terminfo/x/xterm-256color /etc/terminfo/x/xterm \
&& rm -rf /tmp/*.whl /tmp/requirem* \
&& rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* \
&& rm -rf /root/.cache \
&& rm -rf /tmp/*
WORKDIR /root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment