-
Notifications
You must be signed in to change notification settings - Fork 0
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
Smaller Docker image size #1
Changes from all commits
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 | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,6 @@ | ||||||||||||||||||||
FROM debian:12.8-slim AS builder | ||||||||||||||||||||
FROM ubuntu:22.04 | ||||||||||||||||||||
|
||||||||||||||||||||
# Some metadata | ||||||||||||||||||||
LABEL base_image="ubuntu:22.04" | ||||||||||||||||||||
LABEL version="2" | ||||||||||||||||||||
LABEL software="diann" | ||||||||||||||||||||
|
@@ -11,25 +12,32 @@ LABEL about.license_file="https://github.com/vdemichev/DiaNN/LICENSE.txt" | |||||||||||||||||||
LABEL about.tags="Proteomics" | ||||||||||||||||||||
LABEL maintainer="Yasset Perez-Riverol <[email protected]>" | ||||||||||||||||||||
|
||||||||||||||||||||
USER root | ||||||||||||||||||||
ENV DEBIAN_FRONTEND=noninteractive | ||||||||||||||||||||
|
||||||||||||||||||||
RUN apt-get update -y --no-install-recommends && apt-get install -y \ | ||||||||||||||||||||
g++ build-essential cmake zlib1g-dev libbz2-dev libboost-all-dev wget locales unzip && \ | ||||||||||||||||||||
apt-get clean && rm -rf /var/lib/apt/lists/* | ||||||||||||||||||||
# Update package lists and ensure package versions are up to date | ||||||||||||||||||||
RUN apt-get update && apt-get upgrade -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. 🛠️ Refactor suggestion Optimize package installation and avoid unnecessary Running Consider applying the following changes: -RUN apt-get update && apt-get upgrade -y
-RUN apt-get install wget unzip libgomp1 locales -y
+RUN apt-get update && apt-get install -y \
+ wget \
+ unzip \
+ libgomp1 \
+ locales && \
+ rm -rf /var/lib/apt/lists/* This approach installs the necessary packages and cleans up the apt cache to minimize the image size. Also applies to: 22-22 |
||||||||||||||||||||
|
||||||||||||||||||||
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \ | ||||||||||||||||||||
locale-gen && update-locale LANG=en_US.UTF-8 | ||||||||||||||||||||
# Install necessary packages including locales | ||||||||||||||||||||
RUN apt-get install wget unzip libgomp1 locales -y | ||||||||||||||||||||
Comment on lines
+19
to
+22
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. 🛠️ Refactor suggestion Optimize package installation to reduce image size and avoid unnecessary upgrades Running Apply this diff to optimize package installation: -RUN apt-get update && apt-get upgrade -y
-# Install necessary packages including locales
-RUN apt-get install wget unzip libgomp1 locales -y
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends wget unzip libgomp1 locales && \
+ rm -rf /var/lib/apt/lists/* 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
RUN mkdir -p /opt/software && \ | ||||||||||||||||||||
wget https://github.com/vdemichev/DiaNN/releases/download/1.9.2/diann-1.9.2.Linux_update_2024-10-31.zip -O /opt/software/diann-1.9.2.Linux_update_2024-10-31.zip && \ | ||||||||||||||||||||
unzip /opt/software/diann-1.9.2.Linux_update_2024-10-31.zip -d /opt/software && \ | ||||||||||||||||||||
mv /opt/software/diann-1.9.2 /usr/diann-1.9.2 && \ | ||||||||||||||||||||
ln -s /usr/diann-1.9.2/diann-linux /usr/diann-1.9.2/diann && \ | ||||||||||||||||||||
rm -rf /opt/software | ||||||||||||||||||||
# Configure locale to avoid runtime errors | ||||||||||||||||||||
RUN locale-gen en_US.UTF-8 && \ | ||||||||||||||||||||
update-locale LANG=en_US.UTF-8 | ||||||||||||||||||||
|
||||||||||||||||||||
RUN chmod +x /usr/diann-1.9.2/diann-linux | ||||||||||||||||||||
# Set environment variables for locale | ||||||||||||||||||||
ENV LANG=en_US.UTF-8 | ||||||||||||||||||||
ENV LANGUAGE=en_US:en | ||||||||||||||||||||
ENV LC_ALL=en_US.UTF-8 | ||||||||||||||||||||
|
||||||||||||||||||||
ENV PATH="$PATH:/usr/diann-1.9.2" | ||||||||||||||||||||
ENV DIA_NN_PATH="/usr/diann-1.9.2" | ||||||||||||||||||||
# Download DIA-NN version <version> | ||||||||||||||||||||
RUN wget https://github.com/vdemichev/DiaNN/releases/download/1.9.2/diann-1.9.2.Linux.zip -O diann-1.9.2.Linux.zip | ||||||||||||||||||||
|
||||||||||||||||||||
WORKDIR /data/ | ||||||||||||||||||||
# Unzip the DIA-NN package | ||||||||||||||||||||
RUN unzip diann-1.9.2.Linux.zip | ||||||||||||||||||||
|
||||||||||||||||||||
# Set appropriate permissions for the DIA-NN folder | ||||||||||||||||||||
RUN chmod -R 775 /diann-1.9.2 | ||||||||||||||||||||
|
||||||||||||||||||||
# NOTE: It is entirely the user's responsibility to ensure compliance with DIA-NN license terms. | ||||||||||||||||||||
# Please review the licensing terms for DIA-NN before using or distributing this Docker image. | ||||||||||||||||||||
Comment on lines
+42
to
+43
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. Ensure compliance with DIA-NN licensing terms to avoid legal issues. DIA-NN version Would you like assistance in reviewing the licensing terms or exploring alternative methods to comply with the license, such as instructing users to download DIA-NN during the build process? |
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.
🛠️ Refactor suggestion
Consider using a smaller base image to achieve the goal of reducing image size
Switching from
debian:12-slim
toubuntu:22.04
may increase the Docker image size, as Ubuntu images are generally larger than Debian slim images. To meet the PR objective of reducing the image size, consider usingdebian:12-slim
or another minimal base image.