From 49e15df1298c33734615d8f114086ea9b6edf0e4 Mon Sep 17 00:00:00 2001 From: Shuai Lin Date: Fri, 25 Nov 2016 14:56:23 +0800 Subject: [PATCH] Use docke-squash to make a smaller base image. --- image/Makefile | 5 +++++ image/base/Dockerfile | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/image/Makefile b/image/Makefile index fea37ba..9b4d7ee 100644 --- a/image/Makefile +++ b/image/Makefile @@ -1,6 +1,7 @@ server_version=6.0.5 base_image=seafileorg/base:16.04 +base_image_squashed=seafileorg/base:16.04-squashed server_image=seafileorg/server:$(server_version) all: @@ -14,6 +15,10 @@ base: server: cd seafile && docker build -t $(server_image) . +squash-base: + docker-squash --verbose --tag $(base_image_squashed) $(base_image) + docker tag $(base_image_squashed) $(base_image) + push: docker push $(base_image) docker push $(server_image) diff --git a/image/base/Dockerfile b/image/base/Dockerfile index 4eed1a2..ed66852 100644 --- a/image/base/Dockerfile +++ b/image/base/Dockerfile @@ -38,7 +38,21 @@ RUN mkdir -p /etc/service/mysql && \ RUN mkdir -p /etc/my_init.d && rm -f /etc/my_init.d/00_regen_ssh_host_keys.sh ADD my_init.d/99_mysql_setup.sh /etc/my_init.d/ +# clean up for docker squash +RUN rm -rf \ + /root/.cache \ + /root/.npm \ + /root/.pip \ + /usr/local/share/doc \ + /usr/share/doc \ + /usr/share/man \ + /usr/share/vim/vim74/doc \ + /usr/share/vim/vim74/lang \ + /usr/share/vim/vim74/spell/en* + /usr/share/vim/vim74/tutor \ + /var/lib/apt/lists/* \ + /tmp/* \ + CMD ["/sbin/my_init", "--", "bash", "-l"] -# TODO: clean up & squash layers with docker-squash -# See https://github.com/jwilder/docker-squash +# Docker squash