Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker: clean up after setup #59

Closed
abeimler opened this issue Apr 26, 2022 · 4 comments · Fixed by #63
Closed

Docker: clean up after setup #59

abeimler opened this issue Apr 26, 2022 · 4 comments · Fixed by #63
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@abeimler
Copy link
Contributor

Hello,
I'm using setup-cpp in my Dockerfile and saw the generated Layer is big (when installing a lot of tools).

Problem

image
16.3 GB

(it's hard to upload something this big to docker hub)

Dockerfile

## base image
FROM ubuntu:latest as base

ARG extra_libraries

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -y && apt-get install --no-install-recommends -y gnupg software-properties-common
# Install packages available from standard repos
RUN apt-get update -y && \
    apt-get install --no-install-recommends -yq \
        wget curl pkg-config zip unzip tar git && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# add setup_cpp
RUN wget --no-verbose "https://github.com/aminya/setup-cpp/releases/download/v0.13.1/setup_cpp_linux"
RUN chmod +x ./setup_cpp_linux
RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --clangformat true --clangtidy true

I add rm -rf /tmp/* && apt-get clean && rm -rf /var/lib/apt/lists/* for clean up and got: 14.3 GB

RUN ./setup_cpp_linux --compiler llvm \
    --cmake true --ninja true --ccache true \
    --cppcheck true --clangtidy true --clangformat true \
    --gcovr true --conan true --doxygen true && \
    rm -rf /tmp/* && apt-get clean && rm -rf /var/lib/apt/lists/*

(cleaning up the /tmp-folder seem to a bit help ?)

different setups

Readme example

RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --vcpkg true

image

gcc + conan

RUN ./setup_cpp_linux --compiler gcc --cmake true --ninja true --ccache true --conan true

Layer Size: 303.4 MB

with clang tools

idk why but the clang-tools seems huge after setup.

RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --conan true --cppcheck true --clangtidy true --clangformat true

Layer Size: 16 GB

with clangtidy

RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --clangtidy true

Layer Size: 11 GB

with clangformat

RUN ./setup_cpp_linux --compiler llvm --cmake true --ninja true --ccache true --clangformat true

Layer Size: 11 GB

My old setup

apt-get install --no-install-recommends -yq 
          gcc wget curl pkg-config zip unzip tar git build-essential &&     
apt-get install --no-install-recommends -y
          clang binutils bison
          python3 python3-pip doxygen graphviz         
          cmake make ninja-build ccache cppcheck cmake-extras   
          clang-tidy clang-format    
          valgrind gcovr linux-tools-common linux-tools-generic google-perftools         
          neovim emacs nano &&     
apt-get clean && rm -rf /var/lib/apt/lists/*

My old version with only apt-get setup was 1.1 GB (Layer Size)

Directory sizes in (docker) image

RUN du -sh /root/cmake
RUN du -sh /root/ninja
RUN du -sh /root/clangtidy
RUN du -sh /root/clangformat
RUN du -sh /root/llvm

Output

141M    /root/cmake
224K    /root/ninja
4.4G    /root/clangtidy
4.4G    /root/clangformat
4.4G    /root/llvm

Seems like llvm, clangtidy and clangformat are the same.
when installing llvm, and clang-tools, clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz gets downloaded multiple times. (and extract into /root/llvm, /root/clang... ?)

@aminya
Copy link
Owner

aminya commented Apr 26, 2022

However, keep in mind that this image is a dev/build image. You should only use it for building once in your CI system.
Once the building is done, to run your app, use a distroless image.
https://github.com/GoogleContainerTools/distroless

FROM ubuntu:devel as builder
# ... setup-cpp

# then build your app (e.g. using CMake)

FROM gcr.io/distroless/cc
COPY --from=builder /build/your_binary /
COPY --from=builder /build/your_dll_files /
CMD ["./your_binary"]

@aminya
Copy link
Owner

aminya commented Apr 26, 2022

In the meantime, remove the extra llvm flags like --clangtidy, --clangformat. Inside GitHub Actions, these are re-used but in a local installation, the caching doesn't work. #60

@aminya aminya added documentation Improvements or additions to documentation bug Something isn't working labels Apr 26, 2022
@abeimler
Copy link
Contributor Author

abeimler commented Apr 26, 2022

We should use the same path for clang-tools.

Yes I agree, --clangtindy and --clangformat are basically aliases for llvm, clang-tidy is already included in llvm.

@aminya
Copy link
Owner

aminya commented Apr 27, 2022

0.13.2 is released that fixes this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants