Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(Dockerfile)!: use ubuntu replace python image #21

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM python:3.12.1-slim
FROM ubuntu:jammy

ENV HOME="/root"
ENV LANG="C.UTF-8"

# install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends git zsh curl sudo && \
apt-get install -y --no-install-recommends git zsh curl wget sudo ca-certificates && \
apt-get clean && \
apt-get autoremove && \
rm -rf /var/lib/apt/lists/*
Expand All @@ -21,34 +22,45 @@ WORKDIR /app
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \
sudo chsh -s $(which zsh) && \
sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="essembeh"/g' $HOME/.zshrc
ENV SHELL /bin/zsh
ENV SHELL="/bin/zsh"
SHELL [ "/bin/zsh", "-c" ]


# setup nvm / node / npm / pnpm
ENV NVM_DIR ${HOME}/.nvm
ENV NVM_DIR="${HOME}/.nvm"
RUN mkdir -p ${NVM_DIR}
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
ENV NODE_VERSION 20.15.1
ENV NODE_VERSION="20.15.1"
RUN source ${NVM_DIR}/nvm.sh && \
nvm install ${NODE_VERSION} && \
nvm use ${NODE_VERSION} && \
nvm alias default ${NODE_VERSION} && \
rm -rf ${NVM_DIR}/.* ${NVM_DIR}/*.md ${NVM_DIR}/test ${NVM_DIR}/versions/node/v${NODE_VERSION}/*.md
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
ENV PATH="$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH"

RUN npm install -g pnpm
ENV PNPM_HOME=${HOME}/.local/share/pnpm
ENV PNPM_HOME="${HOME}/.local/share/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN pnpm config set store-dir ${PNPM_HOME}/store && \
pnpm setup zsh

# setup python
ENV PYENV_ROOT="${HOME}/.pyenv" PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"
RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && \
pip install wheel
# setup uv and python
ENV PYTHON_VERSION="3.12.1"
ENV PATH="${HOME}/.local/uv_bin/bin/:${PATH}"
RUN curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR=${HOME}/.local/uv_bin bash && \
uv python install ${PYTHON_VERSION}
# ENV is a static command and cannot obtain the architecture information of the local machine.
ihexon marked this conversation as resolved.
Show resolved Hide resolved
ENV PATH="${HOME}/.local/share/uv/python/cpython-${PYTHON_VERSION}-linux-x86_64-gnu/bin:${HOME}/.local/share/uv/python/cpython-${PYTHON_VERSION}-linux-aarch64-gnu/bin:${PATH}"
BlackHole1 marked this conversation as resolved.
Show resolved Hide resolved

# WSL2 GPU Driver libraries load path
RUN mkdir -p "/etc/ld.so.conf.d" && \
echo "/usr/lib/wsl/lib" > /etc/ld.so.conf.d/ld.wsl.conf && \
echo 'ldconfig # /etc/ld.so.cache' >> $HOME/.zshrc
ENV PATH="/usr/lib/wsl/lib/:${PATH}"

# save PATH
RUN echo "export PATH=${PATH}" >> $HOME/.zshrc
# without \$PATH the $PATH will be lost sometime or not be inherited after exec
RUN echo "export PATH=${PATH}:\$PATH" >> $HOME/.zshrc

# set font
COPY ./fonts/* /usr/share/fonts/SourceHanSans/
Expand All @@ -57,4 +69,4 @@ COPY ./fonts/* /usr/share/fonts/SourceHanSans/
RUN mkdir -p ${HOME}/.config/matplotlib/
COPY ./matplotlib/* ${HOME}/.config/matplotlib/

CMD ["/bin/zsh"]
CMD ["zsh"]
Loading