From dd9d64ac6543cf53a93277d7d3d540ce931eb2ce Mon Sep 17 00:00:00 2001 From: luc Date: Mon, 30 May 2016 09:14:23 +0200 Subject: [PATCH 01/17] Added curl dependency to allow running stopYACY.sh and /bin sh scripts. --- docker/Dockerfile | 3 ++- docker/Readme.md | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 476b266a4..3d032042e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -8,7 +8,8 @@ RUN apt-get update && apt-get install -yq \ default-jdk \ default-jre-headless \ ant \ - git + git \ + curl # set current working dir WORKDIR /opt diff --git a/docker/Readme.md b/docker/Readme.md index a49057d91..f37adf916 100755 --- a/docker/Readme.md +++ b/docker/Readme.md @@ -46,7 +46,7 @@ You can retrieve the container IP address with `docker inspect`. docker run -v [your_host/data/directory]:/opt/yacy_search_server/DATA luccioman/yacy -This allow your container to reuse a data directory form the host. +This allow your container to reuse a data directory from the host. #### As background process @@ -65,3 +65,6 @@ This allow your container to reuse a data directory form the host. ### Shutdown * Use "Shutdown" button in administration web interface +* OR run : + + docker exec [your_container_name] /opt/yacy_search_server/stopYACY.sh From 9ca2b140d8c6ed57bf23246fe38eb692fcd11696 Mon Sep 17 00:00:00 2001 From: luc Date: Mon, 30 May 2016 23:21:35 +0200 Subject: [PATCH 02/17] Run yacy daemon as non-root for improved security. --- docker/Dockerfile | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 3d032042e..a1043f52b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,7 +9,8 @@ RUN apt-get update && apt-get install -yq \ default-jre-headless \ ant \ git \ - curl + curl \ + sudo # set current working dir WORKDIR /opt @@ -29,6 +30,12 @@ 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 +# Create user and group yacy : this user will be used to run YaCy main process +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 \ @@ -40,8 +47,8 @@ RUN rm -rf .git \ # Expose port 8090 EXPOSE 8090 -# Set data volume : can be used to persist yacy data and configuration +# Set data volume : yacy data and configuration will persist aven after container stop or destruction VOLUME ["/opt/yacy_search_server/DATA"] -# Start yacy ind debug mode (-d) to display console logs and to wait for yacy process -CMD sh /opt/yacy_search_server/startYACY.sh -d +# Start yacy as non-root process in debug mode (-d) to display console logs and to wait for yacy process +CMD sudo -u yacy sh /opt/yacy_search_server/startYACY.sh -d From e18017015255979f5a18d6d02a24fc17754582a3 Mon Sep 17 00:00:00 2001 From: luc Date: Tue, 31 May 2016 00:12:18 +0200 Subject: [PATCH 03/17] Use latest official Docker java image as a basis. This image is a debian Jessie with an openjdk-8 from debian backports. This avoid downloading openjdk dependencies through apt-get each time YaCy docker image is built. --- docker/Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index a1043f52b..9545e81de 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,17 +1,18 @@ # Build a docker image from latest YaCy sources -# Base image : latest stable Debian -FROM debian:latest +# Base image : latest stable official jdk container from Docker (Debian based) +FROM java:latest # Install needed packages RUN apt-get update && apt-get install -yq \ - default-jdk \ - default-jre-headless \ ant \ git \ curl \ sudo +# trace java version +RUN java -version + # set current working dir WORKDIR /opt @@ -39,7 +40,6 @@ 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 \ - default-jdk \ ant \ git \ && apt-get clean From e71eb4d9e5efbd6d76f22248fa74bdc1e6edce17 Mon Sep 17 00:00:00 2001 From: luccioman Date: Tue, 31 May 2016 09:28:08 +0200 Subject: [PATCH 04/17] Added virtual machines and containers block --- readme.mediawiki | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/readme.mediawiki b/readme.mediawiki index 7848a276f..fa98fa648 100644 --- a/readme.mediawiki +++ b/readme.mediawiki @@ -99,6 +99,13 @@ http://:8090/ConfigAccounts_p.html and set an administration account. +== CAN I RUN YACY IN A VIRTUAL MACHINE OR A CONTAINER == +YaCy runs fine in virtual machines managed by software such as VirtualBox or VMware. + +Container technology may be more flexible and lightweight and also works fine with YaCy. + +More details for YaCy with Docker [here](docker/Readme.md). + == PORT 8090 IS BAD, PEOPLE ARE NOT ALLOWED TO ACCESS THAT PORT == You can forward port 80 to 8090 with iptables: From 16174931d106f8ca6ae7550aa347d12fc4caefae Mon Sep 17 00:00:00 2001 From: luccioman Date: Tue, 31 May 2016 09:38:00 +0200 Subject: [PATCH 05/17] Fixed link to docker readme (mediawiki format) --- readme.mediawiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.mediawiki b/readme.mediawiki index fa98fa648..6e223ed89 100644 --- a/readme.mediawiki +++ b/readme.mediawiki @@ -104,7 +104,7 @@ YaCy runs fine in virtual machines managed by software such as VirtualBox or VMw Container technology may be more flexible and lightweight and also works fine with YaCy. -More details for YaCy with Docker [here](docker/Readme.md). +More details for YaCy with Docker [[docker/Readme.md|here]]. == PORT 8090 IS BAD, PEOPLE ARE NOT ALLOWED TO ACCESS THAT PORT == From 59e4f29687ccac5f30ae78c5892983221e6be783 Mon Sep 17 00:00:00 2001 From: luc Date: Tue, 31 May 2016 09:50:37 +0200 Subject: [PATCH 06/17] Set process as non-root with "USER" instruction. Thus there is no need to get sudo package. --- docker/Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 9545e81de..bc9b4c953 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -7,8 +7,7 @@ FROM java:latest RUN apt-get update && apt-get install -yq \ ant \ git \ - curl \ - sudo + curl # trace java version RUN java -version @@ -50,5 +49,8 @@ EXPOSE 8090 # Set data volume : yacy data and configuration will persist aven after container stop or destruction VOLUME ["/opt/yacy_search_server/DATA"] -# Start yacy as non-root process in debug mode (-d) to display console logs and to wait for yacy process -CMD sudo -u yacy sh /opt/yacy_search_server/startYACY.sh -d +# Next commands run as yacy as non-root user for improved security +USER yacy + +# Start yacy in debug mode (-d) to display console logs and to wait for yacy process +CMD sh /opt/yacy_search_server/startYACY.sh -d From d27ef36453844008c1849b3cb33ab606d8c0431b Mon Sep 17 00:00:00 2001 From: luc Date: Tue, 31 May 2016 09:51:17 +0200 Subject: [PATCH 07/17] Added details about volumes management. --- docker/Readme.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/docker/Readme.md b/docker/Readme.md index f37adf916..04b838b80 100755 --- a/docker/Readme.md +++ b/docker/Readme.md @@ -42,11 +42,21 @@ You can retrieve the container IP address with `docker inspect`. -p option map host port and container port, allowing web interface access through the usual http://localhost:8090. -#### With persistent data volume +#### Handle persistent data volume - docker run -v [your_host/data/directory]:/opt/yacy_search_server/DATA luccioman/yacy - -This allow your container to reuse a data directory from the host. +As configured in the Dockerfile, by default yacy data (in /opt/yacy_search_server/DATA) will persist after container stop or deletion, in a volume with an automatically generated id. + +Bu you may map a host directory to hold yacy data in container : + + docker run -v [/your_host/data/directory]:/opt/yacy_search_server/DATA luccioman/yacy + +Or just use a volume label to help identify it later + + docker run -v yacy_volume:/opt/yacy_search_server/DATA luccioman/yacy + +Note that you can list all docker volumes with : + + docker volume ls #### As background process From d4ed2039a7fe2ac42f1ed5b6da379cadab5d5edc Mon Sep 17 00:00:00 2001 From: luccioman Date: Wed, 1 Jun 2016 21:49:47 +0200 Subject: [PATCH 08/17] Updated comments --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index bc9b4c953..c31625a99 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,9 +1,9 @@ # Build a docker image from latest YaCy sources -# Base image : latest stable official jdk container from Docker (Debian based) +# Base image : latest stable official jdk image from Docker (Debian based) FROM java:latest -# Install needed packages +# Install needed packages not in base image RUN apt-get update && apt-get install -yq \ ant \ git \ From 07d9bfc51d5574e2c30cbc7a5869b31eee514972 Mon Sep 17 00:00:00 2001 From: luccioman Date: Wed, 1 Jun 2016 21:50:40 +0200 Subject: [PATCH 09/17] Created a Dockerfile for yacy base on Alpine Linux --- docker/Dockerfile.alpine | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 docker/Dockerfile.alpine diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine new file mode 100755 index 000000000..219931d06 --- /dev/null +++ b/docker/Dockerfile.alpine @@ -0,0 +1,82 @@ +# Build a docker image from latest YaCy sources on Alpine Linux + +# Base image : latest stable official jdk image from Docker based on Alpine Linux +FROM java:alpine + +# trace java version +RUN java -version + +# Install needed packages not in base image +RUN apk update && \ + apk add --no-cache git \ + curl \ + gnupg + +# set current working dir +WORKDIR /tmp + +# --- Begin of apache ant install : from binary distribution because ant is not in alpine packages + +# 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 + +# set ant required environment variables +ENV ANT_HOME /opt/ant +ENV PATH ${PATH}:/opt/ant/bin + +# --- End of apache ant install + +# 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 + +# 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 + +# Create user and group yacy : this user will be used to run YaCy main process +RUN addgroup yacy && adduser -S -G yacy -H -D 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 && \ + rm -f /tmp/apache-ant-${ANT_VERSION}-bin.tar.gz && \ + rm -rf /opt/ant + +# Expose port 8090 +EXPOSE 8090 + +# Set data volume : yacy data and configuration will persist aven after container stop or destruction +VOLUME ["/opt/yacy_search_server/DATA"] + +# Next commands run as yacy as non-root user for improved security +USER yacy + +# Start yacy in debug mode (-d) to display console logs and to wait for yacy process +CMD sh /opt/yacy_search_server/startYACY.sh -d From afdd6484ed2b99f58877caa1525a6355afe42f20 Mon Sep 17 00:00:00 2001 From: luccioman Date: Wed, 1 Jun 2016 22:14:58 +0200 Subject: [PATCH 10/17] Compacted some instructions to reduce final image size --- docker/Dockerfile.alpine | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) 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 From fb35510b8875632839c42ef7bb5ef55dff2d8c48 Mon Sep 17 00:00:00 2001 From: luccioman Date: Thu, 2 Jun 2016 09:24:44 +0200 Subject: [PATCH 11/17] Improved curl commands (fail if URL is unreachable). --- docker/Dockerfile.alpine | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine index 3bf92ba1e..c962a176d 100755 --- a/docker/Dockerfile.alpine +++ b/docker/Dockerfile.alpine @@ -26,9 +26,9 @@ ENV ANT_VERSION 1.9.7 # - 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 && \ + curl -fSL http://www.eu.apache.org/dist//ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz -o apache-ant-${ANT_VERSION}-bin.tar.gz && \ + curl -fSL https://www.apache.org/dist/ant/binaries/apache-ant-${ANT_VERSION}-bin.tar.gz.asc -o apache-ant-${ANT_VERSION}-bin.tar.gz.asc && \ + curl -fSL 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 && \ From fcd7f2a03a72c79f9c70f3881ccd0d0a34f1a0c3 Mon Sep 17 00:00:00 2001 From: luccioman Date: Thu, 2 Jun 2016 10:03:28 +0200 Subject: [PATCH 12/17] Updated docker readme Added image variants, tags, and license information. --- docker/Readme.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docker/Readme.md b/docker/Readme.md index 04b838b80..0e254d346 100755 --- a/docker/Readme.md +++ b/docker/Readme.md @@ -2,6 +2,11 @@ [![Deploy to Docker Cloud](https://files.cloud.docker.com/images/deploy-to-dockercloud.svg)](https://cloud.docker.com/stack/deploy/?repo=https://github.com/luccioman/yacy_search_server/tree/docker/docker) +## Supported tags and respective Dockerfile links + +* latest (Dockerfile) +* lastet-alpine (Dockerfile.alpine) + ## Getting built image from Docker Hub docker pull luccioman/yacy @@ -15,6 +20,16 @@ Using yacy_search_server/docker/Dockerfile : cd yacy_search_server/docker docker build . +## Image variants + +`luccioman/yacy:latest` + +This image is based on latest stable official [java](https://hub.docker.com/_/java/) image provided by Docker. Embed Yacy compiled from latest git repository sources. + +`luccioman/yacy:latest-alpine` + +This image is based on latest stable official Alpine Linux [java](https://hub.docker.com/_/java/) image provided by Docker. Embed Yacy compiled from latest git repository sources. + ## Default admin account login : admin @@ -78,3 +93,7 @@ Note that you can list all docker volumes with : * OR run : docker exec [your_container_name] /opt/yacy_search_server/stopYACY.sh + +## License + +View [license](../COPYRIGHT) information for the software contained in this image. \ No newline at end of file From 48ea77b8cced15eaaeae599d83749ac53d33ff57 Mon Sep 17 00:00:00 2001 From: luccioman Date: Thu, 2 Jun 2016 12:10:12 +0200 Subject: [PATCH 13/17] git, compile and cleanup in one instruction --- docker/Dockerfile.alpine | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine index c962a176d..6be3154b9 100755 --- a/docker/Dockerfile.alpine +++ b/docker/Dockerfile.alpine @@ -45,22 +45,19 @@ ENV PATH ${PATH}:/opt/ant/bin # 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) -# add and delete git package within this same step to avoid image size growth +# All in one step to reduce image size growth : +# - add git package +# - clone main YaCy git repository (we need to clone git repository to generate correct version when building from source) +# - compile with apache ant +# - remove unnecessary and size consuming .git directory +# - delete git package and ant binary install 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 - -# set current working dir -WORKDIR /opt/yacy_search_server - -# Compile with ant -RUN ant compile + apk add --no-cache 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" && \ + rm -rf /opt/ant && \ + apk del git # 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 @@ -71,10 +68,6 @@ RUN addgroup yacy && adduser -S -G yacy -H -D 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 && \ - rm -rf /opt/ant - # Expose port 8090 EXPOSE 8090 From b54356baecc824312806dec3760c3bb365b56526 Mon Sep 17 00:00:00 2001 From: luccioman Date: Fri, 3 Jun 2016 14:39:39 +0200 Subject: [PATCH 14/17] Fixed line end causing build error. --- docker/Dockerfile.alpine | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine index 6be3154b9..497dd70ed 100755 --- a/docker/Dockerfile.alpine +++ b/docker/Dockerfile.alpine @@ -52,12 +52,12 @@ WORKDIR /opt # - remove unnecessary and size consuming .git directory # - delete git package and ant binary install RUN apk update && \ - apk add --no-cache 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" && \ - rm -rf /opt/ant && \ - apk del git + apk add --no-cache 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 && \ + rm -rf /opt/ant && \ + apk del git # 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 From 377a832f533341b0a5d24b38950729b0a0fad9c6 Mon Sep 17 00:00:00 2001 From: luccioman Date: Fri, 3 Jun 2016 14:50:03 +0200 Subject: [PATCH 15/17] Fixed license link for display on DockerHub --- docker/Readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/Readme.md b/docker/Readme.md index 0e254d346..6a3f1799e 100755 --- a/docker/Readme.md +++ b/docker/Readme.md @@ -2,7 +2,7 @@ [![Deploy to Docker Cloud](https://files.cloud.docker.com/images/deploy-to-dockercloud.svg)](https://cloud.docker.com/stack/deploy/?repo=https://github.com/luccioman/yacy_search_server/tree/docker/docker) -## Supported tags and respective Dockerfile links +## Supported tags and respective Dockerfiles * latest (Dockerfile) * lastet-alpine (Dockerfile.alpine) @@ -24,7 +24,7 @@ Using yacy_search_server/docker/Dockerfile : `luccioman/yacy:latest` -This image is based on latest stable official [java](https://hub.docker.com/_/java/) image provided by Docker. Embed Yacy compiled from latest git repository sources. +This image is based on latest stable official Debian [java](https://hub.docker.com/_/java/) image provided by Docker. Embed Yacy compiled from latest git repository sources. `luccioman/yacy:latest-alpine` @@ -96,4 +96,4 @@ Note that you can list all docker volumes with : ## License -View [license](../COPYRIGHT) information for the software contained in this image. \ No newline at end of file +View [license](https://github.com/yacy/yacy_search_server/blob/master/COPYRIGHT) information for the software contained in this image. \ No newline at end of file From 8a058acac9cfde4a82f712df630942fea85f32e6 Mon Sep 17 00:00:00 2001 From: luccioman Date: Fri, 3 Jun 2016 15:11:41 +0200 Subject: [PATCH 16/17] Improve final image size by concatenating some strategic commands --- docker/Dockerfile | 35 ++++++++++++++--------------------- 1 file 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 From fc958230c455774ec1262bf29f87309ffa248edd Mon Sep 17 00:00:00 2001 From: luccioman Date: Sun, 3 Jul 2016 17:28:47 +0200 Subject: [PATCH 17/17] Added instructions for log control and upgrade --- docker/Readme.md | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/docker/Readme.md b/docker/Readme.md index 6a3f1799e..7471d05ae 100755 --- a/docker/Readme.md +++ b/docker/Readme.md @@ -51,17 +51,22 @@ You can retrieve the container IP address with `docker inspect`. #### Easier to handle - docker run --name yacy -p 8090:8090 luccioman/yacy + docker run --name yacy -p 8090:8090 --log-opt max-size=100m --log-opt max-file=2 luccioman/yacy ---name option allow easier management of your container (without it, docker automatically generate a new name at each startup). +##### Options detail + +* --name : allow easier management of your container (without it, docker automatically generate a new name at each startup). +* -p : map host port and container port, allowing web interface access through the usual http://localhost:8090. +* --log-opt max-size : limit maximum docker log file size for this container +* --log-opt max-file : limit number of docker rotated log files for this container --p option map host port and container port, allowing web interface access through the usual http://localhost:8090. +Note : if you do not specify the log related options, when running a YaCy container 24hour a day with default log level, your Docker container log file will grow up to some giga bytes in a few days! #### Handle persistent data volume As configured in the Dockerfile, by default yacy data (in /opt/yacy_search_server/DATA) will persist after container stop or deletion, in a volume with an automatically generated id. -Bu you may map a host directory to hold yacy data in container : +But you may map a host directory to hold yacy data in container : docker run -v [/your_host/data/directory]:/opt/yacy_search_server/DATA luccioman/yacy @@ -92,7 +97,38 @@ Note that you can list all docker volumes with : * Use "Shutdown" button in administration web interface * OR run : - docker exec [your_container_name] /opt/yacy_search_server/stopYACY.sh + docker exec [your_container_name] /opt/yacy_search_server/stopYACY.sh + +### Upgrade + +You can upgrade your YaCy container the Docker way with the following commands sequence. + +Get latest Docker image : + + docker pull luccioman/yacy:latest +OR + docker pull luccioman/yacy:latest-alpine + +Create new container based on pulled image, using volume data from old container : + + docker create --name [tmp-container_name] -p 8090:8090 --volumes-from=[container_name] luccioman/yacy:latest + +Stop old container : + + docker exec [container_name] /opt/yacy_search_server/stopYACY.sh + + +Start new container : + + docker start [tmp-container_name] + +Check everything works fine, then you can delete old container : + + docker rm [container_name] + +Rename new container to reuse same container name : + + docker rename [tmp-container_name] [container_name] ## License