droppyjs / droppy

Self-hosted file storage
BSD 2-Clause "Simplified" License
104 stars 12 forks source link

Various problems with the new docker image #14

Closed gissehel closed 3 years ago

gissehel commented 3 years ago

There are various problems with the new Dockerfile image.

Description of problem with layers

Inside the Dockerfile, we can find

RUN apt-get -y update
RUN apt-get -y install aria2 gnupg software-properties-common \
                       python3 git curl bash openssl

and latter

## Lets slim the image down!

# systemd uses 26.6 MB of space!
RUN apt-get -y remove --purge --auto-remove systemd

# remove our cache from apt-get
RUN rm -rf /var/cache/apt/archives/

# apt-get update cache (17 MB)
RUN rm -rf /var/lib/apt/lists/

# man page ~6 MB
RUN rm -rf /usr/share/man/

# unused locale data ~31 MB
RUN rm -rf /usr/share/locale/

# unused mandocs ~11 MB
RUN rm -rf /usr/share/doc/

Each time a new RUN instruction is present, a new layer is created in the image with all the file created or modified in this layer. If a subsequent layer remove files, the files won't be removed from the image, they will just be flagged as being "not accessible".

This is why a lot a Dockerfiles that try to minimize the size of an image use as few RUN instruction as possible, either by putting all instruction on the same line like:

RUN instuction1 && \
    instruction2 && \
    instruction3 && \
    instruction4 && \
    rm -rd /.../cache-folder1 && \
    rm -rd /.../cache-folder2

or by using a script

ADD install.sh /
RUN /bin/bash /install.sh && rm -f /install.sh
markhughes commented 3 years ago

Didn't realise that! Thanks for the information! I'll change that :)

markhughes commented 3 years ago

Resolved in #14 - thanks for the feedback! Please give some more if you have a chance!