Skip to content
This repository was archived by the owner on Jan 10, 2020. It is now read-only.

Commit e79a36c

Browse files
authored
Refactor dockerfile (#7)
* Fix PATH to scala * Improve Dockerfile - set pipefail and -x globally - output the scala version after installation - cleanup apt caches in every layer - use sbt version in apt-get - remove now redundant `RUN set -x` - add `--no-install-recommends` to make the image smaller Summary: works as before (as far as tested :D) but received some love and is ~ 400 MB smaller
1 parent 3b4b0db commit e79a36c

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

Dockerfile

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# - AWS CLI
66
# - Docker
77

8+
89
# Pull base image
910
FROM openjdk:8u222
1011

@@ -16,50 +17,57 @@ ENV HOME=/config
1617

1718
# Install Scala
1819
## Piping curl directly in tar
20+
ENV PATH="/root/scala-$SCALA_VERSION/bin:${PATH}"
21+
SHELL ["/bin/bash", "-o", "pipefail", "-x", "-c"]
1922
RUN \
2023
curl -fsL https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz | tar xfz - -C /root/ && \
21-
echo >> /root/.bashrc && \
22-
echo "export PATH=~/scala-$SCALA_VERSION/bin:$PATH" >> /root/.bashrc
24+
scala -version
2325

2426
# Install sbt
2527
RUN \
2628
curl -L -o sbt-$SBT_VERSION.deb https://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb && \
2729
dpkg -i sbt-$SBT_VERSION.deb && \
2830
rm sbt-$SBT_VERSION.deb && \
2931
apt-get update && \
30-
apt-get install sbt && \
31-
sbt sbtVersion
32+
apt-get install -y --no-install-recommends sbt=${SBT_VERSION} && \
33+
sbt sbtVersion && \
34+
apt-get clean && \
35+
rm -rf /var/lib/apt/lists/*
3236

3337
# Install the AWS CLI
34-
# RUN set -x && \
35-
RUN apt-get install -y bash ca-certificates coreutils curl gawk git grep groff gzip jq less python sed tar zip && \
38+
RUN apt-get update && apt-get install -y --no-install-recommends \
39+
bash ca-certificates coreutils curl gawk git grep groff gzip jq less python sed tar zip && \
3640
curl -sSL https://s3.amazonaws.com/aws-cli/awscli-bundle.zip -o awscli-bundle.zip && \
37-
unzip awscli-bundle.zip
38-
RUN ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws && \
41+
unzip awscli-bundle.zip && \
42+
apt-get clean && \
43+
rm -rf /var/lib/apt/lists/* && \
44+
./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws && \
3945
rm awscli-bundle.zip && \
4046
rm -Rf awscli-bundle
4147

4248
# Install kubectl
4349
# Note: Latest version may be found on:
4450
# https://aur.archlinux.org/packages/kubectl-bin/
45-
RUN set -x \
46-
&& curl -LO https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl \
47-
&& mv kubectl /usr/local/bin/kubectl \
48-
&& chmod +x /usr/local/bin/kubectl
51+
RUN \
52+
curl -LO https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl && \
53+
mv kubectl /usr/local/bin/kubectl && \
54+
chmod +x /usr/local/bin/kubectl
4955

50-
RUN set -x && \
51-
chmod +x /usr/local/bin/kubectl && \
52-
\
53-
# Create non-root user (with a randomly chosen UID/GUI).
54-
adduser kubectl -Du 2342 -h /config && \
55-
kubectl version --client
56+
RUN \
57+
chmod +x /usr/local/bin/kubectl && \
58+
# Create non-root user (with a randomly chosen UID/GUI).
59+
adduser kubectl -Du 2342 -h /config && \
60+
kubectl version --client
5661

5762
# Install Docker
58-
RUN set -x && \
59-
apt-get install -y software-properties-common apt-transport-https && \
60-
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | apt-key add - && \
61-
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian stretch stable" && \
62-
apt-get update && apt-get install -y docker-ce
63+
RUN \
64+
apt-get update && apt-get install -y --no-install-recommends software-properties-common apt-transport-https && \
65+
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | apt-key add - && \
66+
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian stretch stable" && \
67+
apt-get update && \
68+
apt-get install -y --no-install-recommends docker-ce && \
69+
apt-get clean && \
70+
rm -rf /var/lib/apt/lists/*
6371

6472
# Define working directory
6573
WORKDIR /root

0 commit comments

Comments
 (0)