-
Notifications
You must be signed in to change notification settings - Fork 72
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
Reduce the size of the clp container images. #288
Changes from all commits
ed5d513
b73df85
410ec4c
a17e516
84f8237
5a0dc6e
16dfff1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exit on any error | ||
set -e | ||
|
||
# Error on undefined variable | ||
set -u | ||
|
||
cUsage="Usage: ${BASH_SOURCE[0]} <clp-core-build-dir>" | ||
if [ "$#" -lt 1 ]; then | ||
echo "${cUsage}" | ||
exit | ||
fi | ||
build_dir="$1" | ||
|
||
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
docker build -t clp-core-x86-ubuntu-focal:dev "${build_dir}" --file "${script_dir}/Dockerfile" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,30 @@ | ||
FROM ubuntu:focal | ||
FROM ubuntu:focal AS BASE | ||
|
||
WORKDIR /root | ||
|
||
RUN mkdir -p ./tools/scripts/lib_install | ||
ADD ./tools/scripts/lib_install ./tools/scripts/lib_install | ||
|
||
RUN ./tools/scripts/lib_install/ubuntu-focal/install-all.sh | ||
# NOTE: We can't use the `install-all.sh` script since we need to configure the compiler in between | ||
# `install-prebuilt-packages.sh` and `install-packages-from-source.sh`. | ||
RUN ./tools/scripts/lib_install/ubuntu-focal/install-prebuilt-packages.sh | ||
|
||
# Set the compiler to gcc-10 | ||
# Set gcc/g++ 10 as the default compiler | ||
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 | ||
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10 | ||
RUN update-alternatives --set gcc /usr/bin/gcc-10 | ||
RUN update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-10 20 | ||
RUN update-alternatives --set cc /usr/bin/gcc-10 | ||
RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10 | ||
RUN update-alternatives --set g++ /usr/bin/g++-10 | ||
RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-10 20 | ||
RUN update-alternatives --set c++ /usr/bin/g++-10 | ||
|
||
RUN ./tools/scripts/lib_install/ubuntu-focal/install-packages-from-source.sh | ||
|
||
# Remove cached files | ||
RUN apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
# Reset the working directory so that it's accessible by any user who runs the | ||
# container | ||
WORKDIR / | ||
# Flatten the image | ||
FROM scratch | ||
COPY --from=BASE / / |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,11 @@ set -e | |
set -u | ||
|
||
apt-get update | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ | ||
checkinstall \ | ||
curl \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should add libssl-dev here unless we plan to remove the dependency in the short term? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. |
||
libmariadb-dev \ | ||
libssl-dev \ | ||
python3 \ | ||
rsync \ | ||
zstd |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,11 @@ set -e | |
set -u | ||
|
||
apt-get update | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment for libssl-dev |
||
checkinstall \ | ||
curl \ | ||
libmariadb-dev \ | ||
libssl-dev \ | ||
python3 \ | ||
rsync \ | ||
zstd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually feel the original way we wrote it is more readable. is there a reason why you turn it into a one line command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to reduce the number of generated layers since each
RUN
command generates a separate layer; but I guess we can keep them separate since we're flattening the image in the end.