Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

Compacted some instructions to reduce final image size

lucciomanafdd6484ed2b
diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine
index 219931d06..3bf92ba1e 100755
--- a/docker/Dockerfile.alpine
+++ b/docker/Dockerfile.alpine
@@ -8,9 +8,7 @@ RUN java -version
# Install needed packages not in base image
RUN apk update && \
- apk add --no-cache git \
- curl \
- gnupg
+ apk add --no-cache curl
# set current working dir
WORKDIR /tmp
@@ -20,18 +18,23 @@ WORKDIR /tmp
# set ant version once in a environment variable
ENV ANT_VERSION 1.9.7
-# get ant binary file from a mirror and PGP file signature from main repository
-RUN curl http://www.eu.apache.org/dist//ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz > apache-ant-${ANT_VERSION}-bin.tar.gz && \
- curl https://www.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz.asc > apache-ant-${ANT_VERSION}-bin.tar.gz.asc
-
-# import gpg keys from main repository and verify binary file signature
-RUN curl https://www.apache.org/dist/ant/KEYS | gpg --import && \
- gpg --verify apache-ant-${ANT_VERSION}-bin.tar.gz.asc
-
-# extract binary, make /opt directory and move extracted ant to /opt/ant
-RUN tar xzf apache-ant-${ANT_VERSION}-bin.tar.gz && \
- mkdir /opt && \
- mv apache-ant-${ANT_VERSION} /opt/ant
+# All in one step to reduce image size growth :
+# - add gnupg package
+# - get ant binary file from a mirror and PGP file signature from main repository
+# - import gpg keys from main repository and verify binary file signature
+# - extract binary, make /opt directory, move extracted ant to /opt/ant
+# - remove archive and gnupg package
+RUN apk update && \
+ apk add --no-cache gnupg && \
+ curl http://www.eu.apache.org/dist//ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz > apache-ant-${ANT_VERSION}-bin.tar.gz && \
+ curl https://www.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz.asc > apache-ant-${ANT_VERSION}-bin.tar.gz.asc && \
+ curl https://www.apache.org/dist/ant/KEYS | gpg --import && \
+ gpg --verify apache-ant-${ANT_VERSION}-bin.tar.gz.asc && \
+ tar xzf apache-ant-${ANT_VERSION}-bin.tar.gz && \
+ mkdir /opt && \
+ mv apache-ant-${ANT_VERSION} /opt/ant && \
+ rm -f apache-ant-${ANT_VERSION}-bin.tar.gz && \
+ apk del gnupg
# set ant required environment variables
ENV ANT_HOME /opt/ant
@@ -44,7 +47,11 @@ 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
+# add and delete git package within this same step to avoid image size growth
+RUN apk update && \
+ apk add --no-cache git && \
+ git clone https://github.com/yacy/yacy_search_server.git && \
+ apk del git
# trace content of source directory
RUN ls -la /opt/yacy_search_server
@@ -66,7 +73,6 @@ RUN chown yacy:yacy -R /opt/yacy_search_server
# make some cleaning to reduce image size
RUN rm -rf .git && \
- rm -f /tmp/apache-ant-${ANT_VERSION}-bin.tar.gz && \
rm -rf /opt/ant
# Expose port 8090