|
| 1 | +# Dockerfile for the devcontainer |
| 2 | +# Branch: maintain |
| 3 | +# Version: 0.1.0 |
| 4 | +# Tag: alpha |
| 5 | + |
| 6 | +# Install |
| 7 | +# - Python 3.12 |
| 8 | +# - Poetry |
| 9 | +# - Oh My Zsh |
| 10 | +# - Pre-commit |
| 11 | + |
| 12 | +FROM python:3.12-bullseye |
| 13 | + |
| 14 | +# User configuration |
| 15 | +ARG USER_NAME=user |
| 16 | +ARG USER_UID=1000 |
| 17 | +ARG USER_GID=1000 |
| 18 | +ARG WORKSPACE=/workspace |
| 19 | + |
| 20 | +# Keeps Python from generating .pyc files in the container |
| 21 | +ENV PYTHONDONTWRITEBYTECODE=1 |
| 22 | +# Turns off buffering for easier container logging |
| 23 | +ENV PYTHONUNBUFFERED=1 |
| 24 | + |
| 25 | +# Avoid warnings by switching to noninteractive |
| 26 | +ENV DEBIAN_FRONTEND=noninteractive |
| 27 | + |
| 28 | +# Configure apt and install packages |
| 29 | +RUN apt-get update \ |
| 30 | + && apt-get -y install --no-install-recommends \ |
| 31 | + zsh \ |
| 32 | + sudo \ |
| 33 | + nano \ |
| 34 | + bat \ |
| 35 | + locales \ |
| 36 | + tzdata |
| 37 | + |
| 38 | +RUN apt-get autoremove -y && apt-get clean |
| 39 | + |
| 40 | +# Set locale |
| 41 | +ENV LANG=ko_KR.UTF-8 |
| 42 | +ENV LC_MESSAGES=POSIX |
| 43 | +RUN localedef -i ko_KR -c -f UTF-8 -A /usr/share/locale/locale.alias ko_KR.UTF-8 \ |
| 44 | + && update-locale LANG=$LANG LC_MESSAGES=$LC_MESSAGES |
| 45 | + |
| 46 | +# Set timezone |
| 47 | +ENV TZ=Asia/Seoul |
| 48 | +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone |
| 49 | + |
| 50 | + |
| 51 | +WORKDIR ${WORKSPACE} |
| 52 | + |
| 53 | +# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers |
| 54 | +RUN adduser --disabled-password --gecos "" --uid ${USER_UID} ${USER_NAME} \ |
| 55 | + && chown -R ${USER_NAME} ${WORKSPACE} |
| 56 | + |
| 57 | +# Grant sudo privilege to ${USER_NAME} |
| 58 | +RUN echo "${USER_NAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USER_NAME} |
| 59 | + |
| 60 | +# Switch container user to ${USER_NAME} |
| 61 | +USER ${USER_NAME} |
| 62 | + |
| 63 | +# Set Zsh as default shell |
| 64 | +RUN sudo chsh -s /bin/zsh ${USER_NAME} |
| 65 | +# ENV SHELL=/bin/zsh |
| 66 | + |
| 67 | +# Install Oh My Zsh and plugins |
| 68 | +ENV ZSH_CUSTOM=/home/${USER_NAME}/.oh-my-zsh/custom |
| 69 | +RUN sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" \ |
| 70 | + && git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions \ |
| 71 | + && git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting \ |
| 72 | + && git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting \ |
| 73 | + && git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-completions \ |
| 74 | + && git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search \ |
| 75 | + && git clone https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k \ |
| 76 | + && git clone https://github.com/mattmc3/zsh-safe-rm ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-safe-rm \ |
| 77 | + && git clone https://github.com/fdellwing/zsh-bat.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-bat \ |
| 78 | + && git clone https://github.com/gretzky/auto-color-ls ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/auto-color-ls \ |
| 79 | + && git clone https://github.com/TamCore/autoupdate-oh-my-zsh-plugins ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/autoupdate |
| 80 | + |
| 81 | +# Copy .zshrc and .p10k.zsh |
| 82 | +COPY extra/.zshrc /home/${USER_NAME}/.zshrc |
| 83 | +COPY extra/.p10k.zsh /home/${USER_NAME}/.p10k.zsh |
| 84 | + |
| 85 | +# Install fzf |
| 86 | +RUN git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf \ |
| 87 | + && ~/.fzf/install --all --no-fish |
| 88 | + |
| 89 | +# Install Ruby gem for colorls |
| 90 | +RUN sudo apt-get -y install --no-install-recommends ruby-dev \ |
| 91 | + && sudo gem install colorls |
| 92 | + |
| 93 | +# Install Poetry |
| 94 | +ENV POETRY_HOME=/home/${USER_NAME}/.poetry |
| 95 | +ENV PATH="${POETRY_HOME}/bin:${PATH}" |
| 96 | +RUN curl -sSL https://install.python-poetry.org | python3 - |
| 97 | + |
| 98 | +# Configure Poetry |
| 99 | +RUN mkdir -p ${ZSH_CUSTOM}/plugins/poetry \ |
| 100 | + && poetry completions zsh > ${ZSH_CUSTOM}/plugins/poetry/_poetry \ |
| 101 | + && poetry config virtualenvs.create true \ |
| 102 | + && poetry config virtualenvs.in-project true \ |
| 103 | + && poetry config virtualenvs.path .venv \ |
| 104 | + && poetry self update |
| 105 | + |
| 106 | +# Install pre-commit |
| 107 | +RUN pip install pre-commit |
| 108 | + |
| 109 | +# Install pip requirements |
| 110 | +# COPY requirements.txt . |
| 111 | +# RUN python -m pip install -r requirements.txt |
| 112 | + |
| 113 | +CMD [ "/bin/zsh" ] |
0 commit comments