summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluccioman <luccioman@users.noreply.github.com>2016-06-03 15:11:41 +0200
committerluccioman <luccioman@users.noreply.github.com>2016-06-03 15:11:41 +0200
commit8a058acac9cfde4a82f712df630942fea85f32e6 (patch)
tree6774dd890b824dbda1c3246e6b9bcd85965922f7
parent377a832f533341b0a5d24b38950729b0a0fad9c6 (diff)
Improve final image size by concatenating some strategic commands
-rw-r--r--docker/Dockerfile35
1 files changed, 14 insertions, 21 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
index c31625a99..35102e4d6 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -4,10 +4,7 @@
FROM java:latest
# Install needed packages not in base image
-RUN apt-get update && apt-get install -yq \
- ant \
- git \
- curl
+RUN apt-get update && apt-get install -yq curl
# trace java version
RUN java -version
@@ -15,17 +12,20 @@ RUN java -version
# set current working dir
WORKDIR /opt
-# clone main YaCy git repository (we need to clone git repository to generate correct version when building from source)
-RUN git clone https://github.com/yacy/yacy_search_server.git
+# All in one step to reduce image size growth :
+# - install ant and git packages
+# - clone main YaCy git repository (we need to clone git repository to generate correct version when building from source)
+# - Compile with ant
+# - remove unnecessary and size consuming .git directory
+# - remove ant and git packages
+RUN apt-get update && \
+ apt-get install -yq ant git && \
+ git clone https://github.com/yacy/yacy_search_server.git && \
+ ant compile -f /opt/yacy_search_server/build.xml && \
+ rm -rf /opt/yacy_search_server/.git && \
+ apt-get purge -yq --auto-remove ant git && \
+ apt-get clean
-# trace content of source directory
-RUN ls -la /opt/yacy_search_server
-
-# set current working dir
-WORKDIR /opt/yacy_search_server
-
-# Compile with ant
-RUN ant compile
# Set initial admin password : "docker" (encoded with custom yacy md5 function net.yacy.cora.order.Digest.encodeMD5Hex())
RUN sed -i "/adminAccountBase64MD5=/c\adminAccountBase64MD5=MD5:e672161ffdce91be4678605f4f4e6786" /opt/yacy_search_server/defaults/yacy.init
@@ -36,13 +36,6 @@ RUN adduser --system --group --no-create-home --disabled-password yacy
# Set ownership of yacy install directory to yacy user/group
RUN chown yacy:yacy -R /opt/yacy_search_server
-# make some cleaning to reduce image size
-RUN rm -rf .git \
- && apt-get purge -yq --auto-remove \
- ant \
- git \
- && apt-get clean
-
# Expose port 8090
EXPOSE 8090