THRIFT-4452: optimize Dockerfile so it runs apt-get update only once
This closes #1464
diff --git a/build/docker/ubuntu-artful/Dockerfile b/build/docker/ubuntu-artful/Dockerfile
index 59bbfa9..a5439a0 100644
--- a/build/docker/ubuntu-artful/Dockerfile
+++ b/build/docker/ubuntu-artful/Dockerfile
@@ -24,6 +24,8 @@
MAINTAINER Apache Thrift <dev@thrift.apache.org>
ENV DEBIAN_FRONTEND noninteractive
+### Add apt repos
+
RUN apt-get update && \
apt-get dist-upgrade -y && \
apt-get install -y --no-install-recommends \
@@ -41,13 +43,25 @@
# dotnet (core)
RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg && \
- echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-artful-prod artful main" > /etc/apt/sources.list.d/dotnetdev.list
+ echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-artful-prod artful main" > \
+ /etc/apt/sources.list.d/dotnetdev.list
-# node.js (this step runs apt-get update internally) - if we ever want a later version
-RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
+# node.js
+RUN curl -sL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - \
+ echo "deb https://deb.nodesource.com/node_8.x artful main" | tee /etc/apt/sources.list.d/nodesource.list
+
+# D
+RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EBCF975E5BA24D5E && \
+ wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list && \
+ wget -qO - https://dlang.org/d-keyring.gpg | apt-key add -
+
+# Dart
+RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
+ curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > \
+ /etc/apt/sources.list.d/dart_stable.list
### install general dependencies
-RUN apt-get install -y --no-install-recommends \
+RUN apt-get update && apt-get install -y --no-install-recommends \
`# General dependencies` \
bash-completion \
bison \
@@ -78,11 +92,7 @@
`# csharp (mono) dependencies` \
mono-devel
-RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EBCF975E5BA24D5E && \
- wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list && \
- wget -qO - https://dlang.org/d-keyring.gpg | apt-key add - && \
- apt-get update && \
- apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# D dependencies` \
dmd-bin \
libphobos2-dev \
@@ -104,10 +114,7 @@
# mv openssl-master/C/* /usr/include/dmd/druntime/import/C/ && \
# rm -rf openssl-master
-RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
- curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \
- apt-get update && \
- apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# Dart dependencies` \
dart/stable
ENV PATH /usr/lib/dart/bin:$PATH
diff --git a/build/docker/ubuntu-trusty/Dockerfile b/build/docker/ubuntu-trusty/Dockerfile
index 394e84f..0acd577 100644
--- a/build/docker/ubuntu-trusty/Dockerfile
+++ b/build/docker/ubuntu-trusty/Dockerfile
@@ -25,6 +25,8 @@
MAINTAINER Apache Thrift <dev@thrift.apache.org>
ENV DEBIAN_FRONTEND noninteractive
+### Add apt repos
+
RUN apt-get update && \
apt-get dist-upgrade -y && \
apt-get install -y --no-install-recommends \
@@ -36,6 +38,16 @@
software-properties-common \
wget
+# D
+RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EBCF975E5BA24D5E && \
+ wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list && \
+ wget -qO - https://dlang.org/d-keyring.gpg | apt-key add -
+
+# Dart
+RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
+ curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > \
+ /etc/apt/sources.list.d/dart_stable.list
+
RUN apt-get update && apt-get install -y --no-install-recommends \
`# General dependencies` \
bash-completion \
@@ -66,11 +78,7 @@
`# csharp (mono) dependencies` \
mono-devel
-RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EBCF975E5BA24D5E && \
- wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list && \
- wget -qO - https://dlang.org/d-keyring.gpg | apt-key add - && \
- apt-get update && \
- apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# D dependencies` \
dmd-bin=2.070.2-0 \
libphobos2-dev=2.070.2-0 \
@@ -88,10 +96,7 @@
# mv openssl-master/C/* /usr/include/dmd/druntime/import/C/ && \
# rm -rf openssl-master
-RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
- curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \
- apt-get update && \
- apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# Dart dependencies` \
dart=1.20.1-1
ENV PATH /usr/lib/dart/bin:$PATH
diff --git a/build/docker/ubuntu-xenial/Dockerfile b/build/docker/ubuntu-xenial/Dockerfile
index 02b5ac2..e06a0c0 100644
--- a/build/docker/ubuntu-xenial/Dockerfile
+++ b/build/docker/ubuntu-xenial/Dockerfile
@@ -27,7 +27,14 @@
### Add apt repos
-RUN apt-get update && apt-get dist-upgrade -y && apt-get install -y --no-install-recommends apt apt-transport-https curl wget apt-utils
+RUN apt-get update && \
+ apt-get dist-upgrade -y && \
+ apt-get install -y --no-install-recommends \
+ apt \
+ apt-transport-https \
+ apt-utils \
+ curl \
+ wget
# csharp (mono)
# RUN echo "deb http://download.mono-project.com/repo/debian xenial main" | tee /etc/apt/sources.list.d/mono.list && \
@@ -40,19 +47,14 @@
# Dart
RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
- curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \
- sed -i /etc/apt/sources.list.d/dart_stable.list -e 's/https:/http:/g'
-# since ubuntu-artful can't run dart, we'll run 1.240 on xenial for now
+ curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > \
+ /etc/apt/sources.list.d/dart_stable.list
ENV DART_VERSION 1.24.2-1
# dotnet (core)
RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg && \
- echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list
-
-# node.js (this step runs apt-get update internally)
-# note: node 8.5 introduced some issues with directory handling / jsdoc / something... using 7.x for now
-# RUN curl -sL https://deb.nodesource.com/setup_7.x | bash
-
+ echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > \
+ /etc/apt/sources.list.d/dotnetdev.list
### install general dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \