angoca / db2-docker

Docker image to run DB2 LUW
MIT License
37 stars 29 forks source link

Reduce the size of the docker images by combining RUN commands #14

Closed grange74 closed 8 years ago

grange74 commented 8 years ago

First of all great work on this repo and for helping DB2 being more user friendly.

Something i did notice which could be improved is the size of the images. For example the base install one is around 3GB according to https://imagelayers.io/?images=angoca%2Fdb2-install:latest.

You should be able to great reduce this size by combining some RUN commands. It does make the Dockerfile a little less readable but you have plenty of comments should it should be ok and the reduction should be worth it.

A good start would be to combine commands that download and ones that delete the downloaded file. If you do this in separate run commands the file won't be accessible in the above layers but it will still be there physical in the download layer.

So for example combine:

# Download the installer.
## URL to download the installer. The link is obtained from an article in the Wiki
## https://github.com/angoca/db2-docker/wiki/db2-link-expc
## That article should contain a valid link as the last line.
## If the link is not valid, you can modify the wiki.
RUN /tmp/download

# Extract the installer and delete the tar file.
RUN cd /tmp && \
  tar -zvxf ${DB2_INSTALLER} && \
  rm ${DB2_INSTALLER}

to:

# Download the installer.
## URL to download the installer. The link is obtained from an article in the Wiki
## https://github.com/angoca/db2-docker/wiki/db2-link-expc
## That article should contain a valid link as the last line.
## If the link is not valid, you can modify the wiki.
# Extract the installer and delete the tar file.
RUN /tmp/download && \
  cd /tmp && \
  tar -zvxf ${DB2_INSTALLER} && \
  rm ${DB2_INSTALLER}

This should reduce the image by around 595MB.

angoca commented 8 years ago

I close this ticked, because your pull request was integrated into master. Again, thanks for your changes.

angoca commented 8 years ago

One last comment. I saw that you have worker a lot on DB2 images for Docker, and because there is not an official image, we can work on that.

There was an effort from IBM, but it was not accomplished: https://github.com/docker-library/official-images/pull/797

What an official repository needs is: https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/ and https://docs.docker.com/docker-cloud/builds/image-scan/

Currently, I am working with Travis-CI to automate the builds, in order to have an independent environment to test the images.

What do you think?