larra/.devcontainer/Dockerfile

85 lines
3.6 KiB
Docker

# Base image using Arch Linux
# Date: Sep10 2024
# Url: https://hub.docker.com/layers/library/archlinux/latest/images/sha256-a10e51dd0694d6c4142754e9d06cbce7baf91ace8031a30df37064d1091ab414?context=explore
FROM archlinux@sha256:a10e51dd0694d6c4142754e9d06cbce7baf91ace8031a30df37064d1091ab414
# Update the package database
# 1. system tools
# 2. build/test tools
# 3. libraries
RUN pacman -Syyu --noconfirm \
&& pacman -Syyu --noconfirm git less vim sudo python-pip wget which pkgconf \
&& pacman -Syyu --noconfirm cmake make gcc ninja meson shellcheck \
&& pacman -Syyu --noconfirm gtk4 gtkmm-4.0 boost spdlog fmt libxml++-5.0
# Create a non-root user 'dev'
RUN useradd -ms /bin/bash dev \
&& echo "dev ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/dev \
&& chmod 0440 /etc/sudoers.d/dev
# Add docker and docker-compose and add permissions to run without sudo
COPY --from=library/docker:latest /usr/local/bin/docker /usr/bin/docker
COPY --from=docker/compose:latest /usr/local/bin/docker-compose /usr/bin/docker-compose
# Allow dev to execute docker without sudo
RUN groupadd docker &&\
usermod -aG docker dev &&\
newgrp docker
# Switch to the 'dev' user
USER dev
# Add cached layer with the latest LLVM-${LLVM_VER}
ARG LLVM_VER=19.1.1
ENV LLVM_VER=${LLVM_VER}
RUN sudo mkdir -p /home/artifacts
ADD https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VER}/LLVM-${LLVM_VER}-Linux-X64.tar.xz /home/artifacts/
# Create the LLVM directory and extract only binaries into it
RUN sudo mkdir -p /home/LLVM-${LLVM_VER}
RUN sudo tar -xJf /home/artifacts/LLVM-${LLVM_VER}-Linux-X64.tar.xz -C /home/LLVM-${LLVM_VER} --strip-components=1 \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-19 \
LLVM-${LLVM_VER}-Linux-X64/bin/clang \
LLVM-${LLVM_VER}-Linux-X64/bin/clang++ \
LLVM-${LLVM_VER}-Linux-X64/bin/lld \
LLVM-${LLVM_VER}-Linux-X64/bin/ld.lld \
LLVM-${LLVM_VER}-Linux-X64/bin/ld64.lld \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-scan-deps \
LLVM-${LLVM_VER}-Linux-X64/bin/llvm-symbolizer \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-format \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-tidy \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-apply-replacements \
LLVM-${LLVM_VER}-Linux-X64/include/ \
LLVM-${LLVM_VER}-Linux-X64/lib/ \
LLVM-${LLVM_VER}-Linux-X64/libexec/ \
LLVM-${LLVM_VER}-Linux-X64/local/ \
LLVM-${LLVM_VER}-Linux-X64/share/
# Add /home/LLVM-${LLVM_VER}/bin to the PATH environment variable
ENV PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}"
# Add extra tools
RUN sudo mkdir -p /home/tools
ADD https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py /home/tools/
RUN sudo chmod -R a+x /home/tools/
RUN sudo chown -R dev /home/tools/
# Add the custom bash prompt with branch info
RUN printf '\n\
function modify_prompt { \n\
local __user_and_host="\[\033[01;32m\]\u@\h" \n\
local __cur_location="\[\033[01;34m\]\w" \n\
local __git_branch_color="\[\033[31m\]" \n\
local __git_branch="\$(git branch 2> /dev/null | sed -e \'"'"'/^[^*]/d\'"'"' -e \'"'"'s/* \(.*\)/(\\1)/\'"'"')" \n\
local __prompt_tail="\[\033[00m\]$" \n\
export PS1="$__user_and_host $__cur_location $__git_branch_color$__git_branch$__prompt_tail " \n\
} \n\
modify_prompt\n' >> /home/dev/.bashrc
RUN git config --global core.editor vim
# Set the default working directory
WORKDIR /home/dev
# Set the default command
CMD ["/bin/bash"]