From f867cecaebb65964009b456d627ec562530dfada Mon Sep 17 00:00:00 2001 From: Shrukan Date: Sat, 17 Feb 2024 13:41:58 -0700 Subject: [PATCH] Rework dockerfile with a better shell, user config, and static analysis --- .clang-tidy | 6 ++++++ Dockerfile | 44 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..ebc2b28 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,6 @@ +--- +Checks: "bugprone-*, clang-analyzer-*, clang-diagnostic-*, concurrency-*, cppcoreguidelines-*, google-*, misc-*, modernize-*, performance-*, portability-*, -modernize-use-trailing-return-type" +WarningsAsErrors: true +HeaderFilterRegex: "" +AnalyzeTemporaryDtors: false +FormatStyle: none diff --git a/Dockerfile b/Dockerfile index 25227ba..e6aaeb9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,39 @@ -FROM gcc:12 +FROM gcc:13 # Install build tools -RUN apt-get update && apt-get install -y python3 python3-pip ninja-build gdb graphviz -RUN pip install meson gcovr -# The version of doxy in the Debian repos is too old to support concepts, so we grab the latest release and manually install -RUN wget --progress=bar:force:noscroll https://www.doxygen.nl/files/doxygen-1.9.5.linux.bin.tar.gz && \ - tar -xzf doxygen-1.9.5.linux.bin.tar.gz && \ - cd doxygen-1.9.5 && \ +RUN apt-get update && apt-get install -y python3 python3-pip ninja-build clang-format clang-tidy gdb graphviz git curl zsh \ + && rm -rf /var/lib/apt/lists/* + +RUN pip install --break-system-packages meson gcovr + +RUN curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/bin + +# Install latest doxygen +RUN wget --progress=bar:force:noscroll https://www.doxygen.nl/files/doxygen-1.10.0.linux.bin.tar.gz && \ + tar -xzf doxygen-1.10.0.linux.bin.tar.gz && \ + cd doxygen-1.10.0 && \ make install && \ cd .. && \ - rm -r doxygen-1.9.5.linux.bin.tar.gz && \ - rm -r doxygen-1.9.5 + rm -r doxygen-1.10.0.linux.bin.tar.gz && \ + rm -r doxygen-1.10.0 -WORKDIR /usr/src/app +# Add a user `dev` with UID/GID 1000 +# Set zsh as the default shell for this user +RUN groupadd -g 1000 dev && \ + useradd -m -u 1000 -g dev -s /bin/zsh dev + +# Change to non-root user +USER dev + +# Set up zsh to not suck +RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true +RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.5/zsh-in-docker.sh)" -- \ + -t robbyrussell \ + -p https://github.com/zsh-users/zsh-autosuggestions \ + -p https://github.com/zsh-users/zsh-syntax-highlighting \ + -a 'bindkey "^[l" autosuggest-accept' + +# Set the default shell for the container (optional, since it's already the default for the user) +# This is more about setting the shell when you exec into the container rather than changing the user's shell +SHELL ["/bin/zsh", "-c"] +ENTRYPOINT ["/bin/zsh"]