Skip to content

Commit

Permalink
feat: add zsh and prezto (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
AngryMaciek authored Sep 23, 2024
1 parent 2a3e281 commit 0f653aa
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
15 changes: 9 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
##### BASE IMAGE #####
FROM ubuntu:22.04
FROM ubuntu:24.04

##### METADATA #####
LABEL base.image="ubuntu:22.04"
LABEL version="1.2.0"
LABEL base.image="ubuntu:24.04"
LABEL version="1.3.0"
LABEL maintainer="Maciek Bak"

##### DEFINE BUILD/ENV VARIABLES #####
ARG MAMBADIR="/mambaforge"
ARG MAMBAURL="https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh"
ARG MAMBAURL="https://github.com/conda-forge/miniforge/releases/download/24.3.0-0/Mambaforge-24.3.0-0-Linux-x86_64.sh"
ENV LANG C.UTF-8

##### INSTALL SYSTEM-LEVEL DEPENDENCIES #####
RUN apt-get update \
&& apt-get install --no-install-recommends --yes \
ca-certificates cmake curl g++ gcc git gnupg2 gosu make vim wget \
ca-certificates cmake curl g++ gcc git gnupg2 gosu make vim wget zsh \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Expand All @@ -25,6 +25,7 @@ RUN /bin/bash -c "curl -L ${MAMBAURL} > mambaforge.sh \
&& ${MAMBADIR}/bin/conda config --system --set channel_priority strict \
&& source ${MAMBADIR}/bin/activate \
&& conda init bash \
&& conda init zsh \
&& mamba install boa conda-build conda-verify -c conda-forge --yes \
&& conda clean --all --yes \
&& rm -f mambaforge.sh"
Expand All @@ -38,9 +39,11 @@ WORKDIR /workdir

##### SETUP ENTRYPOINT W/ NONROOT USER #####
COPY entrypoint.sh /bin/entrypoint.sh
COPY prezto-user-setup.sh /usr/local/bin/prezto-user-setup.sh
RUN /bin/bash -c "chmod +x /bin/entrypoint.sh \
&& groupadd conda \
&& chgrp -R conda ${MAMBADIR} \
&& chmod 770 -R ${MAMBADIR}"
&& chmod 770 -R ${MAMBADIR} \
&& chmod 755 /usr/local/bin/prezto-user-setup.sh"
ENTRYPOINT ["/bin/entrypoint.sh"]
CMD ["/bin/bash"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _~AngryMaciek_

### Brief description

The base image here is the popular `ubuntu:22:04` - that is to increase the similarity of the container system to users OSs; A few system tools come pre-installed: [GNU Bash](https://www.gnu.org/software/bash/), [gcc & g++](https://gcc.gnu.org/), [Git](https://git-scm.com/), [GNU Make](https://www.gnu.org/software/make/), [CMake](https://cmake.org/), [Vim](https://www.vim.org/) and most importantly - [mambaforge](https://github.com/conda-forge/miniforge), which has been set up for the (default) root user; port `8888` is exposed to the host machine; dir `/workspace` is available to mount a volume; an entrypoint script has been designed to add a new non-root linux user which can access conda via a system's group; executing commands as `angryuser` is available through [gosu](https://github.com/tianon/gosu).
The base image here is the popular `ubuntu:24:04` - that is to increase the similarity of the container system to users OSs; A few system tools come pre-installed: [GNU Bash](https://www.gnu.org/software/bash/), [Z shell](https://en.wikipedia.org/wiki/Z_shell), [gcc & g++](https://gcc.gnu.org/), [Git](https://git-scm.com/), [GNU Make](https://www.gnu.org/software/make/), [CMake](https://cmake.org/), [Vim](https://www.vim.org/) and most importantly - [mambaforge](https://github.com/conda-forge/miniforge), which has been set up for the (default) root user; port `8888` is exposed to the host machine; dir `/workspace` is available to mount a volume; an entrypoint script has been designed to add a new non-root linux user which can access conda via a system group; executing commands as `angryuser` is available through [gosu](https://github.com/tianon/gosu); interactive login shell for that user is customised with my personal [Prezto](https://github.com/AngryMaciek/prezto) settings.

Useful references:
* https://denibertovic.com/posts/handling-permissions-with-docker-volumes/
Expand Down Expand Up @@ -94,6 +94,6 @@ container through the `devcontainer` mechanism; include these lines in your JSON
```

By default the container starts as root, though one may swiftly change
to the developer shell with: `gosu angryuser bash`. Watch out! Depending on the container set up tool
to the developer shell with: `gosu angryuser zsh`. Watch out! Depending on the container set up tool
it may turn out that the cloned repository does not have write permission set for _others_ (as root is the owner).
In such case one needs to run `chmod 777 -R .` before switching users.
5 changes: 4 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/bin/bash
echo "[INFO] angry user setup, please wait a moment..."
ID=${HOSTUID:-9001}
useradd --shell /bin/bash -u $ID -o -c "" -m angryuser
export HOME=/home/angryuser
adduser angryuser conda &> /dev/null
/usr/sbin/gosu angryuser /usr/local/bin/prezto-user-setup.sh &> /dev/null
/usr/sbin/gosu angryuser /bin/bash -c "/mambaforge/bin/conda init bash &> /dev/null"
/usr/sbin/gosu angryuser /bin/bash -c "/mambaforge/bin/conda init zsh &> /dev/null"
/usr/sbin/gosu angryuser /bin/bash -c "/mambaforge/bin/conda config --set changeps1 False &> /dev/null"
exec "$@"
7 changes: 7 additions & 0 deletions prezto-user-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/zsh
cd $HOME
git clone --recursive https://github.com/AngryMaciek/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done

0 comments on commit 0f653aa

Please sign in to comment.