From d2e83d197d7b47168b4a39849cb5f56e7f901c96 Mon Sep 17 00:00:00 2001 From: Toby Date: Thu, 2 Jun 2016 10:51:41 +1000 Subject: [PATCH] Improve Docker build; reduce image size & layer count Reducing layer count improves Docker performance, and is best-practice. Avoid packing & sending .git tree into Docker build system. Clean up apt archives to reduce image size. --- .dockerignore | 1 + Dockerfile | 23 +++++++---------------- utils/docker/start.sh | 0 3 files changed, 8 insertions(+), 16 deletions(-) create mode 100644 .dockerignore mode change 100644 => 100755 utils/docker/start.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..6b8710a71 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.git diff --git a/Dockerfile b/Dockerfile index 26df17d2b..558e0404f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,9 @@ FROM ubuntu:trusty MAINTAINER Kyle Johnson -# Let the container know that there is no tty -ENV DEBIAN_FRONTEND noninteractive - # Resynchronize the package index files -RUN apt-get update && apt-get install -y \ +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ libpolkit-gobject-1-dev build-essential libmysqlclient-dev libssl-dev libbz2-dev libpcre3-dev \ libdbi-perl libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libmime-perl libpcre3 \ libwww-perl libdbd-mysql-perl libsys-mmap-perl yasm cmake libjpeg-turbo8-dev \ @@ -16,7 +14,8 @@ RUN apt-get update && apt-get install -y \ mysql-server libvlc-dev libvlc5 libvlccore-dev libvlccore7 vlc-data libcurl4-openssl-dev \ libavformat-dev libswscale-dev libavutil-dev libavcodec-dev libavfilter-dev \ libavresample-dev libavdevice-dev libpostproc-dev libv4l-dev libtool libnetpbm10-dev \ - libmime-lite-perl dh-autoreconf dpatch + libmime-lite-perl dh-autoreconf dpatch \ + && apt-get clean # Copy local code into our container ADD . /ZoneMinder @@ -31,11 +30,8 @@ WORKDIR /ZoneMinder #RUN ./configure --with-libarch=lib/$DEB_HOST_GNU_TYPE --disable-debug --host=$DEB_HOST_GNU_TYPE --build=$DEB_BUILD_GNU_TYPE --with-mysql=/usr --with-webdir=/var/www/zm --with-ffmpeg=/usr --with-cgidir=/usr/lib/cgi-bin --with-webuser=www-data --with-webgroup=www-data --enable-mmap=yes --enable-onvif ZM_SSL_LIB=openssl ZM_DB_USER=zm ZM_DB_PASS=zm RUN cmake . -# Build ZoneMinder -RUN make - -# Install ZoneMinder -RUN make install +# Build & install ZoneMinder +RUN make && make install # ensure writable folders RUN ./zmlinkcontent.sh @@ -43,10 +39,6 @@ RUN ./zmlinkcontent.sh # Adding the start script ADD utils/docker/start.sh /tmp/start.sh -# Ensure we can run this -# TODO - Files ADD'ed have 755 already...why do we need this? -RUN chmod 755 /tmp/start.sh - # give files in /usr/local/share/zoneminder/ RUN chown -R www-data:www-data /usr/local/share/zoneminder/ @@ -65,7 +57,6 @@ RUN useradd -m -s /bin/bash -G sudo zoneminder RUN echo 'zoneminder:zoneminder' | chpasswd # Expose ssh and http ports -EXPOSE 80 -EXPOSE 22 +EXPOSE 22 80 CMD "/tmp/start.sh" diff --git a/utils/docker/start.sh b/utils/docker/start.sh old mode 100644 new mode 100755