diff options
| author | Michael Peter Christen <mc@yacy.net> | 2025-06-21 18:16:11 +0200 |
|---|---|---|
| committer | Michael Peter Christen <mc@yacy.net> | 2025-06-21 18:16:11 +0200 |
| commit | fa77a20012a508b497f776407caf780ca09a4c68 (patch) | |
| tree | 8fff4234603e02c6928eff25b787db71a6afdf57 /docker | |
| parent | c836eb95a373213b7a4a7d3c20b3cdad46ea1671 (diff) | |
enhanced Dockerfiles
Diffstat (limited to 'docker')
| -rw-r--r-- | docker/Dockerfile | 14 | ||||
| -rw-r--r-- | docker/Dockerfile.ArchLinux | 9 | ||||
| -rw-r--r-- | docker/Dockerfile.aarch64 | 10 | ||||
| -rw-r--r-- | docker/Dockerfile.alpine | 15 | ||||
| -rw-r--r-- | docker/Dockerfile.armv7 | 34 |
5 files changed, 49 insertions, 33 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile index c7733fdd6..318b978e6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -# Docker image for YaCy +# Ubuntu Docker image for YaCy # build with # docker build -t yacy/yacy_search_server:latest -f Dockerfile ../ @@ -9,19 +9,20 @@ ## builder image FROM eclipse-temurin:24-jdk-noble AS builder + +# Install needed packages not in base image RUN for i in 1 2 3; do \ apt-get update && break || sleep 5; \ done && \ apt-get install -y --no-install-recommends ant git curl && \ rm -rf /var/lib/apt/lists/* -# compile YaCy +# set current working dir & copy sources WORKDIR /opt COPY . /opt/yacy_search_server/ RUN ant compile -f /opt/yacy_search_server/build.xml # Set initial admin password: "yacy" (encoded with custom yacy md5 function net.yacy.cora.order.Digest.encodeMD5Hex()) -# Intially enable HTTPS: this is the most secure option for remote administrator authentication RUN sed -i "/adminAccountBase64MD5=/c\adminAccountBase64MD5=MD5:8cffbc0d66567a0987a4aba1ec46d63c" /opt/yacy_search_server/defaults/yacy.init && \ sed -i "/adminAccountForLocalhost=/c\adminAccountForLocalhost=false" /opt/yacy_search_server/defaults/yacy.init && \ sed -i "/server.https=false/c\server.https=true" /opt/yacy_search_server/defaults/yacy.init @@ -41,8 +42,15 @@ RUN adduser --system --group --no-create-home --disabled-password yacy WORKDIR /opt COPY --chown=yacy:yacy --from=builder /opt/yacy_search_server /opt/yacy_search_server +# Expose HTTP and HTTPS default ports EXPOSE 8090 8443 + +# Set data volume: yacy data and configuration will persist even 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 as a foreground process (-f) to display console logs and to wait for yacy process CMD ["/bin/sh","/opt/yacy_search_server/startYACY.sh","-f"] diff --git a/docker/Dockerfile.ArchLinux b/docker/Dockerfile.ArchLinux index ea7d655d6..ebe8428d0 100644 --- a/docker/Dockerfile.ArchLinux +++ b/docker/Dockerfile.ArchLinux @@ -1,3 +1,12 @@ +# Arch Linux Docker image for YaCy + +# build with +# docker build -t yacy/yacy_search_server:archlinux -f Dockerfile.ArchLinux ../ + +# run with +# docker run -d --name yacy -p 8090:8090 -p 8443:8443 -v yacy_data:/opt/yacy_search_server/DATA --log-opt max-size=200m --log-opt max-file=2 yacy/yacy_search_server:archlinux + + FROM archlinux:latest # update the system and clean up diff --git a/docker/Dockerfile.aarch64 b/docker/Dockerfile.aarch64 index 765e113cb..a01225ac2 100644 --- a/docker/Dockerfile.aarch64 +++ b/docker/Dockerfile.aarch64 @@ -1,4 +1,4 @@ -# Docker image for YaCy +# ARM64v8 Docker image for YaCy # build with # docker build -t yacy/yacy_search_server:aarch64 -f Dockerfile.aarch64 ../ @@ -21,7 +21,6 @@ COPY . /opt/yacy_search_server/ RUN ant compile -f /opt/yacy_search_server/build.xml # Set initial admin password: "yacy" (encoded with custom yacy md5 function net.yacy.cora.order.Digest.encodeMD5Hex()) -# Intially enable HTTPS: this is the most secure option for remote administrator authentication RUN sed -i "/adminAccountBase64MD5=/c\adminAccountBase64MD5=MD5:8cffbc0d66567a0987a4aba1ec46d63c" /opt/yacy_search_server/defaults/yacy.init && \ sed -i "/adminAccountForLocalhost=/c\adminAccountForLocalhost=false" /opt/yacy_search_server/defaults/yacy.init && \ sed -i "/server.https=false/c\server.https=true" /opt/yacy_search_server/defaults/yacy.init @@ -41,8 +40,15 @@ RUN adduser --system --group --no-create-home --disabled-password yacy WORKDIR /opt COPY --chown=yacy:yacy --from=builder /opt/yacy_search_server /opt/yacy_search_server +# Expose HTTP and HTTPS default ports EXPOSE 8090 8443 + +# Set data volume: yacy data and configuration will persist even 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 as a foreground process (-f) to display console logs and to wait for yacy process CMD ["/bin/sh","/opt/yacy_search_server/startYACY.sh","-f"] diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine index 3d1ff1a80..720141774 100644 --- a/docker/Dockerfile.alpine +++ b/docker/Dockerfile.alpine @@ -1,5 +1,11 @@ -# Build a docker image from latest YaCy sources on Alpine Linux -# with wkhtmltopdf for PDF generation and Java 21 +# Alpine Docker image for YaCy + +# build with +# docker build -t yacy/yacy_search_server:alpine -f Dockerfile.alpine ../ + +# run with +# docker run -d --name yacy -p 8090:8090 -p 8443:8443 -v yacy_data:/opt/yacy_search_server/DATA --log-opt max-size=200m --log-opt max-file=2 yacy/yacy_search_server:alpine + ## builder image FROM eclipse-temurin:21-jdk-alpine-3.21 AS builder @@ -10,13 +16,9 @@ RUN apk add --no-cache curl git apache-ant # set current working dir & copy sources WORKDIR /opt COPY . /opt/yacy_search_server/ - RUN ant compile -f /opt/yacy_search_server/build.xml # Set initial admin password: "yacy" (encoded with custom yacy md5 function net.yacy.cora.order.Digest.encodeMD5Hex()) -# Intially enable HTTPS: this is the most secure option for remote administrator authentication -# Create user and group yacy: this user will be used to run YaCy main process -# Set ownership of yacy install directory to yacy user/group RUN sed -i "/adminAccountBase64MD5=/c\adminAccountBase64MD5=MD5:8cffbc0d66567a0987a4aba1ec46d63c" /opt/yacy_search_server/defaults/yacy.init && \ sed -i "/adminAccountForLocalhost=/c\adminAccountForLocalhost=false" /opt/yacy_search_server/defaults/yacy.init && \ sed -i "/server.https=false/c\server.https=true" /opt/yacy_search_server/defaults/yacy.init @@ -55,6 +57,7 @@ RUN apk add --no-cache \ # Copy wkhtmltopdf files from docker-wkhtmltopdf image COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/wkhtmltopdf +# copy YaCy to app image RUN addgroup yacy && adduser -S -G yacy -H -D yacy WORKDIR /opt COPY --chown=yacy:yacy --from=builder /opt/yacy_search_server /opt/yacy_search_server diff --git a/docker/Dockerfile.armv7 b/docker/Dockerfile.armv7 index 7a3134eac..285f84d1d 100644 --- a/docker/Dockerfile.armv7 +++ b/docker/Dockerfile.armv7 @@ -1,26 +1,21 @@ -# Build a docker image from latest YaCy sources +# arm32v7 Docker image for YaCy + +# build with +# docker build -t yacy/yacy_search_server:armv7 -f Dockerfile.armv7 ../ + +# run with +# docker run -d --name yacy -p 8090:8090 -p 8443:8443 -v yacy_data:/opt/yacy_search_server/DATA --log-opt max-size=200m --log-opt max-file=2 yacy/yacy_search_server:armv7 + # Base image : latest Debian stable official jdk 11 image from Docker -FROM arm32v7/openjdk:11-jdk +FROM arm32v7/openjdk:11-jdk as builder -# Install needed packages not in base image -# (curl for sh scripts in /bin, and wkhtmltopdf,imagemagick,xvfb and ghostscript to enable PDF and image snapshot generation) +# Install needed packages not in base image RUN apt-get update && apt-get install -yq curl wkhtmltopdf imagemagick xvfb ghostscript && \ rm -rf /var/lib/apt/lists/* -# trace java version -RUN java -version - -# set current working dir +# set current working dir & copy sources WORKDIR /opt - -# All in one step to reduce image size growth : -# - install ant package -# - Compile with ant -# - remove unnecessary and size consuming .git directory -# - remove ant package - -# copy sources COPY . /opt/yacy_search_server/ RUN rm -rf /opt/yacy_search_server/.git && \ @@ -31,16 +26,11 @@ RUN rm -rf /opt/yacy_search_server/.git && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* -RUN \ # Set initial admin password: "yacy" (encoded with custom yacy md5 function net.yacy.cora.order.Digest.encodeMD5Hex()) -# > java -classpath classes net.yacy.cora.order.Digest -strfhex "admin:The YaCy access is limited to administrators. If you don't know the password, you can change it using <yacy-home>/bin/passwd.sh <new-password>:docker" - sed -i "/adminAccountBase64MD5=/c\adminAccountBase64MD5=MD5:8cffbc0d66567a0987a4aba1ec46d63c" /opt/yacy_search_server/defaults/yacy.init && \ +RUN sed -i "/adminAccountBase64MD5=/c\adminAccountBase64MD5=MD5:8cffbc0d66567a0987a4aba1ec46d63c" /opt/yacy_search_server/defaults/yacy.init && \ sed -i "/adminAccountForLocalhost=/c\adminAccountForLocalhost=false" /opt/yacy_search_server/defaults/yacy.init && \ -# Intially enable HTTPS: this is the most secure option for remote administrator authentication sed -i "/server.https=false/c\server.https=true" /opt/yacy_search_server/defaults/yacy.init && \ -# Create user and group yacy: this user will be used to run YaCy main process adduser --system --group --no-create-home --disabled-password yacy && \ -# Set ownership of yacy install directory to yacy user/group chown yacy:yacy -R /opt/yacy_search_server # Expose HTTP and HTTPS default ports |
