diff --git a/Dockerfile b/Dockerfile index a7f1167..ccc0280 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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/* @@ -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" @@ -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"] diff --git a/README.md b/README.md index fe5cac8..aba8a5b 100644 --- a/README.md +++ b/README.md @@ -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/ @@ -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. diff --git a/entrypoint.sh b/entrypoint.sh index 99ee902..86f8340 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 "$@" diff --git a/prezto-user-setup.sh b/prezto-user-setup.sh new file mode 100644 index 0000000..346f5c5 --- /dev/null +++ b/prezto-user-setup.sh @@ -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