Refactor using current official Dockerfile best practices
authorCasey Strouse <casey.strouse@gmail.com>
Tue, 13 Jun 2017 02:50:55 +0000 (19:50 -0700)
committerCasey Strouse <casey.strouse@gmail.com>
Tue, 13 Jun 2017 02:50:55 +0000 (19:50 -0700)
Implement best practices for Dockerfiles as per the official
documentation:
https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/

Reduces image size from 451.6MB to 404.9MB.

Dockerfile

index bde64049fd0f3ff77277a0f6d2557f8330864637..dca33b38c39c6a56c72010e8fb7f0ef2cf853f3d 100644 (file)
@@ -1,8 +1,21 @@
-FROM ubuntu
+FROM ubuntu:16.04
+
+RUN apt-get -y update && apt-get install -y \
+    autoconf \
+    bison \
+    check \
+    flex \
+    gcc \
+    git \
+    libtool \
+    make \
+    pkg-config \
+    protobuf-c-compiler \
+    re2c \
+&& rm -rf /var/lib/apt/lists/*
 
-RUN apt-get -y update
-RUN apt-get -y install autoconf bison check flex gcc git libtool make pkg-config protobuf-c-compiler re2c
 RUN git clone https://github.com/google/nsjail.git
-RUN cd /nsjail && make
-RUN mv /nsjail/nsjail /bin && rm -rf -- /nsjail
 
+WORKDIR /nsjail
+
+RUN make && mv /nsjail/nsjail /bin && rm -rf -- /nsjail