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.
This commit is contained in:
parent
74a011fb4d
commit
d2e83d197d
|
@ -0,0 +1 @@
|
||||||
|
.git
|
23
Dockerfile
23
Dockerfile
|
@ -3,11 +3,9 @@
|
||||||
FROM ubuntu:trusty
|
FROM ubuntu:trusty
|
||||||
MAINTAINER Kyle Johnson <kjohnson@gnulnx.net>
|
MAINTAINER Kyle Johnson <kjohnson@gnulnx.net>
|
||||||
|
|
||||||
# Let the container know that there is no tty
|
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
|
||||||
|
|
||||||
# Resynchronize the package index files
|
# 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 \
|
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 \
|
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 \
|
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 \
|
mysql-server libvlc-dev libvlc5 libvlccore-dev libvlccore7 vlc-data libcurl4-openssl-dev \
|
||||||
libavformat-dev libswscale-dev libavutil-dev libavcodec-dev libavfilter-dev \
|
libavformat-dev libswscale-dev libavutil-dev libavcodec-dev libavfilter-dev \
|
||||||
libavresample-dev libavdevice-dev libpostproc-dev libv4l-dev libtool libnetpbm10-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
|
# Copy local code into our container
|
||||||
ADD . /ZoneMinder
|
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 ./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 .
|
RUN cmake .
|
||||||
|
|
||||||
# Build ZoneMinder
|
# Build & install ZoneMinder
|
||||||
RUN make
|
RUN make && make install
|
||||||
|
|
||||||
# Install ZoneMinder
|
|
||||||
RUN make install
|
|
||||||
|
|
||||||
# ensure writable folders
|
# ensure writable folders
|
||||||
RUN ./zmlinkcontent.sh
|
RUN ./zmlinkcontent.sh
|
||||||
|
@ -43,10 +39,6 @@ RUN ./zmlinkcontent.sh
|
||||||
# Adding the start script
|
# Adding the start script
|
||||||
ADD utils/docker/start.sh /tmp/start.sh
|
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/
|
# give files in /usr/local/share/zoneminder/
|
||||||
RUN chown -R www-data:www-data /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
|
RUN echo 'zoneminder:zoneminder' | chpasswd
|
||||||
|
|
||||||
# Expose ssh and http ports
|
# Expose ssh and http ports
|
||||||
EXPOSE 80
|
EXPOSE 22 80
|
||||||
EXPOSE 22
|
|
||||||
|
|
||||||
CMD "/tmp/start.sh"
|
CMD "/tmp/start.sh"
|
||||||
|
|
Loading…
Reference in New Issue